common

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ADPrefix prefix used for AD annotations
	ADPrefix = "ad.datadoghq.com/"
	// ADPrefixRegex used for matching AD annotations
	ADPrefixRegex = "ad\\.datadoghq\\.com/"
	// AgentLabelValue label value to define the Agent
	AgentLabelValue = "agent"
	// ComponentLabelKey label key used to define the datadog agent component
	ComponentLabelKey = "agent.datadoghq.com/component"
	// ClcRunnerLabelValue label value to define the Cluster Checks Runner
	ClcRunnerLabelValue = "cluster-checks-runner"
)

Variables

View Source
var (
	// AgentLabel can be used as a LabelSelector for the Agent
	AgentLabel = fmt.Sprintf("%s=%s", ComponentLabelKey, AgentLabelValue)
	// ClcRunnerLabel can be used as a LabelSelector for the Cluster Checks Runner
	ClcRunnerLabel = fmt.Sprintf("%s=%s", ComponentLabelKey, ClcRunnerLabelValue)
)

Functions

func AskForConfirmation

func AskForConfirmation(input string) bool

AskForConfirmation asks for the user's confirmation before taking an action

func AskForInput

func AskForInput(question string) (string, error)

AskForInput asks the user for a given information

func GetDurationAsString

func GetDurationAsString(obj metav1.Object) string

GetDurationAsString gets object's age

func HasImagePattern

func HasImagePattern(image string) bool

HasImagePattern returns true if the image string respects the format <string>/<string>:<string>

func IntToString

func IntToString(i int32) string

IntToString converts int32 to string

func IsAnnotated

func IsAnnotated(annotations map[string]string, prefix string) bool

IsAnnotated returns true if annotations contain a key with a given prefix

func NewClient

func NewClient(clientConfig clientcmd.ClientConfig) (client.Client, error)

NewClient returns a new controller-runtime client instance

func NewClientset

func NewClientset(clientConfig clientcmd.ClientConfig) (*kubernetes.Clientset, error)

NewClientset returns a new client-go instance

func OverrideComponentImage added in v1.0.0

func OverrideComponentImage(spec *v2alpha1.DatadogAgentSpec, cmpName v2alpha1.ComponentName, imageName, imageTag string) error

func SplitImageString added in v1.0.0

func SplitImageString(in string) (name string, tag string)

func StreamToBytes

func StreamToBytes(stream io.Reader) ([]byte, error)

StreamToBytes converts a stream to bytes

func ValidateAnnotationsContent

func ValidateAnnotationsContent(annotations map[string]string, identifier string) ([]string, bool)

ValidateAnnotationsContent reports errors in AD annotations content the identifier string is expected to include the AD prefix

func ValidateAnnotationsMatching

func ValidateAnnotationsMatching(annotations map[string]string, validIDs map[string]bool) []string

ValidateAnnotationsMatching detects if AD annotations don't match a valid container identifier

func ValidateUpgrade

func ValidateUpgrade(image string, latest bool) error

ValidateUpgrade valides the input of the upgrade commands

Types

type Options

type Options struct {
	ConfigFlags     *genericclioptions.ConfigFlags
	Client          client.Client
	Clientset       *kubernetes.Clientset
	APIExtClient    *apiextensionclient.Clientset
	DiscoveryClient discovery.DiscoveryInterface

	UserNamespace string
}

Options encapsulates the common fields of command options

func (*Options) GetClientConfig

func (o *Options) GetClientConfig() clientcmd.ClientConfig

GetClientConfig returns the client config

func (*Options) Init

func (o *Options) Init(cmd *cobra.Command) error

Init initialize the common config of command options

func (*Options) SetApiExtensionClient added in v1.2.0

func (o *Options) SetApiExtensionClient(client *apiextensionclient.Clientset)

SetApiExtensionClient configures the APIExtClient

func (*Options) SetClient

func (o *Options) SetClient(client client.Client)

SetClient configures the client

func (*Options) SetClientset

func (o *Options) SetClientset(clientset *kubernetes.Clientset)

SetClientset configures the clientset

func (*Options) SetConfigFlags

func (o *Options) SetConfigFlags()

SetConfigFlags configures the config flags

func (*Options) SetDiscoveryClient added in v1.9.0

func (o *Options) SetDiscoveryClient(client discovery.DiscoveryInterface)

SetDiscoveryClient configures the DiscoveryClient

func (*Options) SetNamespace

func (o *Options) SetNamespace(ns string)

SetNamespace configures the namespace

type StatusWrapper added in v1.1.0

type StatusWrapper interface {
	GetObjectMeta() metav1.Object
	GetAgentStatus() *v2alpha1.DaemonSetStatus
	GetClusterAgentStatus() *v2alpha1.DeploymentStatus
	GetClusterChecksRunnerStatus() *v2alpha1.DeploymentStatus
	GetStatusCondition() []metav1.Condition
}

func NewV2StatusWrapper added in v1.1.0

func NewV2StatusWrapper(dda *v2alpha1.DatadogAgent) StatusWrapper

Jump to

Keyboard shortcuts

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