config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: MIT Imports: 5 Imported by: 0

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

View Source
const (
	// ConfigurationDirPerm is the permission (0700) for the configuration directory.
	ConfigurationDirPerm = 0700
	// ConfigurationFilePerm is the permission (0600) for configuration files.
	ConfigurationFilePerm = 0600
)

Variables

View Source
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

func (c *Config) IsConfigValid() bool

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

func (c *Config) LoadConfigFromFile(filename string) error

LoadConfigFromFile loads the configuration from a file.

func (*Config) LoadConfiguration

func (c *Config) LoadConfiguration(cfgFilePath string) error

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

func (c *Config) SaveConfiguration(cfgFilePath string) error

SaveConfiguration saves the configuration to a file If the parameter is empty, it saves the configuration to the default file.

func (*Config) SetHomedir

func (c *Config) SetHomedir(homedir string)

SetHomedir sets the homedir variable It is used for testing purposes.

Jump to

Keyboard shortcuts

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