configs

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cognito

type Cognito struct {
	UseLocal   bool   `env:"COGNITO_USE_LOCAL" yaml:"cognitoUseLocal" envDefault:"false" safe:"true"`
	Endpoint   string `env:"COGNITO_ENDPOINT" yaml:"cognitoEndpoint" safe:"true"`
	ClientId   string `env:"COGNITO_CLIENT_ID" json:"cognitoClientId" yaml:"cognitoClientId"`
	UserPoolId string `env:"COGNITO_USER_POOL_ID" json:"cognitoUserPoolId" yaml:"cognitoUserPoolId"`
	IssuerUrl  string `env:"COGNITO_ISSUER_URL" yaml:"cognitoIssuerUrl"`

	// This will need to be set by the user as it will be dependent on your setup. For example, you might have multiple
	// callback urls that are valid, but if you are running against a live, prelive, or local environment the redirect
	// will be different. Therefore, this is not set by the terraform module itself, but instead should be added by the
	// user.
	RedirectUrl string `env:"COGNITO_REDIRECT_URL" yaml:"cognitoRedirectUrl"`
}

Cognito Struct meant to wrap configuration values to work alongside the https://github.com/project-init/terraform-aws-cognito terraform module. Usage would look similar to

type Config struct {
	// Cognito
	CognitoConfig cfg.CognitoConfig `env:"COGNITO" yaml:"cognito" safe:"true"`
}

var (
	configuration *Config = &Config{}
	once          sync.Once
)

func GetConfig() *Config {
	once.Do(func() {
		opts := []cfg.Option{}

		if configFiles, ok := os.LookupEnv(EnvVarConfigFiles); ok && len(configFiles) > 0 {
			opts = append(opts, cfg.NewFileOption(configFiles))
		}

		if smSecrets, ok := os.LookupEnv(EnvVarConfigAWSSecretsManagerSecrets); ok && len(smSecrets) > 0 {
			opts = append(opts, cfg.NewAWSSecretsManagerOption(secretsmanager.NewFromConfig(aws.GetConfig()), strings.Split(smSecrets, ",")...))
		}

		opts = append(opts, cfg.NewEnvOption())

		if err := cfg.LoadConfigs(configuration, opts...); err != nil {
			sre.LogFatal(err)
		}
	})

	return configuration
}

type RDS added in v0.3.1

type RDS struct {
	PostgresDatabase string `env:"POSTGRES_DATABASE" yaml:"postgresDatabase" safe:"true"`
	PostgresPort     string `env:"POSTGRES_PORT" yaml:"postgresPort" safe:"true"`

	PostgresReadOnlyHost     string `env:"POSTGRES_READ_ONLY_HOST" yaml:"postgresReadOnlyHost" safe:"true"`
	PostgresReadOnlyUser     string `env:"POSTGRES_READ_ONLY_USER" yaml:"postgresReadOnlyUser" safe:"true"`
	PostgresReadOnlyPassword string `env:"POSTGRES_READ_ONLY_PASSWORD" yaml:"postgresReadOnlyPassword"`

	PostgresWriterHost     string `env:"POSTGRES_WRITER_HOST" yaml:"postgresWriterHost" safe:"true"`
	PostgresWriterUser     string `env:"POSTGRES_WRITER_USER" yaml:"postgresWriterUser" safe:"true"`
	PostgresWriterPassword string `env:"POSTGRES_WRITER_PASSWORD" yaml:"postgresWriterPassword"`
}

type Service

type Service struct {
	Env     env.Env `env:"ENV" yaml:"env" safe:"true"`
	Region  string  `env:"AWS_REGION" yaml:"region" safe:"true"`
	Version string  `env:"VERSION" yaml:"version" safe:"true"`
}

Service Struct meant to wrap configuration values to work alongside service modules from project-init

* https://github.com/project-init/terraform-aws-api-service * https://github.com/project-init/terraform-aws-cron * https://github.com/project-init/terraform-aws-grpc-service

Usage would look similar to

type Config struct {
	// Service
	ServiceConfig cfg.ServiceConfig `yaml:"service" safe:"true"`
}

var (
	configuration *Config = &Config{}
	once          sync.Once
)

func GetConfig() *Config {
	once.Do(func() {
		opts := []cfg.Option{}

		if configFiles, ok := os.LookupEnv(EnvVarConfigFiles); ok && len(configFiles) > 0 {
			opts = append(opts, cfg.NewFileOption(configFiles))
		}

		if smSecrets, ok := os.LookupEnv(EnvVarConfigAWSSecretsManagerSecrets); ok && len(smSecrets) > 0 {
			opts = append(opts, cfg.NewAWSSecretsManagerOption(secretsmanager.NewFromConfig(aws.GetConfig()), strings.Split(smSecrets, ",")...))
		}

		opts = append(opts, cfg.NewEnvOption())

		if err := cfg.LoadConfigs(configuration, opts...); err != nil {
			sre.LogFatal(err)
		}
	})

	return configuration
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL