Expose ProjectConfigurator URL in core config
This commit is contained in:
1 parent
ddcf2fd78d
commit
b012d585f8
1 file changed
+14
-3
@@ -1,5 +1,5 @@
|
|||||||
// Package coreconfig lets any service in this workspace receive AuthGuard's and CarrierNode's
|
// Package coreconfig lets any service in this workspace receive AuthGuard's, CarrierNode's, and
|
||||||
// current base URL(s) pushed from ProjectConfigurator, instead of each service hardcoding them in
|
// ProjectConfigurator's current base URL(s) pushed from ProjectConfigurator, instead of each service hardcoding them in
|
||||||
// its own env vars. ProjectConfigurator's Projects workspace is the operator-facing source of
|
// its own env vars. ProjectConfigurator's Projects workspace is the operator-facing source of
|
||||||
// truth for both (its authguard_url/carriernode_url(_N) settings); it pushes a fresh copy to every
|
// truth for both (its authguard_url/carriernode_url(_N) settings); it pushes a fresh copy to every
|
||||||
// project it has registered whenever either changes, and again on a periodic tick, so a service
|
// project it has registered whenever either changes, and again on a periodic tick, so a service
|
||||||
@@ -16,9 +16,14 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Info is AuthGuard's and CarrierNode's current base URL(s), as pushed by ProjectConfigurator.
|
// Info is AuthGuard's, CarrierNode's, and ProjectConfigurator's current base URL(s), as pushed by
|
||||||
|
// ProjectConfigurator.
|
||||||
type Info struct {
|
type Info struct {
|
||||||
AuthGuardURL string `json:"authGuardUrl"`
|
AuthGuardURL string `json:"authGuardUrl"`
|
||||||
|
// ProjectConfiguratorURL is the ProjectConfigurator instance that owns the current workspace
|
||||||
|
// configuration. Consumers with independent databases can use it to read settings such as the
|
||||||
|
// configured mount mappings.
|
||||||
|
ProjectConfiguratorURL string `json:"projectConfiguratorUrl"`
|
||||||
|
|
||||||
// CarrierNodeURL is the primary CarrierNode instance's URL (CarrierNodeURLs[0], if any) - kept
|
// CarrierNodeURL is the primary CarrierNode instance's URL (CarrierNodeURLs[0], if any) - kept
|
||||||
// for the services that only ever talk to one CarrierNode instance via
|
// for the services that only ever talk to one CarrierNode instance via
|
||||||
@@ -58,6 +63,9 @@ func (s *Store) Get() Info {
|
|||||||
// authclient.Client's SetBaseURL, or (via OnUpdate) to keep one continuously up to date.
|
// authclient.Client's SetBaseURL, or (via OnUpdate) to keep one continuously up to date.
|
||||||
func (s *Store) AuthGuardURL() string { return s.Get().AuthGuardURL }
|
func (s *Store) AuthGuardURL() string { return s.Get().AuthGuardURL }
|
||||||
|
|
||||||
|
// ProjectConfiguratorURL is a convenience accessor for Get().ProjectConfiguratorURL.
|
||||||
|
func (s *Store) ProjectConfiguratorURL() string { return s.Get().ProjectConfiguratorURL }
|
||||||
|
|
||||||
// CarrierNodeURL is a convenience accessor for Get().CarrierNodeURL - the natural closure to wire
|
// CarrierNodeURL is a convenience accessor for Get().CarrierNodeURL - the natural closure to wire
|
||||||
// as a single-instance carriernodeclient.Client's BaseURL: carriernodeclient.New(secret, func(ctx
|
// as a single-instance carriernodeclient.Client's BaseURL: carriernodeclient.New(secret, func(ctx
|
||||||
// context.Context) string { return store.CarrierNodeURL() }).
|
// context.Context) string { return store.CarrierNodeURL() }).
|
||||||
@@ -87,6 +95,9 @@ func (s *Store) Set(next Info) {
|
|||||||
if url := strings.TrimSpace(next.AuthGuardURL); url != "" {
|
if url := strings.TrimSpace(next.AuthGuardURL); url != "" {
|
||||||
s.info.AuthGuardURL = url
|
s.info.AuthGuardURL = url
|
||||||
}
|
}
|
||||||
|
if url := strings.TrimRight(strings.TrimSpace(next.ProjectConfiguratorURL), "/"); url != "" {
|
||||||
|
s.info.ProjectConfiguratorURL = url
|
||||||
|
}
|
||||||
if len(next.CarrierNodeURLs) > 0 {
|
if len(next.CarrierNodeURLs) > 0 {
|
||||||
s.info.CarrierNodeURLs = next.CarrierNodeURLs
|
s.info.CarrierNodeURLs = next.CarrierNodeURLs
|
||||||
s.info.CarrierNodeURL = next.CarrierNodeURLs[0]
|
s.info.CarrierNodeURL = next.CarrierNodeURLs[0]
|
||||||
|
|||||||
Reference in new issue
Block a user