Documentation ¶
Overview ¶
Package config load settings from external files or environment variables and manage their values.
Index ¶
Constants ¶
const ConfigFilePath string = ".spare.yml"
ConfigFilePath is the path of the configuration file.
Variables ¶
var ( // ErrConfigFileAlreadyExists is an error that occurs when the config file already exists. ErrConfigFileAlreadyExists = fmt.Errorf("%s config file already exists", ConfigFilePath) // ErrInvalidRegion is an error that occurs when the region is invalid. ErrInvalidRegion = errors.New("invalid region") // ErrInvalidBucket is an error that occurs when the bucket is invalid. ErrInvalidBucket = errors.New("invalid bucket") // ErrInvalidSpareTemplateVersion is an error that occurs when the spare template version is invalid. ErrInvalidSpareTemplateVersion = errors.New("invalid spare template version") // ErrInvalidDeployTarget is an error that occurs when the deploy target is invalid. ErrInvalidDeployTarget = errors.New("invalid deploy target") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { SpareTemplateVersion TemplateVersion `yaml:"spareTemplateVersion"` // DeployTarget is the path of the deploy target (it's SPA). DeployTarget DeployTarget `yaml:"deployTarget"` // Region is AWS region. Region model.Region `yaml:"region"` // CustomDomain is the domain name of the CloudFront. // If you do not specify this, the CloudFront default domain name is used. CustomDomain model.Domain `yaml:"customDomain"` // S3BucketName is the name of the S3 bucket. S3BucketName model.BucketName `yaml:"s3BucketName"` // AllowOrigins is the list of domains that are allowed to access the SPA. AllowOrigins model.AllowOrigins `yaml:"allowOrigins"` DebugLocalstackEndpoint model.Endpoint `yaml:"debugLocalstackEndpoint"` }
Config is a struct that corresponds to the configuration file ".spare.yml".
func (*Config) DefaultS3BucketName ¶
func (c *Config) DefaultS3BucketName() model.BucketName
DefaultS3BucketName returns the default S3 bucket name.
type DeployTarget ¶
type DeployTarget string
DeployTarget is a type that represents a deploy target path.
func (DeployTarget) String ¶
func (d DeployTarget) String() string
String returns the string representation of DeployTarget.
func (DeployTarget) Validate ¶
func (d DeployTarget) Validate() error
Validate validates DeployTarget. If DeployTarget is invalid, it returns an error. DeployTarget is invalid if it is empty.
type S3 ¶
type S3 struct { // Bucket is the name of the S3 bucket. Bucket model.BucketName `env:"spare_BUCKET"` // Region is the name of the AWS region. Region model.Region `env:"spare_REGION" envDefault:"us-east-1"` }
S3 is a struct that contains the settings for the S3 storage.
type TemplateVersion ¶
type TemplateVersion string
TemplateVersion is a type that represents a spare template version.
const CurrentSpareTemplateVersion TemplateVersion = "0.0.1"
CurrentSpareTemplateVersion is the version of the template.
func (TemplateVersion) String ¶
func (t TemplateVersion) String() string
String returns the string representation of TemplateVersion.
func (TemplateVersion) Validate ¶
func (t TemplateVersion) Validate() error
Validate validates TemplateVersion. If TemplateVersion is invalid, it returns an error. TemplateVersion is invalid if it is empty.