Profiles
Use active and default profiles to load environment-specific configuration.
Profiles let one application load different values for development, staging, production, or another runtime mode.
Procyon keeps two profile sets:
- Active profiles are explicit runtime choices.
- Default profiles are used when no active profile is selected.
The built-in default profile is default.
Active profiles
Set active profiles when you know exactly which environment should be loaded.
procyon:
profiles:
active: devWith dev active, Procyon loads the base file first and then looks for a
profile-specific file:
server:
port: 3000
database:
host: localhostYou can also select the active profile from the runtime environment:
$ go run . --procyon.profiles.active=prod$ PROCYON_PROFILES_ACTIVE=prod go run .Default profiles
Default profiles are fallback profiles. They are useful when local development should use a named profile unless the deployment explicitly chooses another active profile.
procyon:
profiles:
default: localWith no active profile set, Procyon loads resources/procyon-local.yml after the
base file.
Loading order
Base configuration is loaded first. Then the selected profile files are loaded on top of it.
server:
port: 8080
readTimeout: 5
database:
port: 5432server:
port: 80
database:
host: db.internalFor the prod profile, server.port and database.host come from
procyon-prod.yml, while server.readTimeout and database.port still come
from procyon.yml.
Programmatic profile changes
The environment also exposes methods for setting profiles from code. Use this from framework or integration setup code, before configuration-dependent components are initialized.
if err := env.SetActiveProfiles("prod"); err != nil {
return err
}
if err := env.AddActiveProfiles("metrics"); err != nil {
return err
}
if err := env.SetDefaultProfiles("local"); err != nil {
return err
}Profile names must not be empty or blank.
Keep profile selection in one place
Use base configuration, environment variables, command-line arguments, or early startup code to select profiles. Profile-specific files should only contain settings for that profile.
