config

package
v0.0.0-...-ebfd914 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AccessKeyEnvVar is the name of the environment variable where the access
	// key to the Infralight App Server must be provided
	AccessKeyEnvVar = "INFRALIGHT_ACCESS_KEY"

	// SecretKeyEnvVar is the name of the environment variable where the secret
	// key to the Infralight App Server must be provided
	SecretKeyEnvVar = "INFRALIGHT_SECRET_KEY" // nolint: gosec

	// DefaultConfigDir is the path to the default directory where configuration
	// files (generally mounted from a Kubernetes ConfigMap) must be present.
	DefaultConfigDir = "/etc/config"

	// DefaultFireflyAPI is the default URL for Firefly's API
	DefaultFireflyAPI = "https://k8s-api.prod.external.api.infralight.cloud"

	// DefaultFireflyLoginAPI is the default URL for Firefly's Login API
	DefaultFireflyLoginAPI = "https://prod.external.api.infralight.cloud"
)

Variables

View Source
var (
	// ErrAccessKeys is an error returned when the environment variables for the
	// access and secret keys are not provided or empty.
	ErrAccessKeys = errors.New("access and secret keys must be provided")

	// ErrEndpoint is an error returned when the configuration directory is
	// missing an endpoint setting (endpoint is the URL to the Infralight App
	// Server).
	ErrEndpoint = errors.New("Infralight endpoint must be provided")

	// DefaultResourceTypes is the list of Kubernetes resources that are
	// to be collected by default (i.e. if there is no configuration at all)
	DefaultResourceTypes = []string{
		"apiservices",
		"analysistemplates",
		"clusteranalysistemplates",
		"clusterroles",
		"clusterrolebindings",
		"configmaps",
		"controllerrevisions",
		"csinodes",
		"cronjobs",
		"customresourcedefinitions",
		"daemonsets",
		"deployments",
		"endpoints",
		"endpointslices",
		"flowschemas",
		"ingresses",
		"jobs",
		"leases",
		"namespaces",
		"networkpolicies",
		"nodes",
		"persistentvolumeclaims",
		"persistentvolumes",
		"pods",
		"priorityclasses",
		"prioritylevelconfigurations",
		"replicasets",
		"replicationcontrollers",
		"roles",
		"rolebindings",
		"rollouts",
		"rollouts/finalizers",
		"rollouts/status",
		"serviceaccounts",
		"services",
		"services/status",
		"statefulsets",
		"storageclasses",
	}
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// File system object from which configuration files are read. by default,
	// this is the local file system; an in-memory file system is used in the
	// unit tests
	FS fs.FS

	// The directory inside fs where configuration files are stored. by default,
	// this is /etc/config
	ConfigDir string

	// DryRun indicates whether the collector should only perform local read
	// operations. When true, authentication against the Firefly API is not
	// made, as is sending of collected data. Data is printed to standard output
	// instead
	DryRun bool

	// The logger instance
	Log *zerolog.Logger

	// AccessKey is the Infralight access key
	AccessKey string

	// SecretKey is the Infralight secret key
	SecretKey string

	// Endpoint is the URL to the Infralight App Server
	Endpoint string

	// LoginEndpoint is the URL to login Infralight Service
	LoginEndpoint string

	// Namespace is the Kubernets namespace we're collecting data from (if empty,
	// all namespaces are collected)
	Namespace string

	// IgnoreNamespaces is a list of namespaces to ignore (only taken into
	// account when Namespace is empty)
	IgnoreNamespaces []string

	// AllowedResources is a list of resource types (named by their "Kind" value)
	// that the collector is allowed to collect
	AllowedResources map[string]bool

	// OverrideUniqueClusterId is a boolean indicating whether to override the master url of the Kubernetes integration
	OverrideUniqueClusterId bool

	// PageSize is an integer for max page size in KB
	PageSize int

	// MaxGoRoutines is an integer for max goroutines running at ones sending the chunks.
	MaxGoRoutines int
}

Config represents configuration to the collector library. It is shared between the different data collectors (impementing the collector.DataCollector interface).

func LoadConfig

func LoadConfig(
	log *zerolog.Logger,
	cfs fs.FS,
	configDir string,
	dryRun bool,
) (conf *Config, err error)

LoadConfig creates a new configuration object. A logger object, a file-system object (where configuration files are stored), and a path to the configuration directory may be provided. All parameters are optional. If not provided, a noop logger is used, the local file system is used, and DefaultConfigDir is used.

func (*Config) IgnoreNamespace

func (conf *Config) IgnoreNamespace(ns string) bool

IgnoreNamespace accepts a namespace and returns a boolean value indicating whether the namespace should be ignored

Jump to

Keyboard shortcuts

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