Summary
Migrate CelestraCloud's configuration layer to ConfigKeyKit, matching the pattern already used by MistDemo and BushelCloud. This work happens in the MistKit repo via the CelestraCloud subrepo.
Motivation
CelestraCloud currently hand-rolls what ConfigKeyKit was built to eliminate:
Sources/CelestraCloudKit/Configuration/ConfigurationKeys.swift maintains two string constants per option — a dot key and a paired ENV key (e.g. containerID = "cloudkit.container_id" + containerIDEnv = "CLOUDKIT_CONTAINER_ID"). ~14 paired constants.
ConfigurationLoader.loadConfiguration() hand-writes a fallback chain for every option:
readString(forKey: ...containerID) ?? readString(forKey: ...containerIDEnv) ?? default
~11 of these ?? ...Env ?? default chains.
Every new option means editing both files and keeping the CLI/ENV spelling in sync by hand.
Proposed change
Replace ConfigurationKeys string-pair constants with typed ConfigKey definitions and collapse the loader's fallback chains into a single generic read(_:) that iterates ConfigKeySource.allCases (the helper BushelCloud already wrote).
let containerID = ConfigKey("cloudkit.container_id", default: CloudKitConfiguration.defaultContainerID)
containerID.key(for: .commandLine) // "cloudkit.container_id"
containerID.key(for: .environment) // "CLOUDKIT_CONTAINER_ID"
Why CelestraCloud is a clean fit
Unlike BushelCloud (which needed a bushelPrefixed helper because its env vars are BUSHEL_*), CelestraCloud's env vars are CLOUDKIT_* and UPDATE_* — which StandardNamingStyle derives directly from the base key's first segment (cloudkit.container_id → CLOUDKIT_CONTAINER_ID, update.delay → UPDATE_DELAY). So plain ConfigKey(base, default:) produces the exact spellings already in use — no prefix helper / ConfigKey+CELESTRA.swift needed, and no behavior change for users.
Scope
Touches three files:
Package.swift — add the ConfigKeyKit product dependency.
Sources/CelestraCloudKit/Configuration/ConfigurationKeys.swift — replace string-pair constants with typed ConfigKey definitions.
Sources/CelestraCloudKit/Configuration/ConfigurationLoader.swift — collapse ?? ...Env ?? default chains into generic read(_:) helpers (model on BushelCloud's loader).
The provider stack (CommandLineArgumentsProvider + EnvironmentVariablesProvider) stays identical; ConfigKeyKit pairs with swift-configuration rather than replacing it.
Watch-outs
Update.jsonOutputPath's CLI key is currently "update.json-output-path" (kebab inside a dot key) while the others use snake case. ConfigKeyKit's naming style would normalize it to update.json_output_path — confirm that's acceptable before migrating.
- Run
swift build and the existing config tests to confirm CLI > ENV > default parity is preserved.
References
- ConfigKeyKit: https://github.com/brightdigit/ConfigKeyKit
- Prior adopters: MistDemo (
Examples/MistDemo/Sources/MistDemoKit/Configuration/), BushelCloud (Sources/BushelCloudKit/Configuration/ConfigurationLoader.swift)
Summary
Migrate CelestraCloud's configuration layer to ConfigKeyKit, matching the pattern already used by MistDemo and BushelCloud. This work happens in the MistKit repo via the CelestraCloud subrepo.
Motivation
CelestraCloud currently hand-rolls what ConfigKeyKit was built to eliminate:
Sources/CelestraCloudKit/Configuration/ConfigurationKeys.swiftmaintains two string constants per option — a dot key and a paired ENV key (e.g.containerID = "cloudkit.container_id"+containerIDEnv = "CLOUDKIT_CONTAINER_ID"). ~14 paired constants.ConfigurationLoader.loadConfiguration()hand-writes a fallback chain for every option:?? ...Env ?? defaultchains.Every new option means editing both files and keeping the CLI/ENV spelling in sync by hand.
Proposed change
Replace
ConfigurationKeysstring-pair constants with typedConfigKeydefinitions and collapse the loader's fallback chains into a single genericread(_:)that iteratesConfigKeySource.allCases(the helper BushelCloud already wrote).Why CelestraCloud is a clean fit
Unlike BushelCloud (which needed a
bushelPrefixedhelper because its env vars areBUSHEL_*), CelestraCloud's env vars areCLOUDKIT_*andUPDATE_*— whichStandardNamingStylederives directly from the base key's first segment (cloudkit.container_id→CLOUDKIT_CONTAINER_ID,update.delay→UPDATE_DELAY). So plainConfigKey(base, default:)produces the exact spellings already in use — no prefix helper /ConfigKey+CELESTRA.swiftneeded, and no behavior change for users.Scope
Touches three files:
Package.swift— add theConfigKeyKitproduct dependency.Sources/CelestraCloudKit/Configuration/ConfigurationKeys.swift— replace string-pair constants with typedConfigKeydefinitions.Sources/CelestraCloudKit/Configuration/ConfigurationLoader.swift— collapse?? ...Env ?? defaultchains into genericread(_:)helpers (model on BushelCloud's loader).The provider stack (
CommandLineArgumentsProvider+EnvironmentVariablesProvider) stays identical; ConfigKeyKit pairs with swift-configuration rather than replacing it.Watch-outs
Update.jsonOutputPath's CLI key is currently"update.json-output-path"(kebab inside a dot key) while the others use snake case. ConfigKeyKit's naming style would normalize it toupdate.json_output_path— confirm that's acceptable before migrating.swift buildand the existing config tests to confirm CLI > ENV > default parity is preserved.References
Examples/MistDemo/Sources/MistDemoKit/Configuration/), BushelCloud (Sources/BushelCloudKit/Configuration/ConfigurationLoader.swift)