config

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasDefaultConfigFile added in v0.6.0

func HasDefaultConfigFile() bool

HasDefaultConfigFile returns true if the default configuration file exists.

Types

type Config

type Config struct {
	ActiveDeployment string                `toml:"active_deployment" envconfig:"deployment"`
	Deployments      map[string]Deployment `toml:"deployments"`
	Insecure         bool                  `toml:"-" envconfig:"insecure"`

	URLOverride            string `toml:"-" envconfig:"url"`
	TokenOverride          string `toml:"-" envconfig:"token"`
	OrganizationIDOverride string `toml:"-" envconfig:"org_id"`

	ConfigFilePath string `toml:"-"`
	// contains filtered or unexported fields
}

Config is the global Axiom CLI configuration.

func Load

func Load(configFilePath string) (*Config, error)

Load the configuration. It behaves like LoadFromReader() but opens a file for reading the TOML configuration.

func LoadDefault

func LoadDefault() (*Config, error)

LoadDefault tries to load the default configuration. It behaves like Load() but doesn't fail if the configuration file doesn't exist.

func LoadFromReader

func LoadFromReader(r io.Reader) (config *Config, err error)

LoadFromReader loads configuration from an io.Reader. Configuration values loaded from the environment overwrite the ones from the TOML configuration. On error, the default configuration or the configuration processed till the error occurred is returned.

func (*Config) DeploymentAliases

func (c *Config) DeploymentAliases() []string

DeploymentAliases returns a sorted slice of deployment aliases.

func (*Config) Get

func (c *Config) Get(key string) (string, error)

Get the string value for the given key.

func (*Config) GetActiveDeployment

func (c *Config) GetActiveDeployment() (Deployment, bool)

GetActiveDeployment returns the configured deployment with overrides applied, if given.

func (*Config) IsEmpty added in v0.6.1

func (c *Config) IsEmpty() bool

IsEmpty returns true if the configuration does not contain any non-zero values for its user configurable fields.

func (*Config) Keys

func (c *Config) Keys() []string

Keys which are valid arguments to Get() and Set().

func (*Config) Set

func (c *Config) Set(key, value string) error

Set the string value at the given key. Existing values are overwritten. The key must exist in the configuration.

func (*Config) Write

func (c *Config) Write() error

Write the configuration to its configuration file on disk. If it doesn't exist, it is created.

type Deployment

type Deployment struct {
	URL            string `toml:"url"`
	Token          string `toml:"token"`
	OrganizationID string `toml:"org_id"`
}

Deployment is the configuration for an Axiom instance.

Jump to

Keyboard shortcuts

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