config

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigFlagName     = "config"
	LevelFlagName      = "level"
	AppName            = "hydros"
	ConfigDir          = "." + AppName
	WorkDirFlagName    = "work-dir"
	AppIDFlagName      = "appId"
	PrivateKeyFlagName = "private-key"
)

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.

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,omitempty" yaml:"logging,omitempty"`
	GitHub  *GitHubConfig `json:"gitHub,omitempty" yaml:"gitHub,omitempty"`
	// WorkDir is the working directory for hydros where repositories should be checked out
	WorkDir string `json:"workDir,omitempty" yaml:"workDir,omitempty"`
}

Config represents the persistent configuration data for foyle.

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.

func GetConfig

func GetConfig() *Config

GetConfig returns a configuration created from the viper configuration.

func (*Config) GetConfigDir

func (c *Config) GetConfigDir() string

GetConfigDir returns the configuration directory

func (*Config) GetLogLevel

func (c *Config) GetLogLevel() string

func (*Config) GetWorkDir

func (c *Config) GetWorkDir() 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 GitHubConfig

type GitHubConfig struct {
	// AppID is the ID of the GitHub App
	AppID int64 `json:"appID,omitempty" yaml:"appID,omitempty"`
	// PrivateKey is the private key for the GitHub App
	PrivateKey string `json:"privateKey,omitempty" yaml:"privateKey,omitempty"`
}

type Logging

type Logging struct {
	Level string `json:"level,omitempty" yaml:"level,omitempty"`
}

Jump to

Keyboard shortcuts

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