config

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigFlagName  = "config"
	LevelFlagName   = "level"
	AppName         = "ddctl"
	ConfigDir       = "." + AppName
	BaseURLFlagName = "base-url"
)

Variables

This section is empty.

Functions

func DefaultConfigFile

func DefaultConfigFile() string

func InitViper

func InitViper(cmd *cobra.Command) error

InitViper function is responsible for reading the configuration file and environment variables, if they are set. The results are stored in viper. To retrieve a configuration, use the GetConfig function. The function accepts a cmd parameter which allows binding to command flags.

func InitViperInstance

func InitViperInstance(v *viper.Viper, cmd *cobra.Command) error

InitViperInstance function is responsible for reading the configuration file and environment variables, if they are set. The results are stored in viper. To retrieve a configuration, use the GetConfig function. The function accepts a cmd parameter which allows binding to command flags.

Types

type Config

type Config struct {
	APIVersion string `json:"apiVersion" yaml:"apiVersion" yamltags:"required"`
	Kind       string `json:"kind" yaml:"kind" yamltags:"required"`

	Logging Logging `json:"logging" yaml:"logging"`

	// BaseURL is the base URL in the Honeycomb UI for your environment.
	// This is used to construct URLs to Honeycomb queries.
	BaseURL string `json:"baseURL" yaml:"baseURL"`
	// contains filtered or unexported fields
}

Config represents the persistent configuration data.

Currently, the format of the data on disk and in memory is identical. In the future, we may modify this to simplify changes to the disk format and to store in-memory values that should not be written to disk. Could that be achieved by embedding it in a different struct which contains values that shouldn't be serialized?

func GetConfig

func GetConfig() *Config

GetConfig returns a configuration created from the viper configuration.

func UpdateViperConfig

func UpdateViperConfig(v *viper.Viper, expression string) (*Config, error)

UpdateViperConfig update the viper configuration with the given expression. expression should be a value such as "agent.model=gpt-4o-mini" The input is a viper configuration because we leverage viper to handle setting most keys. However, in some special cases we use custom functions. This is why we return a Config object.

func (*Config) DeepCopy

func (c *Config) DeepCopy() Config

DeepCopy returns a deep copy.

func (*Config) GetBaseURL

func (c *Config) GetBaseURL() string

func (*Config) GetConfigDir

func (c *Config) GetConfigDir() string

GetConfigDir returns the configuration directory

func (*Config) GetConfigFile

func (c *Config) GetConfigFile() string

GetConfigFile returns the configuration file

func (*Config) GetLogLevel

func (c *Config) GetLogLevel() string

func (*Config) IsValid

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

IsValid validates the configuration and returns any errors.

func (*Config) Write

func (c *Config) Write(cfgFile string) error

Write saves the configuration to a file.

type LogSink

type LogSink struct {
	// Set to true to write logs in JSON format
	JSON bool `json:"json,omitempty" yaml:"json,omitempty"`
	// Path is the path to write logs to. Use "stderr" to write to stderr.
	// Use gcplogs:///projects/${PROJECT}/logs/${LOGNAME} to write to Google Cloud Logging
	Path string `json:"path,omitempty" yaml:"path,omitempty"`
}

type Logging

type Logging struct {
	Level string `json:"level,omitempty" yaml:"level,omitempty"`
	// Use JSON logging
	JSON bool `json:"json,omitempty" yaml:"json,omitempty"`
}

Jump to

Keyboard shortcuts

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