修改配置编辑不了的问题
This commit is contained in:
1 parent
22b504e53e
commit
2a2f78c81e
42 files changed
+1082
-178
No files matched your search
@@ -13,6 +13,14 @@ import (
|
||||
)
|
||||
|
||||
type RuntimeUpdater func(context.Context, map[string]string) error
|
||||
|
||||
// RuntimeSettingsRepository persists the subset of settings that can be
|
||||
// applied to provider calls without restarting the Go process.
|
||||
type RuntimeSettingsRepository interface {
|
||||
LoadRuntimeSettings(context.Context, []string) (map[string]string, error)
|
||||
SaveRuntimeSettings(context.Context, map[string]string) error
|
||||
}
|
||||
|
||||
type Option struct {
|
||||
Label string `json:"label"`
|
||||
Value string `json:"value"`
|
||||
@@ -72,6 +80,8 @@ type Service struct {
|
||||
mu sync.Mutex
|
||||
path string
|
||||
environment map[string]string
|
||||
provider map[string]string
|
||||
repository RuntimeSettingsRepository
|
||||
update RuntimeUpdater
|
||||
billing BillingAccountWriter
|
||||
}
|
||||
@@ -85,7 +95,14 @@ type BillingAccountWriter interface {
|
||||
}
|
||||
|
||||
func New(path string, environment map[string]string, updater RuntimeUpdater) *Service {
|
||||
return &Service{path: path, environment: cloneStrings(environment), update: updater}
|
||||
return NewWithRuntimeRepository(path, environment, nil, updater)
|
||||
}
|
||||
|
||||
func NewWithRuntimeRepository(path string, environment map[string]string, repository RuntimeSettingsRepository, updater RuntimeUpdater) *Service {
|
||||
return &Service{
|
||||
path: path, environment: cloneStrings(environment), provider: map[string]string{},
|
||||
repository: repository, update: updater,
|
||||
}
|
||||
}
|
||||
|
||||
// LoadEnvironment reads only the settings whitelist. Values already supplied
|
||||
@@ -108,11 +125,17 @@ func LoadEnvironment(path string, environment map[string]string) (map[string]str
|
||||
}
|
||||
|
||||
func RuntimeSettingKeys() []string {
|
||||
keys := make([]string, 0, len(fieldIndex)+len(runtimeOnlyKeys))
|
||||
keys := make([]string, 0, len(fieldIndex))
|
||||
for key := range fieldIndex {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
for key := range runtimeOnlyKeys {
|
||||
sort.Strings(keys)
|
||||
return keys
|
||||
}
|
||||
|
||||
func ProviderSettingKeys() []string {
|
||||
keys := make([]string, 0, len(providerSettingKeys))
|
||||
for key := range providerSettingKeys {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
@@ -120,10 +143,7 @@ func RuntimeSettingKeys() []string {
|
||||
}
|
||||
|
||||
func allowedEnvironmentKey(key string) bool {
|
||||
if _, allowed := fieldIndex[key]; allowed {
|
||||
return true
|
||||
}
|
||||
_, allowed := runtimeOnlyKeys[key]
|
||||
_, allowed := fieldIndex[key]
|
||||
return allowed
|
||||
}
|
||||
|
||||
@@ -137,14 +157,53 @@ func (s *Service) Get(ctx context.Context) (any, error) {
|
||||
}
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if err := s.refreshProviderSettings(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.get()
|
||||
}
|
||||
|
||||
// RuntimeValues returns one coherent provider configuration snapshot. Database
|
||||
// values override process/file values, including an explicitly saved empty
|
||||
// non-secret value. Callers use a fresh snapshot per request or worker action
|
||||
// so changes made through another replica are also observed.
|
||||
func (s *Service) RuntimeValues(ctx context.Context) (map[string]string, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if err := s.refreshProviderSettings(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.runtimeValues()
|
||||
}
|
||||
|
||||
// CachedRuntimeValues is the non-blocking fallback used by liveness reporting
|
||||
// if PostgreSQL is temporarily unavailable. Mutating/provider request paths use
|
||||
// RuntimeValues and therefore still fail closed on a refresh error.
|
||||
func (s *Service) CachedRuntimeValues() map[string]string {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
values, err := s.runtimeValues()
|
||||
if err != nil {
|
||||
values = cloneStrings(s.environment)
|
||||
for key, value := range s.provider {
|
||||
values[key] = value
|
||||
}
|
||||
}
|
||||
return values
|
||||
}
|
||||
|
||||
func (s *Service) Save(ctx context.Context, values map[string]any) (any, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if err := s.refreshProviderSettings(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
updates := map[string]string{}
|
||||
for key, raw := range values {
|
||||
field, ok := fieldIndex[key]
|
||||
@@ -159,24 +218,46 @@ func (s *Service) Save(ctx context.Context, values map[string]any) (any, error)
|
||||
updates[key] = next
|
||||
}
|
||||
if len(updates) > 0 {
|
||||
// Capture the complete persisted view before writing so a partial billing
|
||||
// account update cannot blank sibling fields that only exist in the file.
|
||||
persisted, err := readEnv(s.path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
providerUpdates, fileUpdates := map[string]string{}, map[string]string{}
|
||||
for key, value := range updates {
|
||||
if s.repository != nil && isProviderSetting(key) {
|
||||
providerUpdates[key] = value
|
||||
} else {
|
||||
fileUpdates[key] = value
|
||||
}
|
||||
}
|
||||
if err := s.write(updates); err != nil {
|
||||
return nil, err
|
||||
// Capture the complete file-backed view before writing so a partial billing
|
||||
// account update cannot blank sibling fields.
|
||||
persisted := map[string]string{}
|
||||
if len(fileUpdates) > 0 || containsBillingAccountUpdate(updates) {
|
||||
var err error
|
||||
persisted, err = readEnv(s.path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if len(fileUpdates) > 0 {
|
||||
if err := s.write(fileUpdates); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if len(providerUpdates) > 0 {
|
||||
if err := s.repository.SaveRuntimeSettings(ctx, cloneStrings(providerUpdates)); err != nil {
|
||||
return nil, fmt.Errorf("persist provider settings: %w", err)
|
||||
}
|
||||
}
|
||||
if s.update != nil {
|
||||
if err := s.update(ctx, cloneStrings(updates)); err != nil {
|
||||
return nil, fmt.Errorf("apply runtime settings: %w", err)
|
||||
}
|
||||
}
|
||||
for key, value := range updates {
|
||||
for key, value := range fileUpdates {
|
||||
s.environment[key] = value
|
||||
persisted[key] = value
|
||||
}
|
||||
for key, value := range providerUpdates {
|
||||
s.provider[key] = value
|
||||
}
|
||||
if s.billing != nil && containsBillingAccountUpdate(updates) {
|
||||
if err := s.billing.SaveBillingAccount(ctx, BillingAccount{
|
||||
AccountName: billingSetting(s.environment, persisted, "ZHINIAN_BILLING_ACCOUNT_NAME"),
|
||||
@@ -214,6 +295,9 @@ func containsBillingAccountUpdate(updates map[string]string) bool {
|
||||
|
||||
func requiresRestart(updates map[string]string) bool {
|
||||
for key := range updates {
|
||||
if isProviderSetting(key) {
|
||||
continue
|
||||
}
|
||||
switch key {
|
||||
case "ZHINIAN_BILLING_ACCOUNT_NAME", "ZHINIAN_BILLING_ACCOUNT_BANK", "ZHINIAN_BILLING_ACCOUNT_NUMBER", "ZHINIAN_BILLING_CONTACT":
|
||||
continue
|
||||
@@ -229,6 +313,9 @@ func (s *Service) get() (Payload, error) {
|
||||
return Payload{}, err
|
||||
}
|
||||
current := func(field Field) string {
|
||||
if value, ok := s.provider[field.Key]; ok {
|
||||
return value
|
||||
}
|
||||
if value, ok := s.environment[field.Key]; ok {
|
||||
return value
|
||||
}
|
||||
@@ -250,19 +337,56 @@ func (s *Service) get() (Payload, error) {
|
||||
}
|
||||
image := normalizeImage(current(fieldIndex["IMAGE_GENERATE_ENGINE"]))
|
||||
video := normalizeVideo(current(fieldIndex["VIDEO_GENERATE_ENGINE"]))
|
||||
imageModel := map[string]string{"jimeng": lookup(s.environment, file, "JIMENG_IMAGE_GENERATE_46_REQ_KEY", "jimeng_seedream46_cvtob"), "evolink": lookup(s.environment, file, "EVOLINK_IMAGE_MODEL", "gpt-image-2"), "bailian": lookup(s.environment, file, "BAILIAN_IMAGE_MODEL", "wan2.7-image-pro")}[image]
|
||||
videoModel := lookup(s.environment, file, "SEEDANCE_MODEL", "doubao-seedance-2-0-260128")
|
||||
imageModel := map[string]string{"jimeng": lookup(s.provider, s.environment, file, "JIMENG_IMAGE_GENERATE_46_REQ_KEY", "jimeng_seedream46_cvtob"), "evolink": lookup(s.provider, s.environment, file, "EVOLINK_IMAGE_MODEL", "gpt-image-2"), "bailian": lookup(s.provider, s.environment, file, "BAILIAN_IMAGE_MODEL", "wan2.7-image-pro")}[image]
|
||||
videoModel := lookup(s.provider, s.environment, file, "SEEDANCE_MODEL", "doubao-seedance-2-0-260128")
|
||||
if video == "bailian" {
|
||||
videoModel = lookup(s.environment, file, "BAILIAN_VIDEO_MODEL", "wan2.7-i2v-2026-04-25")
|
||||
videoModel = lookup(s.provider, s.environment, file, "BAILIAN_VIDEO_MODEL", "wan2.7-i2v-2026-04-25")
|
||||
}
|
||||
imageConnected := connected(image, s.environment, file)
|
||||
videoConnected := connected(video, s.environment, file)
|
||||
imageField := project(fieldIndex["IMAGE_GENERATE_ENGINE"], image, s.environment, file)
|
||||
videoField := project(fieldIndex["VIDEO_GENERATE_ENGINE"], video, s.environment, file)
|
||||
imageConnected := connected(image, s.provider, s.environment, file)
|
||||
videoConnected := connected(video, s.provider, s.environment, file)
|
||||
imageField := project(fieldIndex["IMAGE_GENERATE_ENGINE"], image, s.provider, s.environment, file)
|
||||
videoField := project(fieldIndex["VIDEO_GENERATE_ENGINE"], video, s.provider, s.environment, file)
|
||||
assignments := []EngineAssignment{{ID: "image.generate", Label: "图片生成", Engine: image, EngineLabel: label(image), Connected: imageConnected, ConnectionLabel: connection(imageConnected), ReqKey: imageModel, Configurable: true, Field: &imageField}, {ID: "video.generate", Label: "视频生成", Engine: video, EngineLabel: label(video), Connected: videoConnected, ConnectionLabel: connection(videoConnected), ReqKey: videoModel, Configurable: true, Field: &videoField}}
|
||||
services := Services{Visual: connected("jimeng", s.environment, file), Evolink: connected("evolink", s.environment, file), Seedance: connected("seedance", s.environment, file), Bailian: connected("bailian", s.environment, file), Auth: lookup(s.environment, file, "ZHINIAN_AUTH_SESSION_SECRET", "") != "", Organization: lookup(s.environment, file, "DATABASE_URL", "") != "" || lookup(s.environment, file, "ZHINIAN_AUTH_SESSION_SECRET", "") != ""}
|
||||
services := Services{Visual: connected("jimeng", s.provider, s.environment, file), Evolink: connected("evolink", s.provider, s.environment, file), Seedance: connected("seedance", s.provider, s.environment, file), Bailian: connected("bailian", s.provider, s.environment, file), Auth: lookup(s.provider, s.environment, file, "ZHINIAN_AUTH_SESSION_SECRET", "") != "", Organization: lookup(s.provider, s.environment, file, "DATABASE_URL", "") != "" || lookup(s.provider, s.environment, file, "ZHINIAN_AUTH_SESSION_SECRET", "") != ""}
|
||||
return Payload{Services: services, Capabilities: []Capability{{ID: "image.generate", Label: "图片生成 4.6", ReqKey: imageModel, Engine: image, EngineLabel: label(image), Enabled: true}, {ID: "video.generate", Label: "视频生成", ReqKey: videoModel, Engine: video, EngineLabel: label(video), Enabled: true}}, EngineAssignments: assignments, Groups: groups}, nil
|
||||
}
|
||||
|
||||
func (s *Service) refreshProviderSettings(ctx context.Context) error {
|
||||
if s.repository == nil {
|
||||
return nil
|
||||
}
|
||||
values, err := s.repository.LoadRuntimeSettings(ctx, ProviderSettingKeys())
|
||||
if err != nil {
|
||||
return fmt.Errorf("load provider settings: %w", err)
|
||||
}
|
||||
s.provider = map[string]string{}
|
||||
for key, value := range values {
|
||||
if isProviderSetting(key) {
|
||||
s.provider[key] = value
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) runtimeValues() (map[string]string, error) {
|
||||
file, err := readEnv(s.path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
values := map[string]string{}
|
||||
for key, value := range file {
|
||||
if allowedEnvironmentKey(key) {
|
||||
values[key] = value
|
||||
}
|
||||
}
|
||||
for key, value := range s.environment {
|
||||
values[key] = value
|
||||
}
|
||||
for key, value := range s.provider {
|
||||
values[key] = value
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
func (s *Service) write(updates map[string]string) error {
|
||||
data, err := os.ReadFile(s.path)
|
||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
@@ -413,7 +537,10 @@ func cloneStrings(input map[string]string) map[string]string {
|
||||
}
|
||||
return out
|
||||
}
|
||||
func lookup(environment, file map[string]string, key, fallback string) string {
|
||||
func lookup(provider, environment, file map[string]string, key, fallback string) string {
|
||||
if value, ok := provider[key]; ok {
|
||||
return value
|
||||
}
|
||||
if value, ok := environment[key]; ok {
|
||||
return value
|
||||
}
|
||||
@@ -422,9 +549,9 @@ func lookup(environment, file map[string]string, key, fallback string) string {
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
func project(field Field, value string, environment, file map[string]string) Field {
|
||||
func project(field Field, value string, provider, environment, file map[string]string) Field {
|
||||
field.Value = value
|
||||
field.Configured = lookup(environment, file, field.Key, "") != ""
|
||||
field.Configured = lookup(provider, environment, file, field.Key, "") != ""
|
||||
return field
|
||||
}
|
||||
func normalizeImage(value string) string {
|
||||
@@ -458,16 +585,16 @@ func connection(ok bool) string {
|
||||
}
|
||||
return "待配置"
|
||||
}
|
||||
func connected(engine string, environment, file map[string]string) bool {
|
||||
func connected(engine string, provider, environment, file map[string]string) bool {
|
||||
switch engine {
|
||||
case "evolink":
|
||||
return strings.TrimSpace(lookup(environment, file, "EVOLINK_API_KEY", "")) != ""
|
||||
return strings.TrimSpace(lookup(provider, environment, file, "EVOLINK_API_KEY", "")) != ""
|
||||
case "seedance":
|
||||
return strings.TrimSpace(lookup(environment, file, "SEEDANCE_API_KEY", "")) != ""
|
||||
return strings.TrimSpace(lookup(provider, environment, file, "SEEDANCE_API_KEY", "")) != ""
|
||||
case "bailian":
|
||||
return strings.TrimSpace(lookup(environment, file, "BAILIAN_API_KEY", "")) != "" || strings.TrimSpace(lookup(environment, file, "DASHSCOPE_API_KEY", "")) != ""
|
||||
return strings.TrimSpace(lookup(provider, environment, file, "BAILIAN_API_KEY", "")) != "" || strings.TrimSpace(lookup(provider, environment, file, "DASHSCOPE_API_KEY", "")) != ""
|
||||
default:
|
||||
return strings.TrimSpace(lookup(environment, file, "VOLCENGINE_ACCESS_KEY_ID", "")) != "" && strings.TrimSpace(lookup(environment, file, "VOLCENGINE_SECRET_ACCESS_KEY", "")) != ""
|
||||
return strings.TrimSpace(lookup(provider, environment, file, "VOLCENGINE_ACCESS_KEY_ID", "")) != "" && strings.TrimSpace(lookup(provider, environment, file, "VOLCENGINE_SECRET_ACCESS_KEY", "")) != ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,8 +622,23 @@ var fieldIndex = func() map[string]Field {
|
||||
return result
|
||||
}()
|
||||
|
||||
// runtimeOnlyKeys are read from the process/settings file by the Go startup
|
||||
// loader but are intentionally not exposed as editable settings-panel fields.
|
||||
var runtimeOnlyKeys = map[string]struct{}{
|
||||
"ZHINIAN_ALLOW_UNCONFIGURED_PROVIDERS": {},
|
||||
var providerSettingKeys = map[string]struct{}{
|
||||
"VOLCENGINE_ACCESS_KEY_ID": {},
|
||||
"VOLCENGINE_SECRET_ACCESS_KEY": {},
|
||||
"EVOLINK_API_KEY": {},
|
||||
"EVOLINK_BASE_URL": {},
|
||||
"EVOLINK_IMAGE_MODEL": {},
|
||||
"EVOLINK_IMAGE_QUALITY": {},
|
||||
"SEEDANCE_API_KEY": {},
|
||||
"BAILIAN_API_KEY": {},
|
||||
"BAILIAN_BASE_URL": {},
|
||||
"BAILIAN_IMAGE_MODEL": {},
|
||||
"BAILIAN_VIDEO_MODEL": {},
|
||||
"IMAGE_GENERATE_ENGINE": {},
|
||||
"VIDEO_GENERATE_ENGINE": {},
|
||||
}
|
||||
|
||||
func isProviderSetting(key string) bool {
|
||||
_, ok := providerSettingKeys[key]
|
||||
return ok
|
||||
}
|
||||
@@ -65,12 +65,61 @@ func TestServiceSavePreservesSecretsAndUnrelatedEnvLines(t *testing.T) {
|
||||
if !reflect.DeepEqual(applied, map[string]string{"ZHINIAN_BILLING_CONTACT": "", "EVOLINK_BASE_URL": "https://new.example/v1"}) {
|
||||
t.Fatalf("applied = %#v", applied)
|
||||
}
|
||||
if payload := value.(Payload); !payload.RestartRequired {
|
||||
t.Fatal("provider setting update must declare restartRequired")
|
||||
if payload := value.(Payload); payload.RestartRequired {
|
||||
t.Fatal("provider setting update must be applied without restart")
|
||||
}
|
||||
assertSecretProjection(t, value, "ZHINIAN_AUTH_SESSION_SECRET", true)
|
||||
}
|
||||
|
||||
func TestRuntimeRepositoryOverridesEnvironmentAndProjectsSecrets(t *testing.T) {
|
||||
repository := &runtimeSettingsRepositoryStub{values: map[string]string{
|
||||
"EVOLINK_API_KEY": "database-secret",
|
||||
"EVOLINK_BASE_URL": "https://database.example",
|
||||
"IMAGE_GENERATE_ENGINE": "evolink",
|
||||
}}
|
||||
service := NewWithRuntimeRepository(
|
||||
filepath.Join(t.TempDir(), ".env.local"),
|
||||
map[string]string{"EVOLINK_API_KEY": "environment-secret", "EVOLINK_BASE_URL": "https://environment.example"},
|
||||
repository,
|
||||
nil,
|
||||
)
|
||||
value, err := service.Get(context.Background())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := fieldValue(t, value, "EVOLINK_BASE_URL"); got != "https://database.example" {
|
||||
t.Fatalf("base URL = %q", got)
|
||||
}
|
||||
assertSecretProjection(t, value, "EVOLINK_API_KEY", true)
|
||||
runtime, err := service.RuntimeValues(context.Background())
|
||||
if err != nil || runtime["EVOLINK_API_KEY"] != "database-secret" {
|
||||
t.Fatalf("runtime=%#v err=%v", runtime, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRuntimeRepositorySaveIsPartialImmediateAndDoesNotCreateSettingsFile(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "nested", ".env.local")
|
||||
repository := &runtimeSettingsRepositoryStub{values: map[string]string{"EVOLINK_API_KEY": "keep-secret"}}
|
||||
service := NewWithRuntimeRepository(path, nil, repository, nil)
|
||||
value, err := service.Save(context.Background(), map[string]any{
|
||||
"EVOLINK_API_KEY": " ",
|
||||
"EVOLINK_BASE_URL": " https://saved.example ",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(repository.saved, map[string]string{"EVOLINK_BASE_URL": "https://saved.example"}) {
|
||||
t.Fatalf("saved=%#v", repository.saved)
|
||||
}
|
||||
if _, err := os.Stat(path); !os.IsNotExist(err) {
|
||||
t.Fatalf("provider save unexpectedly created local settings file: %v", err)
|
||||
}
|
||||
if value.(Payload).RestartRequired {
|
||||
t.Fatal("provider database update should apply immediately")
|
||||
}
|
||||
assertSecretProjection(t, value, "EVOLINK_API_KEY", true)
|
||||
}
|
||||
|
||||
func TestServiceGetUsesInjectedEnvironmentWithoutMutatingProcess(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), ".env.local")
|
||||
if err := os.WriteFile(path, []byte("EVOLINK_BASE_URL=file-value\nSEEDANCE_API_KEY=file-secret\n"), 0o600); err != nil {
|
||||
@@ -100,7 +149,7 @@ func TestServiceGetUsesInjectedEnvironmentWithoutMutatingProcess(t *testing.T) {
|
||||
assertSecretProjection(t, value, "SEEDANCE_API_KEY", true)
|
||||
}
|
||||
|
||||
func TestLoadEnvironmentAllowsBootstrapRuntimeFlagButIgnoresUnknownKeys(t *testing.T) {
|
||||
func TestLoadEnvironmentIgnoresUnknownRuntimeFlags(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), ".env.local")
|
||||
if err := os.WriteFile(path, []byte("ZHINIAN_ALLOW_UNCONFIGURED_PROVIDERS=true\nUNKNOWN_RUNTIME_FLAG=true\n"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -109,8 +158,8 @@ func TestLoadEnvironmentAllowsBootstrapRuntimeFlagButIgnoresUnknownKeys(t *testi
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if values["ZHINIAN_ALLOW_UNCONFIGURED_PROVIDERS"] != "true" {
|
||||
t.Fatalf("bootstrap flag = %q", values["ZHINIAN_ALLOW_UNCONFIGURED_PROVIDERS"])
|
||||
if _, exists := values["ZHINIAN_ALLOW_UNCONFIGURED_PROVIDERS"]; exists {
|
||||
t.Fatal("obsolete provider bootstrap flag was loaded")
|
||||
}
|
||||
if _, exists := values["UNKNOWN_RUNTIME_FLAG"]; exists {
|
||||
t.Fatal("unknown runtime flag was loaded")
|
||||
@@ -160,6 +209,26 @@ func (writer *billingWriterStub) SaveBillingAccount(_ context.Context, value Bil
|
||||
return nil
|
||||
}
|
||||
|
||||
type runtimeSettingsRepositoryStub struct {
|
||||
values map[string]string
|
||||
saved map[string]string
|
||||
}
|
||||
|
||||
func (repository *runtimeSettingsRepositoryStub) LoadRuntimeSettings(_ context.Context, _ []string) (map[string]string, error) {
|
||||
return clone(repository.values), nil
|
||||
}
|
||||
|
||||
func (repository *runtimeSettingsRepositoryStub) SaveRuntimeSettings(_ context.Context, values map[string]string) error {
|
||||
repository.saved = clone(values)
|
||||
if repository.values == nil {
|
||||
repository.values = map[string]string{}
|
||||
}
|
||||
for key, value := range values {
|
||||
repository.values[key] = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func fieldValue(t *testing.T, value any, key string) string {
|
||||
t.Helper()
|
||||
payload := value.(Payload)
|
||||
|
||||
Reference in new issue
Block a user