config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	LegacyInstancesField = "instances"
)

Variables

View Source
var LegacyYAML = errors.New("file format belongs to the old integrations format")

LegacyYAML is not an actual error. Used for discarding V3 plugins

Functions

func MigrateV3toV4

func MigrateV3toV4(pathConfiguration string, pathDefinition string, pathOutput string, overwrite bool) error

Types

type ConfigEntry

type ConfigEntry struct {
	InstanceName string            `yaml:"name" json:"name"`         // integration instance name
	CLIArgs      []string          `yaml:"cli_args" json:"cli_args"` // optional when executable is deduced by "name" instead of "exec"
	Exec         ShlexOpt          `yaml:"exec" json:"exec"`         // it may be a CLI string or a YAML array
	Env          map[string]string `yaml:"env" json:"env"`           // User-defined environment variables
	Interval     string            `yaml:"interval" json:"interval"` // User-defined interval string (duration notation)
	Timeout      *time.Duration    `yaml:"timeout" json:"timeout"`
	User         string            `yaml:"integration_user" json:"integration_user"`
	WorkDir      string            `yaml:"working_dir" json:"working_dir"`
	Labels       map[string]string `yaml:"labels" json:"labels"`
	Tags         map[string]string `yaml:"tags" json:"tags"`
	When         EnableConditions  `yaml:"when" json:"when"`

	// Legacy definition commands
	Command         string            `yaml:"command" json:"command"`
	Arguments       map[string]string `yaml:"arguments" json:"arguments"`
	IntegrationName string            `yaml:"integration_name" json:"integration_name"`
	InventorySource string            `yaml:"inventory_source" json:"inventory_source"`

	// Config embeds a configuration file as a string. It can't coexist with TemplatePath
	Config interface{} `yaml:"config" json:"config"`
	// TemplatePath specifies the path of an external configuration file. It can't coexist with Config
	TemplatePath  string `yaml:"config_template_path" json:"config_template_path"`
	LogsQueueSize int    `yaml:"logs_queue_size" json:"logs_queue_size"`
}

ConfigEntry holds an integrations YAML configuration entry. It may define multiple types of tasks

func (*ConfigEntry) Sanitize

func (cf *ConfigEntry) Sanitize() error

checks that the format is correct and fixes possible nil leaks with default values

func (*ConfigEntry) UppercaseEnvVars

func (cf *ConfigEntry) UppercaseEnvVars()

UppercaseEnvVars transforms all lowercase env vars defined in the config to uppercase

type EnableConditions

type EnableConditions struct {
	// Feature allows enabling/disabling the OHI via agent cfg "feature" or cmd-channel Feature Flag
	Feature string `yaml:"feature"`
	// FileExists conditions the execution of the OHI only if the given file path exists
	FileExists string `yaml:"file_exists"`
	// EnvExists conditions the execution of the OHI only if the given
	// environment variables exists and match the value.
	EnvExists map[string]string `yaml:"env_exists"`
}

EnableConditions condition the execution of an integration to the trueness of ALL the conditions

type Loader

type Loader interface {
	// Load reads all the configuration files in a given directory. If path is a file instead of a directory
	// will try to read it as a single configuration file.
	Load(path string) (YAMLMap, error)

	// LoadFile reads the configuration file.
	LoadFile(file string) (YAML, error)
}

Loader will read and parse integrations v4 config files.

func NewPathLoader

func NewPathLoader() Loader

NewPathLoader returns a new instance of a config Loader.

type ShlexOpt

type ShlexOpt []string

ShlexOpt is a wrapper around []string so we can use go-shlex for shell tokenizing

func (*ShlexOpt) Set

func (s *ShlexOpt) Set(value string) error

Set the value

func (*ShlexOpt) String

func (s *ShlexOpt) String() string

func (*ShlexOpt) Type

func (s *ShlexOpt) Type() string

Type returns the type of the value

func (*ShlexOpt) UnmarshalYAML

func (s *ShlexOpt) UnmarshalYAML(unmarshal func(interface{}) error) error

func (*ShlexOpt) Value

func (s *ShlexOpt) Value() []string

Value returns the value as a string slice

type V3toV4Result

type V3toV4Result struct {
	V3toV4Result string `json:"migrateV3toV4Result"`
}

V3toV4Result represents the result of a migration

type YAML

type YAML struct {
	Databind     databind.YAMLConfig `yaml:",inline"`
	Integrations []ConfigEntry       `yaml:"integrations"`
}

YAML stores the information from a single V4 integrations file

type YAMLMap

type YAMLMap map[string]YAML

YAMLMap maps YAML config with the path of the config file as key.

Jump to

Keyboard shortcuts

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