config

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Overview

Package config provides configuration management for Privateer plugins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ServiceName    string // Must be unique in the config file or logs will be overwritten
	LogLevel       string
	Logger         hclog.Logger
	Write          bool
	Output         string
	WriteDirectory string
	Invasive       bool
	Policy         Policy
	Vars           map[string]interface{}
	Error          error
}

Config holds the configuration for a plugin execution.

func NewConfig

func NewConfig(requiredVars []string) Config

NewConfig creates a new Config instance from viper configuration.

func (*Config) GetBool

func (c *Config) GetBool(key string) bool

GetBool retrieves the value associated with the given key as a boolean. If the value is not of type boolean, it returns false.

Parameters:

  • key: The key name in the config vars.

Returns:

  • bool: The boolean value associated with the key, or false if the value is not a boolean.

func (*Config) GetBoolSlice

func (c *Config) GetBoolSlice(key string) []bool

GetBoolSlice retrieves a slice of boolean values from the configuration based on the provided key. If the key does not exist or the value is not of type []bool, it returns nil.

Parameters:

  • key: The key name in the config vars.

Returns:

  • []bool: A slice of boolean values if the key exists and the value is of type []bool.
  • nil: If the key does not exist or the value is not of type []bool.

func (*Config) GetInt

func (c *Config) GetInt(key string) int

GetInt retrieves the value associated with the given key as an integer. If the value is not of type int, it returns 0.

Parameters:

  • key: The key name in the config vars.

Returns:

  • int: The value associated with the key, or 0 if the value is not of type int.

func (*Config) GetIntSlice

func (c *Config) GetIntSlice(key string) []int

GetIntSlice retrieves the value associated with the given key as a slice of integers. If the value is not of type []int, it returns nil.

Parameters:

  • key: The key name in the config vars.

Returns:

  • []int: The value associated with the key as a slice of integers
  • nil: If the value is not of type []int or the key does not exist.

func (*Config) GetMap

func (c *Config) GetMap(key string) map[string]interface{}

GetMap retrieves a value from the configuration as a map[string]interface{}. It takes a key as a string and returns the corresponding value if it is of type map[string]interface{}. If the value is not of the expected type, it returns nil.

Parameters:

  • key: The key name in the config vars.

Returns:

  • map[string]interface{}: The value associated with the key if it is of the correct type
  • nil: If the value is not of type map[string]interface{} or the key does not exist.

func (*Config) GetString

func (c *Config) GetString(key string) string

GetString retrieves the value associated with the given key from the Config object. If the value is not of type string, it returns an empty string.

Parameters:

  • key: The key name in the config vars.

Returns:

  • string: The value associated with the key, or an empty string if the value is not of type string.

func (*Config) GetStringSlice

func (c *Config) GetStringSlice(key string) []string

GetStringSlice retrieves the value associated with the given key as a slice of strings. If the value is not of type []string, it returns nil.

Parameters:

  • key: The key name in the config vars.

Returns:

  • []string: The value associated with the key as a slice of strings
  • nil: If the value is not of type []string or the key does not exist.

func (*Config) GetVar

func (c *Config) GetVar(key string) (interface{}, string)

GetVar retrieves the value associated with the given key from the Config's Vars map. It returns the value as an interface{} and a string representing the type of the value. Useful for debugging in the event that a value is not being retrieved as expected.

Parameters:

  • key: The key name in the config vars.

Returns:

  • interface{}: The value associated with the key.
  • string: The type of the value associated with the key. If the key does not exist, it returns "missing".

func (*Config) SetupLogging

func (c *Config) SetupLogging(name string, jsonFormat bool)

SetupLogging configures logging for the plugin with the given name and format.

type Policy added in v1.0.0

type Policy struct {
	ControlCatalogs []string
	Applicability   []string
}

Policy defines the control catalogs and applicability settings for a plugin. TODO: We will want to replace this with a Gemara layer3 object now that those are ready.

Jump to

Keyboard shortcuts

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