History

refactor(config): remove deprecated AMP configuration keys during save

hkfires committed 11 months ago

Commit df0fd1a1 parent b6bdbe71 file · +12 −1Browse files

Unified · Split

internal/config/config.go+12−1
@@ -588,8 +588,9 @@ func SaveConfigPreserveComments(configFile string, cfg *Config) error { · 587 unmodified lines
588588
589589 // Remove deprecated auth block before merging to avoid persisting it again.
590590 removeMapKey(original.Content[0], "auth")
591− removeLegacyOpenAICompatAPIKeys(original.Content[0])
592591 removeMapKey(original.Content[0], "generative-language-api-key")
592+ removeLegacyOpenAICompatAPIKeys(original.Content[0])
593+ removeLegacyAmpKeys(original.Content[0])
593594 pruneMappingToGeneratedKeys(original.Content[0], generated.Content[0], "oauth-excluded-models")
594595
595596 // Merge generated into original in-place, preserving comments/order of existing nodes.
@@ -1071,6 +1072,16 @@ func removeLegacyOpenAICompatAPIKeys(root *yaml.Node) { · 475 unmodified lines
10711072 }
10721073 }
10731074
1075+func removeLegacyAmpKeys(root *yaml.Node) {
1076+ if root == nil || root.Kind != yaml.MappingNode {
1077+ return
1078+ }
1079+ removeMapKey(root, "amp-upstream-url")
1080+ removeMapKey(root, "amp-upstream-api-key")
1081+ removeMapKey(root, "amp-restrict-management-to-localhost")
1082+ removeMapKey(root, "amp-model-mappings")
1083+}
1084+
10741085 func pruneMappingToGeneratedKeys(dstRoot, srcRoot *yaml.Node, key string) {
10751086 if key == "" || dstRoot == nil || srcRoot == nil {
10761087 return