refactor(installer): centralise postgres users and vault secret names in codesphere package#492
Merged
Conversation
… in codesphere package Introduce two canonical definitions in internal/codesphere to eliminate scattered string literals and duplicate service lists across the installer: **PostgresService struct** (postgres.go) - Defines every Codesphere service that owns a dedicated postgres user, with an optional username override (e.g. usageAggregationRefresher → usage_aggregation_refresher). - Replaces independent []string slices that existed in config_yaml.go, secrets/secrets.go, and config_manager.go. **Secrets map** (secrets.go) - Single map[string]string registry of every vault secret name used across the installer (auth keys, JWT tokens, postgres, ceph, TLS, OIDC, git providers, registry, ACME, OpenBao, monitoring, nix, optional Helm defaults). - Replaces the files.Secret* constants that were defined in secret_names.go (now deleted) and all raw string literals in EnsureSecrets functions, MergeVaultIntoConfig, and AddSecretsToVault. - MergedSecretNames slice (derived from the map) drives the known-secret set in MergeVaultIntoConfig, so the extra-secrets round-trip stays in sync automatically. **Extra secrets round-trip** (config_yaml.go + config_manager.go) - RootConfig gains an ExtraSecrets []SecretEntry field (yaml:"-"). - MergeVaultIntoConfig stores any vault entry not in MergedSecretNames into ExtraSecrets; AddSecretsToVault re-emits them last so custom vault entries survive a merge → extract cycle without overriding known secrets. Tests added for PostgresService.DBUsername overrides, extra-secrets round-trip, and MergeVaultIntoConfig postgres password mapping. Signed-off-by: Tim Schrodi <tim@codesphere.com>
NJona
approved these changes
Jun 16, 2026
NJona
left a comment
Member
There was a problem hiding this comment.
lgtm, but someone from OMS should also review I guess
All secret values (private keys, passwords, OAuth client IDs/secrets, ACME EAB MAC keys, registry credentials) are removed from yaml:"-" struct fields and stored exclusively in *files.InstallVault via vault.SetSecret / vault.GetSecret. Key changes: - Add internal/installer/files/secret_names.go with typed const names for every secret previously scattered across config structs - Remove MergeVaultIntoConfig (vault→config) and ExtractVault / AddSecretsToVault (config→vault) — callers now use vault directly - Remove yaml:"-" secret fields from PostgresConfig, ACMEConfig, OAuthConfig, OpenBaoConfig, RegistryConfig and all git-provider OAuth structs - Update all production code in bootstrap/gcp, installer and cli/cmd to read/write secrets through the vault - Fix all affected tests to assert on vault contents instead of removed struct fields; drop tests for removed functions Signed-off-by: Tim Schrodi <tim@codesphere.com>
NautiluX
approved these changes
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce two canonical definitions in internal/codesphere to eliminate scattered string literals and duplicate service lists across the installer:
PostgresService struct (postgres.go)
Secrets map (secrets.go)
Extra secrets round-trip (config_yaml.go + config_manager.go)
Tests added for PostgresService.DBUsername overrides, extra-secrets round-trip, and MergeVaultIntoConfig postgres password mapping.