args

package
v3.8.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 9 Imported by: 52

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupArgs

func SetupArgs(args interface{}) error

SetupArgs parses a struct's definition and populates the arguments from the fields it defines. Each of the fields in the struct can define their defaults and help string by using tags:

type Arguments struct {
   	DefaultArgumentList
   	Argument1 bool   `default:"false" help:"This is the help we will print"`
   	Argument2 int    `default:"1" help:"This is the help we will print"`
   	Argument3 string `default:"value" help:"This is the help we will print"`
}

The fields in the struct will be populated with the values set either from the command line or from environment variables.

Types

type DefaultArgumentList

type DefaultArgumentList struct {
	Verbose        bool   `default:"false" help:"Print more information to logs."`
	Pretty         bool   `default:"false" help:"Print pretty formatted JSON."`
	Metrics        bool   `default:"false" help:"Publish metrics data."`
	Inventory      bool   `default:"false" help:"Publish inventory data."`
	Events         bool   `default:"false" help:"Publish events data."`
	Metadata       bool   `default:"false" help:"Add customer defined key-value attributes to the samples."`
	NriAddHostname bool   `default:"false" help:"Add hostname attribute to the samples."`
	NriCluster     string `default:"" help:"Optional. Cluster name"`
	NriService     string `default:"" help:"Optional. Service name"`
	TempDir        string `default:"" help:"Optional. Integrations path to store temporal data (defaults to os.tempDir if left empty)."`
}

DefaultArgumentList includes the minimal set of necessary arguments for an integration. If all data flags (Inventory, Metrics and Events) are false, all of them are published.

func GetDefaultArgs

func GetDefaultArgs(arguments interface{}) *DefaultArgumentList

GetDefaultArgs checks if the arguments interface contains a 'DefaultArgumentList' field. If there is no 'DefaultArgumentList' field, it returns a DefaultArgumentList with default values.

func (*DefaultArgumentList) All

func (d *DefaultArgumentList) All() bool

All returns if all data should be published

func (*DefaultArgumentList) HasEvents

func (d *DefaultArgumentList) HasEvents() bool

HasEvents returns if events should be published

func (*DefaultArgumentList) HasInventory

func (d *DefaultArgumentList) HasInventory() bool

HasInventory returns if inventory should be published

func (*DefaultArgumentList) HasMetrics

func (d *DefaultArgumentList) HasMetrics() bool

HasMetrics returns if metrics should be published

type HTTPClientArgumentList

type HTTPClientArgumentList struct {
	HTTPCaBundleFile string        `default: "" help: "Name of the certificate file"`
	HTTPCaBundleDir  string        `default: "" help: "Path where the certificate exists"`
	HTTPTimeout      time.Duration `default:30 help: "Client http timeout in seconds"`
}

HTTPClientArgumentList are meant to be used as flags from a custom integrations. With this you could send this arguments from the command line.

type JSON

type JSON struct {
	// contains filtered or unexported fields
}

JSON type, to be used from the arguments structs. This argument type will parse a serialized JSON string into a map

func NewJSON

func NewJSON(value interface{}) *JSON

NewJSON returns a new JSON holder containing the given value

func (*JSON) Get

func (i *JSON) Get() interface{}

Get returns the hold value

func (*JSON) Set

func (i *JSON) Set(s string) error

Set unmarshals the given string into the JSON holder

func (*JSON) String

func (i *JSON) String() string

String converts to string

Jump to

Keyboard shortcuts

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