Share optional ComfyUI endpoint in core config
This commit is contained in:
1 parent
b012d585f8
commit
4b0566ea46
2 files changed
+21
-1
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
// Package coreconfig lets any service in this workspace receive AuthGuard's, CarrierNode's, and
|
// Package coreconfig lets any service in this workspace receive AuthGuard's, CarrierNode's,
|
||||||
|
// ComfyUI's, and
|
||||||
// ProjectConfigurator's 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
|
||||||
@@ -20,6 +21,9 @@ import (
|
|||||||
// ProjectConfigurator.
|
// ProjectConfigurator.
|
||||||
type Info struct {
|
type Info struct {
|
||||||
AuthGuardURL string `json:"authGuardUrl"`
|
AuthGuardURL string `json:"authGuardUrl"`
|
||||||
|
// ComfyUIURL is the configured ComfyUI endpoint for services that use the
|
||||||
|
// generator. It is optional so services that do not use ComfyUI can ignore it.
|
||||||
|
ComfyUIURL string `json:"comfyUiUrl,omitempty"`
|
||||||
// ProjectConfiguratorURL is the ProjectConfigurator instance that owns the current workspace
|
// ProjectConfiguratorURL is the ProjectConfigurator instance that owns the current workspace
|
||||||
// configuration. Consumers with independent databases can use it to read settings such as the
|
// configuration. Consumers with independent databases can use it to read settings such as the
|
||||||
// configured mount mappings.
|
// configured mount mappings.
|
||||||
@@ -63,6 +67,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 }
|
||||||
|
|
||||||
|
// ComfyUIURL is a convenience accessor for Get().ComfyUIURL.
|
||||||
|
func (s *Store) ComfyUIURL() string { return s.Get().ComfyUIURL }
|
||||||
|
|
||||||
// ProjectConfiguratorURL is a convenience accessor for Get().ProjectConfiguratorURL.
|
// ProjectConfiguratorURL is a convenience accessor for Get().ProjectConfiguratorURL.
|
||||||
func (s *Store) ProjectConfiguratorURL() string { return s.Get().ProjectConfiguratorURL }
|
func (s *Store) ProjectConfiguratorURL() string { return s.Get().ProjectConfiguratorURL }
|
||||||
|
|
||||||
@@ -95,6 +102,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.ComfyUIURL), "/"); url != "" {
|
||||||
|
s.info.ComfyUIURL = url
|
||||||
|
}
|
||||||
if url := strings.TrimRight(strings.TrimSpace(next.ProjectConfiguratorURL), "/"); url != "" {
|
if url := strings.TrimRight(strings.TrimSpace(next.ProjectConfiguratorURL), "/"); url != "" {
|
||||||
s.info.ProjectConfiguratorURL = url
|
s.info.ProjectConfiguratorURL = url
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,16 @@ func TestStoreSetIgnoresBlankFields(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStoreSetComfyUIURL(t *testing.T) {
|
||||||
|
store := NewStore(Info{})
|
||||||
|
|
||||||
|
store.Set(Info{ComfyUIURL: "http://comfyui:8188/"})
|
||||||
|
|
||||||
|
if got := store.ComfyUIURL(); got != "http://comfyui:8188" {
|
||||||
|
t.Fatalf("ComfyUIURL = %q, want trimmed URL", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestStoreOnUpdateFiresWithNewInfo(t *testing.T) {
|
func TestStoreOnUpdateFiresWithNewInfo(t *testing.T) {
|
||||||
store := NewStore(Info{})
|
store := NewStore(Info{})
|
||||||
var got Info
|
var got Info
|
||||||
|
|||||||
Reference in new issue
Block a user