Documentation
¶
Overview ¶
Package config holds configuration structures and loading logic.
Index ¶
Constants ¶
const ( // DefaultConfigName is the default name of the config file DefaultConfigName = ".cdnscli" // DefaultConfigType is the default config file type DefaultConfigType = "yaml" // DefaultClientTimeout is the default client timeout DefaultClientTimeout = 10 * time.Second // DefaultOutputFormat is the default output format DefaultOutputFormat = "text" )
Variables ¶
This section is empty.
Functions ¶
func GetConfigPath ¶
GetConfigPath returns the path to the config file that would be used.
Types ¶
type CloudflareCredentials ¶
type CloudflareCredentials struct {
// APIToken is the Cloudflare API token
APIToken string `mapstructure:"api_token" yaml:"api_token"`
// APIKey is the Cloudflare API key (alternative to token)
APIKey string `mapstructure:"api_key" yaml:"api_key"`
// Email is the Cloudflare account email (required with APIKey)
Email string `mapstructure:"email" yaml:"email"`
}
CloudflareCredentials holds Cloudflare-specific credentials.
type Config ¶
type Config struct {
// DefaultProvider is the name of the default provider to use
DefaultProvider string `mapstructure:"default_provider" yaml:"default-provider,omitempty"`
// Providers contains configuration for all DNS providers
Providers map[string]ProviderConfig `mapstructure:"providers" yaml:"providers"`
// ClientTimeout is the default timeout for API requests
ClientTimeout time.Duration `mapstructure:"client_timeout" yaml:"client-timeout,omitempty"`
// OutputFormat is the default output format
OutputFormat string `mapstructure:"output_format" yaml:"output-format,omitempty"`
// Debug enables debug output
Debug bool `mapstructure:"debug" yaml:"debug"`
}
Config represents the main configuration structure.
func Load ¶
Load loads configuration from file, environment variables, and command line flags. Priority order: flags > env > config file > defaults
func (*Config) GetClientTimeout ¶
GetClientTimeout returns the client timeout, ensuring it's at least 1 second.
func (*Config) GetProvider ¶
func (c *Config) GetProvider(name string) (*ProviderConfig, error)
GetProvider returns the provider configuration by name. Returns an error if the provider is not found.
type ProviderConfig ¶
type ProviderConfig struct {
// Type is the provider type (e.g., "cloudflare", "route53", "digitalocean")
Type string `mapstructure:"type" yaml:"type"`
// DisplayName is the custom display name for the provider (e.g., "Cloudflare", "Рога и Копыта")
// If not set, a default display name will be used based on the provider type.
DisplayName string `mapstructure:"display_name" yaml:"display-name,omitempty"`
// Credentials holds provider-specific credentials
Credentials map[string]interface{} `mapstructure:"credentials" yaml:"credentials"`
// Options holds provider-specific options
Options map[string]interface{} `mapstructure:"options" yaml:"options"`
}
ProviderConfig holds configuration for a specific DNS provider.
func (*ProviderConfig) GetCloudflareCredentials ¶
func (pc *ProviderConfig) GetCloudflareCredentials() (*CloudflareCredentials, error)
GetCloudflareCredentials extracts Cloudflare credentials from provider config.
func (*ProviderConfig) GetRegRuCredentials ¶ added in v0.99.4
func (pc *ProviderConfig) GetRegRuCredentials() (*RegRuCredentials, error)
GetRegRuCredentials extracts RegRu credentials from provider config.
func (*ProviderConfig) Validate ¶
func (pc *ProviderConfig) Validate(name string) error
Validate validates a provider configuration.
type RegRuCredentials ¶ added in v0.99.4
type RegRuCredentials struct {
// Username is the RegRu account username
Username string `mapstructure:"username" yaml:"username"`
// Password is the RegRu account password
Password string `mapstructure:"password" yaml:"password"`
}
RegRuCredentials holds RegRu-specific credentials.
type ValidationError ¶
ValidationError represents a configuration validation error.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string