Documentation
¶
Overview ¶
Package config provides configuration management for the ephemeralfiles CLI. It supports loading configuration from both YAML files and environment variables, with environment variables taking precedence over file-based configuration.
Index ¶
- Constants
- Variables
- func DefaultConfigFilePath() string
- func DefautConfigDir() string
- type Config
- func (c *Config) IsConfigValid() bool
- func (c *Config) LoadConfigFromEnvVar()
- func (c *Config) LoadConfigFromFile(filename string) error
- func (c *Config) LoadConfiguration(cfgFilePath string) error
- func (c *Config) SaveConfiguration(cfgFilePath string) error
- func (c *Config) SetHomedir(homedir string)
Constants ¶
const ( // ConfigurationDirPerm is the permission (0700) for the configuration directory. ConfigurationDirPerm = 0700 // ConfigurationFilePerm is the permission (0600) for configuration files. ConfigurationFilePerm = 0600 )
Variables ¶
var ( // ErrConfigurationNotFound is returned when no valid configuration is found. ErrConfigurationNotFound = errors.New("configuration not found") // ErrInvalidToken is returned when the provided token is invalid. ErrInvalidToken = errors.New("token is invalid") // ErrInvalidEndpoint is returned when the provided endpoint is invalid. ErrInvalidEndpoint = errors.New("endpoint is invalid") )
Functions ¶
func DefaultConfigFilePath ¶ added in v0.2.0
func DefaultConfigFilePath() string
DefaultConfigFilePath returns the default configuration file path.
func DefautConfigDir ¶ added in v0.2.0
func DefautConfigDir() string
DefautConfigDir returns the default configuration directory path.
Types ¶
type Config ¶
type Config struct {
Token string `yaml:"token"`
Endpoint string `yaml:"endpoint"`
// contains filtered or unexported fields
}
Config is the configuration for the application.
func NewConfig ¶
func NewConfig() *Config
NewConfig creates a new configuration for the application.
func (*Config) IsConfigValid ¶
IsConfigValid checks if the configuration is valid.
func (*Config) LoadConfigFromEnvVar ¶
func (c *Config) LoadConfigFromEnvVar()
LoadConfigFromEnvVar loads the configuration from the environment variables.
func (*Config) LoadConfigFromFile ¶
LoadConfigFromFile loads the configuration from a file.
func (*Config) LoadConfiguration ¶
LoadConfiguration loads the configuration from the environment variables first. If the configuration is not valid, it tries to load the configuration from a file.
func (*Config) SaveConfiguration ¶
SaveConfiguration saves the configuration to a file If the parameter is empty, it saves the configuration to the default file.
func (*Config) SetHomedir ¶
SetHomedir sets the homedir variable It is used for testing purposes.