hq

package
v2.14.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 14 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ExpectedMinAzureCliVersion  = "2.46.0"
	ExpectedMinTerraformVersion = "1.4.0"
	ExpectedMinHelmVersion      = "3.11.3"
	ExpectedMinKubectlVersion   = "1.25.7"
	ExpectedMinKubeloginVersion = "0.0.28"
	ExpectedMinCopsctlVersion   = "0.10.0"
	ExpectedMinSopsVersion      = "3.7.3"
)

Variables

View Source
var ProjectBasePath = filepath.Join(".", "../", "../")

ProjectBasePath simply points to root of the Go project, which should always be two levels above the currently executed directory (which per convention, should always be cmd/project_name

Functions

This section is empty.

Types

type HQ

type HQ interface {
	// Run starts the HQ CLI parsing functionality
	Run() error

	// GetExecutor retrieves the currently configured executor
	GetExecutor() commands.Executor

	// GetCli retrieves the current cli instance
	GetCli() cli.Cli

	// GetLogrusLogger retrieves the currently initialized logrus logger
	GetLogrusLogger() *logrus.Logger

	// LoadEnvironmentConfigFile is a special version of LoadConfigFile in which the config file is expected in
	// the location 'config/<<environment_tag>>.yaml'. This command relies on the defined variable
	// 'environment-tag', available through Viper. Most common way to provide the 'environment-tag' is through cli
	// parameters, which are automatically bound to Viper.
	LoadEnvironmentConfigFile() error

	// LoadConfigFile loads the specified config file, which is expected to be saved encrypted (with sops) on disk.
	// You can generate the path using filepath.Join and the hq.ProjectBasePath variable. Sops is expected to be
	// available in PATH, and in correct version (use the CheckToolingDependencies method or call hq 'check-dependencies')
	LoadConfigFile(filePath string) error

	// GetRawConfigurationFile returns the currently loaded configuration decrypted as string. Loading configuration is
	// a procondition due to get raw configuration string
	GetRawConfigurationFile() (string, error)

	// CheckToolingDependencies can be called to check if installed tooling (Azure CLI, Terraform, Helm etc.) is of minimal
	// expected version for all of HQ functionality to work. It is highly recommended to call this method in your code, and fail
	// in case of errors.
	CheckToolingDependencies() error
}

HQ is an easy one-stop setup for typical IaC projects. Don't forget to call the Run() method after you complete setting up (e.g. all CLI commands added to HQ.Cli). Consider this object similar to an IoC container, which can be used to retrieve main dependencies for other objects, such as the command executor or the CLI.

func New

func New(programName string, version string, logFileName string) HQ

New creates a new HQ instance, configuring internally used modules for usage. Keep the created HQ instance and avoid re-instantiation since some setup steps might have global impacts (like logging setup). It will create a chatty executor, piping all commands and outputs to both the console and the file (e.g. like in shell scripts)

func NewCustom

func NewCustom(programName string, version string, options *HqOptions) HQ

NewCustom creates a new HQ instance, configuring internally used modules for usage. Keep the created HQ instance and avoid re-instantiation since some setup steps might have global impacts (like logging setup). Custom HQ lets you override most of the behaviours and HQ setup options

func NewQuiet

func NewQuiet(programName string, version string, logFileName string) HQ

NewQuiet creates a new HQ instance, configuring internally used modules for usage. Keep the created HQ instance and avoid re-instantiation since some setup steps might have global impacts (like logging setup). Quiet HQ will create a quiet executor, piping all commands and outputs to the log file, but the console will be kept clean. If needed, like in CI, a viper flag "verbose" can be used to override this behavior.

type HqOptions

type HqOptions struct {
	// Quiet HQ will create a quiet executor, piping all commands and outputs to the log file, but the console will be
	// kept clean. If needed, like in CI, a viper flag "verbose" can be used to override this behavior.
	Quiet bool

	// Filename for the log file, if enabled
	LogFileName string

	// Default logging to file can be disabled with this flag
	DisableFileLogging bool
}

func (*HqOptions) Validate

func (options *HqOptions) Validate() error

Jump to

Keyboard shortcuts

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