config

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricsNamespace = "jenkins_autoscaler"
)

Variables

View Source
var (

	// Options global configuration
	Options = fs.Options{
		{
			Name:     "dry_run",
			Help:     "whether to enable dry run",
			Default:  false,
			NoPrefix: true,
		},
		{
			Name:     "log_level",
			Help:     "minimum log level",
			Default:  "error",
			NoPrefix: true,
		},
		{
			Name:     "run_interval",
			Help:     "interval of the main scaler loop",
			Default:  "1m",
			NoPrefix: true,
		},
		{
			Name:     "gc_run_interval",
			Help:     "interval of the gc loop",
			Default:  "1h",
			NoPrefix: true,
		},
		{
			Name:     "jenkins_url",
			Help:     "jenkins server base url",
			NoPrefix: true,
			Required: true,
		},
		{
			Name:     "jenkins_user",
			Help:     "jenkins username",
			NoPrefix: true,
			Required: true,
		},
		{
			Name:       "jenkins_token",
			Help:       "jenkins api token",
			IsPassword: true,
			NoPrefix:   true,
			Required:   true,
		},
		{
			Name:     "nodes_with_label",
			Help:     "target only nodes with the specified label",
			NoPrefix: true,
		},
		{
			Name:     "metrics_server_addr",
			Help:     "address of http metrics server",
			Default:  ":8080",
			NoPrefix: true,
		},
		{
			Name:     "controller_node_name",
			Help:     "built-in Jenkins node (aka master)",
			Default:  "Built-In Node",
			NoPrefix: true,
		},
		{
			Name:     "max_nodes",
			Help:     "maximum number of nodes at any given time",
			Default:  1,
			NoPrefix: true,
		},
		{
			Name:     "node_num_executors",
			Help:     "number of executors per node",
			Default:  1,
			NoPrefix: true,
		},
		{
			Name:     "min_nodes_during_working_hours",
			Help:     "the minimum nodes to keep while inside working hours",
			Default:  2,
			NoPrefix: true,
		},
		{
			Name:     "scale_up_threshold",
			Help:     "usage percentage above which a scale up will occur",
			Default:  70,
			NoPrefix: true,
		},
		{
			Name:     "scale_down_threshold",
			Help:     "usage percentage above which a scale down will occur",
			Default:  30,
			NoPrefix: true,
		},
		{
			Name:     "scale_up_grace_period",
			Help:     "how much time to wait before another scale up can be performed",
			Default:  "5m",
			NoPrefix: true,
		},
		{
			Name:     "scale_down_grace_period",
			Help:     "how much time to wait before another scale down can be performed",
			Default:  "10m",
			NoPrefix: true,
		},
		{
			Name:     "scale_down_grace_period_during_working_hours",
			Help:     "scale down cooldown timer in minutes during working hours",
			Default:  "10m",
			NoPrefix: true,
		},
		{
			Name:     "working_hours_cron_expressions",
			Help:     "working hours range, specified as cron expression",
			Default:  "* 5-17 * * 1-5",
			NoPrefix: true,
		},
		{
			Name:     "disable_working_hours",
			Help:     "ignore working hours when scaling down",
			NoPrefix: true,
		},
	}
)

Functions

func FileGet

func FileGet(section, key string) (string, bool)

FileGet gets the config key under section returning the the value and true if found and or ("", false) otherwise

func GetConfigPath

func GetConfigPath() string

GetConfigPath get the config file path

func OptionToEnv

func OptionToEnv(name string) string

OptionToEnv converts an option name, e.g. "foo-poo" into an environment name "JAS_FOO_POO"

func ReadOptions

func ReadOptions(src configmap.Mapper, dst ReadOptionsDst) error

ReadOptions read options from getters and validate if need and set it to options struct

func SectionOptionToEnv

func SectionOptionToEnv(section, name string) string

SectionOptionToEnv converts a config section and name, e.g. ("my-section","foo-poo") into an environment name "JAS_CONFIG_MY_SECTION_FOO_POO"

func SetConfigPath

func SetConfigPath(path string) (err error)

SetConfigPath sets new config file path

Checks for empty string, os null device, or special path, all of which indicates in-memory config.

func SetDefaultFromEnv

func SetDefaultFromEnv(flags *pflag.FlagSet, name string)

SetDefaultFromEnv constructs a name from the flag passed in and sets the default from the environment if possible

Types

type ReadOptionsDst

type ReadOptionsDst interface {
	Name() string
}

Jump to

Keyboard shortcuts

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