{"modulePath":"github.com/cloudzero/cloudzero-agent","version":"v1.3.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package config\n\nPackage config contains the configuration for the application.\n\n## Constants\n\n```go\nconst (\n\tFieldNamespace    = \"namespace\"\n\tFieldNode         = \"node\"\n\tFieldPod          = \"pod\"\n\tFieldResourceType = \"resource_type\"\n\tFieldWorkload     = \"workload\"\n)\n```\n\n## Variables\n\n```go\nvar ResourceTypeToMetricName = map[ResourceType]string{\n\tUnknown:                  \"unknown\",\n\tDeployment:               \"deployment\",\n\tStatefulSet:              \"statefulset\",\n\tPod:                      \"pod\",\n\tNode:                     \"node\",\n\tNamespace:                \"namespace\",\n\tJob:                      \"job\",\n\tCronJob:                  \"cronjob\",\n\tDaemonSet:                \"daemonset\",\n\tIngressClass:             \"ingressclass\",\n\tIngress:                  \"ingress\",\n\tService:                  \"service\",\n\tCustomResourceDefinition: \"crd\",\n\tReplicaSet:               \"replicaset\",\n\tStorageClass:             \"storageclass\",\n\tPersistentVolume:         \"pv\",\n\tPersistentVolumeClaim:    \"pcv\",\n\tGatewayClass:             \"gatewayclass\",\n\tGateway:                  \"gateway\",\n}\n```\n\n## Types\n\n```go\ntype Annotations struct {\n\tEnabled   bool      `yaml:\"enabled\" default:\"false\" env:\"ANNOTATIONS_ENABLED\" env-description:\"enable annotations\"`\n\tResources Resources `yaml:\"resources\"`\n\tPatterns  []string  `yaml:\"patterns\" env:\"ANNOTATIONS_FILTERS\" env-description:\"list of annotations regular expressions to filter\"`\n}\n```\n\n```go\ntype Certificate struct {\n\tKey  string `yaml:\"key\" env:\"TLS_KEY\" env-description:\"path to the TLS key\"`\n\tCert string `yaml:\"cert\" env:\"TLS_CERT\" env-description:\"path to the TLS certificate\"`\n}\n```\n\n```go\ntype ConfigAccessor interface {\n\t// LabelsEnabled checks if labels are enabled globally.\n\tLabelsEnabled() bool\n\n\t// AnnotationsEnabled checks if annotations are enabled globally.\n\tAnnotationsEnabled() bool\n\n\t// LabelsEnabledForType checks if labels are enabled for a specific resource type.\n\tLabelsEnabledForType() bool\n\n\t// AnnotationsEnabledForType checks if annotations are enabled for a specific resource type.\n\tAnnotationsEnabledForType() bool\n\n\t// ResourceType returns the type of resource associated with the configuration.\n\tResourceType() ResourceType\n\n\t// Settings retrieves the configuration settings.\n\tSettings() *Settings\n}\n```\nConfigAccessor defines the interface for accessing settings related to labels and annotations. It provides methods to check if labels and annotations are enabled globally or for specific resource types, retrieve the associated resource type, and access the configuration settings.\n\n```go\ntype Database struct {\n\tEnabled         bool          `yaml:\"enabled\" default:\"false\" env:\"DATABASE_ENABLED\" env-description:\"when enabled will write to persistent storage, otherwise only in memory sqlite\"`\n\tStoragePath     string        `yaml:\"storage_path\" default:\"/opt/insights\" env:\"DATABASE_STORAGE_PATH\" env-description:\"location where to write database\"`\n\tRetentionTime   time.Duration `yaml:\"retention_time\" default:\"24h\" env:\"DATABASE_RETENTION\" env-description:\"how long local data should be retain before being deleted\"`\n\tCleanupInterval time.Duration `yaml:\"cleanup_interval\" default:\"3h\" env:\"DATABASE_CLEANUP_INTERVAL\" env-description:\"how often to check for expired data\"`\n\tBatchUpdateSize int           `yaml:\"batch_update_size\" default:\"500\" env:\"DATABASE_BATCH_UPDATE_SIZE\" env-description:\"how many records to update in a single batch\"`\n}\n```\n\n```go\ntype Files []string\n```\nFiles is a custom flag type to handle multiple configuration files\n\n```go\nfunc (c *Files) Set(value string) error\n```\nSet appends a new configuration file to the Files\n\n```go\nfunc (c *Files) String() string\n```\n\n```go\ntype Filters struct {\n\tLabels      Labels      `yaml:\"labels\"`\n\tAnnotations Annotations `yaml:\"annotations\"`\n\tPolicy      bluemonday.Policy\n}\n```\n\n```go\ntype K8sClient struct {\n\tKubeConfig      string `yaml:\"kube_config\" env:\"KUBE_CONFIG\" default:\"false\" env-description:\"path to the kubeconfig file\"`\n\tPaginationLimit int64  `yaml:\"pagination_limit\" env:\"KUBE_PAGINATION_LIMIT\" default:\"500\" env-description:\"limit for pagination\"`\n}\n```\n\n```go\ntype Labels struct {\n\tEnabled   bool      `yaml:\"enabled\" default:\"false\" env:\"LABELS_ENABLED\" env-description:\"enable labels\"`\n\tResources Resources `yaml:\"resources\"`\n\tPatterns  []string  `yaml:\"patterns\" env:\"LABEL_FILTERS\" env-description:\"list of label regular expressions to filter\"`\n}\n```\n\n```go\ntype Logging struct {\n\tLevel string `yaml:\"level\" default:\"info\" env:\"LOG_LEVEL\" env-description:\"logging level such as debug, info, error\"`\n}\n```\n\n```go\ntype MetricLabelTags = map[string]string\n```\nMetricLabelTags represents metric labels attached to a metric that represent annotations or labels; value must be prefixed with \"label\\_\"\n\n```go\nfunc Filter(tags map[string]string, patterns []regexp.Regexp, enabled bool, settings *Settings) MetricLabelTags\n```\n\n```go\ntype MetricLabels = map[string]string\n```\nMetricLabels represents any metric label that can be added to a metric; \"pod\", \"namespace\", \"label\\_foo\" etc.\n\n```go\ntype RemoteWrite struct {\n\tHost            string\n\tMaxBytesPerSend int           `yaml:\"max_bytes_per_send\" default:\"10000000\" env:\"MAX_BYTES_PER_SEND\" env-description:\"maximum bytes to send in a single request\"`\n\tSendInterval    time.Duration `yaml:\"send_interval\" default:\"60s\" env:\"SEND_INTERVAL\" env-description:\"interval in seconds to send data\"`\n\tSendTimeout     time.Duration `yaml:\"send_timeout\" default:\"30s\" env:\"SEND_TIMEOUT\" env-description:\"timeout in seconds to send data\"`\n\tMaxRetries      int           `yaml:\"max_retries\" default:\"3\" env:\"MAX_RETRIES\" env-description:\"maximum number of retries\"`\n}\n```\n\n```go\ntype ResourceType int\n```\n\n```go\nconst (\n\tUnknown ResourceType = iota\n\tDeployment\n\tStatefulSet\n\tPod\n\tNode\n\tNamespace\n\tJob\n\tCronJob\n\tDaemonSet\n\tIngressClass\n\tIngress\n\tService\n\tCustomResourceDefinition\n\tReplicaSet\n\tStorageClass\n\tPersistentVolume\n\tPersistentVolumeClaim\n\tGatewayClass\n\tGateway\n)\n```\n\n```go\ntype Resources struct {\n\tPods         bool `yaml:\"pods\" default:\"true\"`\n\tNamespaces   bool `yaml:\"namespaces\" default:\"true\"`\n\tDeployments  bool `yaml:\"deployments\" default:\"false\"`\n\tJobs         bool `yaml:\"jobs\" default:\"false\"`\n\tCronJobs     bool `yaml:\"cronjobs\" default:\"false\"`     //nolint:tagliatelle // compatibility\n\tStatefulSets bool `yaml:\"statefulsets\" default:\"false\"` //nolint:tagliatelle // compatibility\n\tDaemonSets   bool `yaml:\"daemonsets\" default:\"false\"`   //nolint:tagliatelle // compatibility\n\tNodes        bool `yaml:\"nodes\" default:\"false\"`\n}\n```\n\n```go\ntype Server struct {\n\tMode      string `yaml:\"mode\" default:\"http\" env:\"SERVER_MODE\" env-description:\"server mode such as http, https\"`\n\tNamespace string `yaml:\"namespace\" env:\"NAMESPACE\" env-description:\"namespace of the webhook\"`\n\tDomain    string `yaml:\"domain\" default:\"\" env:\"SERVER_DOMAIN\" env-description:\"server domain\"`\n\tPort      uint   `yaml:\"port\" default:\"8080\" env:\"SERVER_PORT\" env-description:\"server port\"`\n\tProfiling bool   `yaml:\"profiling\" default:\"false\" env:\"SERVER_PROFILING\" env-description:\"enable profiling\"`\n\n\tReadTimeout        time.Duration `yaml:\"read_timeout\" default:\"15s\" env:\"READ_TIMEOUT\" env-description:\"server read timeout in seconds\"`\n\tWriteTimeout       time.Duration `yaml:\"write_timeout\" default:\"15s\" env:\"WRITE_TIMEOUT\" env-description:\"server write timeout in seconds\"`\n\tIdleTimeout        time.Duration `yaml:\"idle_timeout\" default:\"60s\" env:\"IDLE_TIMEOUT\" env-description:\"server idle timeout in seconds\"`\n\tReconnectFrequency int           `yaml:\"reconnect_frequency\" default:\"16\" env:\"SERVER_RECONNECT_FREQUENCY\" env-description:\"how frequently to close HTTP connections from clients, to distribute the load. 0=never, otherwise 1/N probability.\"`\n}\n```\n\n```go\ntype Settings struct {\n\tCloudAccountID string      `yaml:\"cloud_account_id\" env:\"CLOUD_ACCOUNT_ID\" env-description:\"CSP account ID\"`\n\tRegion         string      `yaml:\"region\" env:\"CSP_REGION\" env-description:\"cloud service provider region\"`\n\tClusterName    string      `yaml:\"cluster_name\" env:\"CLUSTER_NAME\" env-description:\"name of the cluster to monitor\"`\n\tDestination    string      `yaml:\"destination\" env:\"DESTINATION\" env-default:\"https://api.cloudzero.com/v1/container-metrics\" env-description:\"location to send metrics to\"`\n\tServer         Server      `yaml:\"server\"`\n\tCertificate    Certificate `yaml:\"certificate\"`\n\tLogging        Logging     `yaml:\"logging\"`\n\tDatabase       Database    `yaml:\"database\"`\n\tFilters        Filters     `yaml:\"filters\"`\n\tRemoteWrite    RemoteWrite `yaml:\"remote_write\"`\n\tK8sClient      K8sClient   `yaml:\"k8s_client\"`\n\n\t// Deprecated: removed in CP-28161 when the insights-controller stopped\n\t// authenticating to the in-cluster aggregator. Kept as an ignored\n\t// tombstone so legacy configs (older Helm-rendered server-config.yaml,\n\t// or an API_KEY_PATH env var still set in a pod spec) load cleanly under\n\t// strict YAML/env decoders. Has no effect.\n\tAPIKeyPath string `yaml:\"api_key_path\" env:\"API_KEY_PATH\" env-description:\"deprecated; ignored\"`\n\n\tLabelMatches      []regexp.Regexp\n\tAnnotationMatches []regexp.Regexp\n}\n```\nSettings represents the configuration settings for the application.\n\n```go\nfunc NewSettings(configFiles ...string) (*Settings, error)\n```\n\n```go\nfunc (s *Settings) ToBytes() ([]byte, error)\n```\nToBytes returns a serialized representation of the data in the class\n\n```go\nfunc (s *Settings) ToYAML() ([]byte, error)\n```\n\n","path":"github.com/cloudzero/cloudzero-agent/app/config/webhook","name":"config","synopsis":"Package config contains the configuration for the application.","isRedistributable":true}
