refactor(config): replace auto-update-panel with disable-auto-update-panel for clarity

This commit is contained in:
Luis Pater
2026-03-25 10:31:44 +08:00
parent 1a149475e0
commit 1e6bc81cfd
5 changed files with 40 additions and 29 deletions
+3 -3
View File
@@ -25,9 +25,9 @@ remote-management:
# Disable the bundled management control panel asset download and HTTP route when true. # Disable the bundled management control panel asset download and HTTP route when true.
disable-control-panel: false disable-control-panel: false
# Enable automatic periodic background updates of the management panel from GitHub (default: false). # Disable automatic periodic background updates of the management panel from GitHub (default: false).
# When disabled, the panel is only downloaded on first access if missing, and never auto-updated afterward. # When enabled, the panel is only downloaded on first access if missing, and never auto-updated afterward.
# auto-update-panel: false # disable-auto-update-panel: false
# GitHub repository for the management control panel. Accepts a repository URL or releases API URL. # GitHub repository for the management control panel. Accepts a repository URL or releases API URL.
panel-github-repository: "https://github.com/router-for-me/Cli-Proxy-API-Management-Center" panel-github-repository: "https://github.com/router-for-me/Cli-Proxy-API-Management-Center"
+3 -3
View File
@@ -178,9 +178,9 @@ type RemoteManagement struct {
SecretKey string `yaml:"secret-key"` SecretKey string `yaml:"secret-key"`
// DisableControlPanel skips serving and syncing the bundled management UI when true. // DisableControlPanel skips serving and syncing the bundled management UI when true.
DisableControlPanel bool `yaml:"disable-control-panel"` DisableControlPanel bool `yaml:"disable-control-panel"`
// AutoUpdatePanel enables automatic periodic background updates of the management panel asset from GitHub. // DisableAutoUpdatePanel disables automatic periodic background updates of the management panel asset from GitHub.
// When false (the default), the panel is only downloaded on first access if missing, and never auto-updated. // When false (the default), the background updater remains enabled; when true, the panel is only downloaded on first access if missing.
AutoUpdatePanel bool `yaml:"auto-update-panel"` DisableAutoUpdatePanel bool `yaml:"disable-auto-update-panel"`
// PanelGitHubRepository overrides the GitHub repository used to fetch the management panel asset. // PanelGitHubRepository overrides the GitHub repository used to fetch the management panel asset.
// Accepts either a repository URL (https://github.com/org/repo) or an API releases endpoint. // Accepts either a repository URL (https://github.com/org/repo) or an API releases endpoint.
PanelGitHubRepository string `yaml:"panel-github-repository"` PanelGitHubRepository string `yaml:"panel-github-repository"`
+4 -4
View File
@@ -31,7 +31,7 @@ const (
httpUserAgent = "CLIProxyAPI-management-updater" httpUserAgent = "CLIProxyAPI-management-updater"
managementSyncMinInterval = 30 * time.Second managementSyncMinInterval = 30 * time.Second
updateCheckInterval = 3 * time.Hour updateCheckInterval = 3 * time.Hour
maxAssetDownloadSize = 10 << 20 // 10 MB safety limit for management asset downloads maxAssetDownloadSize = 50 << 20 // 10 MB safety limit for management asset downloads
) )
// ManagementFileName exposes the control panel asset filename. // ManagementFileName exposes the control panel asset filename.
@@ -89,8 +89,8 @@ func runAutoUpdater(ctx context.Context) {
log.Debug("management asset auto-updater skipped: control panel disabled") log.Debug("management asset auto-updater skipped: control panel disabled")
return return
} }
if !cfg.RemoteManagement.AutoUpdatePanel { if cfg.RemoteManagement.DisableAutoUpdatePanel {
log.Debug("management asset auto-updater skipped: auto-update-panel is disabled") log.Debug("management asset auto-updater skipped: disable-auto-update-panel is enabled")
return return
} }
@@ -289,7 +289,7 @@ func ensureFallbackManagementHTML(ctx context.Context, client *http.Client, loca
} }
log.Warnf("management asset downloaded from fallback URL without digest verification (hash=%s) — "+ log.Warnf("management asset downloaded from fallback URL without digest verification (hash=%s) — "+
"consider setting auto-update-panel: true to receive verified updates from GitHub", downloadedHash) "enable verified GitHub updates by keeping disable-auto-update-panel set to false", downloadedHash)
if err = atomicWriteFile(localPath, data); err != nil { if err = atomicWriteFile(localPath, data); err != nil {
log.WithError(err).Warn("failed to persist fallback management control panel page") log.WithError(err).Warn("failed to persist fallback management control panel page")
+3
View File
@@ -256,6 +256,9 @@ func BuildConfigChangeDetails(oldCfg, newCfg *config.Config) []string {
if oldCfg.RemoteManagement.DisableControlPanel != newCfg.RemoteManagement.DisableControlPanel { if oldCfg.RemoteManagement.DisableControlPanel != newCfg.RemoteManagement.DisableControlPanel {
changes = append(changes, fmt.Sprintf("remote-management.disable-control-panel: %t -> %t", oldCfg.RemoteManagement.DisableControlPanel, newCfg.RemoteManagement.DisableControlPanel)) changes = append(changes, fmt.Sprintf("remote-management.disable-control-panel: %t -> %t", oldCfg.RemoteManagement.DisableControlPanel, newCfg.RemoteManagement.DisableControlPanel))
} }
if oldCfg.RemoteManagement.DisableAutoUpdatePanel != newCfg.RemoteManagement.DisableAutoUpdatePanel {
changes = append(changes, fmt.Sprintf("remote-management.disable-auto-update-panel: %t -> %t", oldCfg.RemoteManagement.DisableAutoUpdatePanel, newCfg.RemoteManagement.DisableAutoUpdatePanel))
}
oldPanelRepo := strings.TrimSpace(oldCfg.RemoteManagement.PanelGitHubRepository) oldPanelRepo := strings.TrimSpace(oldCfg.RemoteManagement.PanelGitHubRepository)
newPanelRepo := strings.TrimSpace(newCfg.RemoteManagement.PanelGitHubRepository) newPanelRepo := strings.TrimSpace(newCfg.RemoteManagement.PanelGitHubRepository)
if oldPanelRepo != newPanelRepo { if oldPanelRepo != newPanelRepo {
@@ -23,6 +23,7 @@ func TestBuildConfigChangeDetails(t *testing.T) {
AllowRemote: false, AllowRemote: false,
SecretKey: "old", SecretKey: "old",
DisableControlPanel: false, DisableControlPanel: false,
DisableAutoUpdatePanel: false,
PanelGitHubRepository: "repo-old", PanelGitHubRepository: "repo-old",
}, },
OAuthExcludedModels: map[string][]string{ OAuthExcludedModels: map[string][]string{
@@ -57,6 +58,7 @@ func TestBuildConfigChangeDetails(t *testing.T) {
AllowRemote: true, AllowRemote: true,
SecretKey: "new", SecretKey: "new",
DisableControlPanel: true, DisableControlPanel: true,
DisableAutoUpdatePanel: true,
PanelGitHubRepository: "repo-new", PanelGitHubRepository: "repo-new",
}, },
OAuthExcludedModels: map[string][]string{ OAuthExcludedModels: map[string][]string{
@@ -88,6 +90,7 @@ func TestBuildConfigChangeDetails(t *testing.T) {
expectContains(t, details, "ampcode.upstream-url: http://old-upstream -> http://new-upstream") expectContains(t, details, "ampcode.upstream-url: http://old-upstream -> http://new-upstream")
expectContains(t, details, "ampcode.model-mappings: updated (1 -> 2 entries)") expectContains(t, details, "ampcode.model-mappings: updated (1 -> 2 entries)")
expectContains(t, details, "remote-management.allow-remote: false -> true") expectContains(t, details, "remote-management.allow-remote: false -> true")
expectContains(t, details, "remote-management.disable-auto-update-panel: false -> true")
expectContains(t, details, "remote-management.secret-key: updated") expectContains(t, details, "remote-management.secret-key: updated")
expectContains(t, details, "oauth-excluded-models[providera]: updated (1 -> 2 entries)") expectContains(t, details, "oauth-excluded-models[providera]: updated (1 -> 2 entries)")
expectContains(t, details, "oauth-excluded-models[providerb]: added (1 entries)") expectContains(t, details, "oauth-excluded-models[providerb]: added (1 entries)")
@@ -266,6 +269,7 @@ func TestBuildConfigChangeDetails_FlagsAndKeys(t *testing.T) {
}, },
RemoteManagement: config.RemoteManagement{ RemoteManagement: config.RemoteManagement{
DisableControlPanel: true, DisableControlPanel: true,
DisableAutoUpdatePanel: true,
PanelGitHubRepository: "new/repo", PanelGitHubRepository: "new/repo",
SecretKey: "", SecretKey: "",
}, },
@@ -299,6 +303,7 @@ func TestBuildConfigChangeDetails_FlagsAndKeys(t *testing.T) {
expectContains(t, details, "ampcode.restrict-management-to-localhost: false -> true") expectContains(t, details, "ampcode.restrict-management-to-localhost: false -> true")
expectContains(t, details, "ampcode.upstream-api-key: removed") expectContains(t, details, "ampcode.upstream-api-key: removed")
expectContains(t, details, "remote-management.disable-control-panel: false -> true") expectContains(t, details, "remote-management.disable-control-panel: false -> true")
expectContains(t, details, "remote-management.disable-auto-update-panel: false -> true")
expectContains(t, details, "remote-management.panel-github-repository: old/repo -> new/repo") expectContains(t, details, "remote-management.panel-github-repository: old/repo -> new/repo")
expectContains(t, details, "remote-management.secret-key: deleted") expectContains(t, details, "remote-management.secret-key: deleted")
} }
@@ -338,6 +343,7 @@ func TestBuildConfigChangeDetails_AllBranches(t *testing.T) {
RemoteManagement: config.RemoteManagement{ RemoteManagement: config.RemoteManagement{
AllowRemote: false, AllowRemote: false,
DisableControlPanel: false, DisableControlPanel: false,
DisableAutoUpdatePanel: false,
PanelGitHubRepository: "old/repo", PanelGitHubRepository: "old/repo",
SecretKey: "old", SecretKey: "old",
}, },
@@ -391,6 +397,7 @@ func TestBuildConfigChangeDetails_AllBranches(t *testing.T) {
RemoteManagement: config.RemoteManagement{ RemoteManagement: config.RemoteManagement{
AllowRemote: true, AllowRemote: true,
DisableControlPanel: true, DisableControlPanel: true,
DisableAutoUpdatePanel: true,
PanelGitHubRepository: "new/repo", PanelGitHubRepository: "new/repo",
SecretKey: "", SecretKey: "",
}, },
@@ -460,6 +467,7 @@ func TestBuildConfigChangeDetails_AllBranches(t *testing.T) {
expectContains(t, changes, "oauth-excluded-models[p2]: added (1 entries)") expectContains(t, changes, "oauth-excluded-models[p2]: added (1 entries)")
expectContains(t, changes, "remote-management.allow-remote: false -> true") expectContains(t, changes, "remote-management.allow-remote: false -> true")
expectContains(t, changes, "remote-management.disable-control-panel: false -> true") expectContains(t, changes, "remote-management.disable-control-panel: false -> true")
expectContains(t, changes, "remote-management.disable-auto-update-panel: false -> true")
expectContains(t, changes, "remote-management.panel-github-repository: old/repo -> new/repo") expectContains(t, changes, "remote-management.panel-github-repository: old/repo -> new/repo")
expectContains(t, changes, "remote-management.secret-key: deleted") expectContains(t, changes, "remote-management.secret-key: deleted")
expectContains(t, changes, "openai-compatibility:") expectContains(t, changes, "openai-compatibility:")