From e9c8d0db2f4b9444eea543d092c92792627a7dde Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 2 May 2025 12:00:17 -0700 Subject: [PATCH] [chore] apply unkeyed literal initialization prevention --- .checkapi.yaml | 4 +++ connector/datadogconnector/config.go | 2 ++ connector/exceptionsconnector/config.go | 4 +++ .../connector_metrics_test.go | 22 +++++++-------- connector/servicegraphconnector/config.go | 3 +++ connector/spanmetricsconnector/config.go | 8 ++++++ exporter/awss3exporter/config.go | 2 ++ exporter/cassandraexporter/config.go | 6 +++++ exporter/elasticsearchexporter/config.go | 27 +++++++++++++++++++ exporter/honeycombmarkerexporter/config.go | 3 +++ exporter/loadbalancingexporter/config.go | 10 +++++++ exporter/logicmonitorexporter/config.go | 4 +++ .../prometheusremotewriteexporter/config.go | 9 +++++++ exporter/rabbitmqexporter/config.go | 2 ++ extension/azureauthextension/config.go | 8 ++++++ .../config.go | 3 +++ .../awslogsencodingextension/config.go | 5 ++++ .../awslogsencodingextension/config_test.go | 8 +++--- extension/headerssetterextension/config.go | 3 +++ extension/observer/cfgardenobserver/config.go | 6 +++++ extension/observer/hostobserver/config.go | 3 +++ processor/datadogsemanticsprocessor/config.go | 3 +++ processor/deltatorateprocessor/config.go | 3 +++ processor/groupbyattrsprocessor/config.go | 3 +++ processor/k8sattributesprocessor/config.go | 12 +++++++++ .../metricsgenerationprocessor/config.go | 3 +++ processor/metricstransformprocessor/config.go | 9 +++++++ processor/remotetapprocessor/config.go | 3 +++ processor/resourceprocessor/config.go | 3 +++ receiver/apachereceiver/config.go | 3 +++ receiver/apachesparkreceiver/config.go | 3 +++ .../awscloudwatchmetricsreceiver/config.go | 9 +++++++ .../awsecscontainermetricsreceiver/config.go | 3 +++ receiver/awss3receiver/config.go | 6 +++++ receiver/awsxrayreceiver/config.go | 3 +++ receiver/azuremonitorreceiver/config.go | 2 ++ receiver/chronyreceiver/config.go | 3 +++ receiver/cloudflarereceiver/config.go | 6 +++++ receiver/cloudfoundryreceiver/config.go | 15 +++++++++++ receiver/datadogreceiver/config.go | 3 +++ receiver/filelogreceiver/filelog.go | 3 +++ receiver/filestatsreceiver/config.go | 3 +++ receiver/fluentforwardreceiver/config.go | 3 +++ receiver/gitlabreceiver/config.go | 6 +++++ receiver/httpcheckreceiver/config.go | 3 +++ receiver/jaegerreceiver/config.go | 15 +++++++++++ receiver/journaldreceiver/config.go | 3 +++ receiver/libhoneyreceiver/config.go | 6 +++++ receiver/libhoneyreceiver/receiver.go | 9 +++++++ receiver/lokireceiver/config.go | 6 +++++ receiver/mongodbatlasreceiver/config.go | 9 +++++++ receiver/namedpipereceiver/namedpipe.go | 3 +++ receiver/nginxreceiver/config.go | 3 +++ receiver/opencensusreceiver/config.go | 3 +++ receiver/otelarrowreceiver/config.go | 12 +++++++++ receiver/purefareceiver/config.go | 6 +++++ receiver/purefbreceiver/config.go | 6 +++++ receiver/snmpreceiver/config.go | 12 +++++++++ receiver/solacereceiver/config.go | 15 +++++++++++ receiver/solacereceiver/config_test.go | 12 ++++----- receiver/sqlqueryreceiver/config.go | 3 +++ receiver/stefreceiver/config.go | 3 +++ receiver/syslogreceiver/syslog.go | 3 +++ receiver/tcpcheckreceiver/config.go | 3 +++ receiver/tcplogreceiver/tcp.go | 3 +++ receiver/tlscheckreceiver/config.go | 6 +++++ receiver/udplogreceiver/udp.go | 3 +++ .../wavefrontreceiver/wavefront_parser.go | 3 +++ receiver/windowseventlogreceiver/receiver.go | 3 +++ receiver/zipkinreceiver/config.go | 3 +++ 70 files changed, 387 insertions(+), 21 deletions(-) diff --git a/.checkapi.yaml b/.checkapi.yaml index dc7681c660332..c7e1a67d221b5 100644 --- a/.checkapi.yaml +++ b/.checkapi.yaml @@ -67,3 +67,7 @@ ignored_functions: - ^Test.* - ^Benchmark.* - ^Fuzz.* + +unkeyed_literal_initialization: + enabled: true + limit: 1 # this limit will increase over time to 5. diff --git a/connector/datadogconnector/config.go b/connector/datadogconnector/config.go index b58b09a0a7e31..8548f151fc6c8 100644 --- a/connector/datadogconnector/config.go +++ b/connector/datadogconnector/config.go @@ -15,6 +15,8 @@ var _ component.Config = (*Config)(nil) type Config struct { // Traces defines the Traces specific configuration Traces datadogconfig.TracesConnectorConfig `mapstructure:"traces"` + // prevent unkeyed literal initialization + _ struct{} } // Validate checks if the configuration is valid diff --git a/connector/exceptionsconnector/config.go b/connector/exceptionsconnector/config.go index ea0081442b891..434af03da4cc7 100644 --- a/connector/exceptionsconnector/config.go +++ b/connector/exceptionsconnector/config.go @@ -13,10 +13,14 @@ import ( type Dimension struct { Name string `mapstructure:"name"` Default *string `mapstructure:"default"` + // prevent unkeyed literal initialization + _ struct{} } type Exemplars struct { Enabled bool `mapstructure:"enabled"` + // prevent unkeyed literal initialization + _ struct{} } // Config defines the configuration options for exceptionsconnector diff --git a/connector/exceptionsconnector/connector_metrics_test.go b/connector/exceptionsconnector/connector_metrics_test.go index 679ca0190fa44..fc9c5510ebd8e 100644 --- a/connector/exceptionsconnector/connector_metrics_test.go +++ b/connector/exceptionsconnector/connector_metrics_test.go @@ -124,21 +124,21 @@ func newTestMetricsConnector(mcon consumer.Metrics, defaultNullValue *string, lo cfg := &Config{ Dimensions: []Dimension{ // Set nil defaults to force a lookup for the attribute in the span. - {stringAttrName, nil}, - {intAttrName, nil}, - {doubleAttrName, nil}, - {boolAttrName, nil}, - {mapAttrName, nil}, - {arrayAttrName, nil}, - {nullAttrName, defaultNullValue}, + {Name: stringAttrName}, + {Name: intAttrName}, + {Name: doubleAttrName}, + {Name: boolAttrName}, + {Name: mapAttrName}, + {Name: arrayAttrName}, + {Name: nullAttrName, Default: defaultNullValue}, // Add a default value for an attribute that doesn't exist in a span - {notInSpanAttrName0, stringp("defaultNotInSpanAttrVal")}, + {Name: notInSpanAttrName0, Default: stringp("defaultNotInSpanAttrVal")}, // Leave the default value unset to test that this dimension should not be added to the metric. - {notInSpanAttrName1, nil}, + {Name: notInSpanAttrName1}, // Exception specific dimensions - {exceptionTypeKey, nil}, - {exceptionMessageKey, nil}, + {Name: exceptionTypeKey}, + {Name: exceptionMessageKey}, }, Exemplars: Exemplars{ Enabled: true, diff --git a/connector/servicegraphconnector/config.go b/connector/servicegraphconnector/config.go index e2730f423776a..2e19596a1d7e3 100644 --- a/connector/servicegraphconnector/config.go +++ b/connector/servicegraphconnector/config.go @@ -62,4 +62,7 @@ type StoreConfig struct { MaxItems int `mapstructure:"max_items"` // TTL is the time to live for items in the store. TTL time.Duration `mapstructure:"ttl"` + + // prevent unkeyed literal initialization + _ struct{} } diff --git a/connector/spanmetricsconnector/config.go b/connector/spanmetricsconnector/config.go index 6115a549a25ea..0fd324f679e98 100644 --- a/connector/spanmetricsconnector/config.go +++ b/connector/spanmetricsconnector/config.go @@ -107,15 +107,21 @@ type HistogramConfig struct { type ExemplarsConfig struct { Enabled bool `mapstructure:"enabled"` MaxPerDataPoint *int `mapstructure:"max_per_data_point"` + // prevent unkeyed literal initialization + _ struct{} } type ExponentialHistogramConfig struct { MaxSize int32 `mapstructure:"max_size"` + // prevent unkeyed literal initialization + _ struct{} } type ExplicitHistogramConfig struct { // Buckets is the list of durations representing explicit histogram buckets. Buckets []time.Duration `mapstructure:"buckets"` + // prevent unkeyed literal initialization + _ struct{} } type EventsConfig struct { @@ -123,6 +129,8 @@ type EventsConfig struct { Enabled bool `mapstructure:"enabled"` // Dimensions defines the list of dimensions to add to the events metric. Dimensions []Dimension `mapstructure:"dimensions"` + // prevent unkeyed literal initialization + _ struct{} } var _ xconfmap.Validator = (*Config)(nil) diff --git a/exporter/awss3exporter/config.go b/exporter/awss3exporter/config.go index 333468ae69950..87c994585929f 100644 --- a/exporter/awss3exporter/config.go +++ b/exporter/awss3exporter/config.go @@ -73,6 +73,8 @@ const ( type ResourceAttrsToS3 struct { // S3Prefix indicates the mapping of the key (directory) prefix used for writing into the bucket to a specific resource attribute value. S3Prefix string `mapstructure:"s3_prefix"` + // prevent unkeyed literal initialization + _ struct{} } // Config contains the main configuration options for the s3 exporter diff --git a/exporter/cassandraexporter/config.go b/exporter/cassandraexporter/config.go index f0c6c866f03aa..94fdc5e00b477 100644 --- a/exporter/cassandraexporter/config.go +++ b/exporter/cassandraexporter/config.go @@ -23,13 +23,19 @@ type Config struct { type Replication struct { Class string `mapstructure:"class"` ReplicationFactor int `mapstructure:"replication_factor"` + // prevent unkeyed literal initialization + _ struct{} } type Compression struct { Algorithm string `mapstructure:"algorithm"` + // prevent unkeyed literal initialization + _ struct{} } type Auth struct { UserName string `mapstructure:"username"` Password configopaque.String `mapstructure:"password"` + // prevent unkeyed literal initialization + _ struct{} } diff --git a/exporter/elasticsearchexporter/config.go b/exporter/elasticsearchexporter/config.go index 8afcc807aae11..2e00bf5665609 100644 --- a/exporter/elasticsearchexporter/config.go +++ b/exporter/elasticsearchexporter/config.go @@ -129,12 +129,18 @@ type TelemetrySettings struct { LogFailedDocsInput bool `mapstructure:"log_failed_docs_input"` LogFailedDocsInputRateLimit time.Duration `mapstructure:"log_failed_docs_input_rate_limit"` + + // prevent unkeyed literal initialization + _ struct{} } type LogstashFormatSettings struct { Enabled bool `mapstructure:"enabled"` PrefixSeparator string `mapstructure:"prefix_separator"` DateFormat string `mapstructure:"date_format"` + + // prevent unkeyed literal initialization + _ struct{} } type DynamicIndexSetting struct { @@ -142,14 +148,23 @@ type DynamicIndexSetting struct { // // Deprecated: [v0.122.0] This config is now ignored. Dynamic index routing is always done by default. Enabled bool `mapstructure:"enabled"` + + // prevent unkeyed literal initialization + _ struct{} } type DynamicIDSettings struct { Enabled bool `mapstructure:"enabled"` + + // prevent unkeyed literal initialization + _ struct{} } type DynamicPipelineSettings struct { Enabled bool `mapstructure:"enabled"` + + // prevent unkeyed literal initialization + _ struct{} } // AuthenticationSettings defines user authentication related settings. @@ -164,6 +179,9 @@ type AuthenticationSettings struct { // // https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html APIKey configopaque.String `mapstructure:"api_key"` + + // prevent unkeyed literal initialization + _ struct{} } // DiscoverySettings defines Elasticsearch node discovery related settings. @@ -183,6 +201,9 @@ type DiscoverySettings struct { // Interval instructs the exporter to renew the list of Elasticsearch URLs // with the given interval. URLs will not be updated if Interval is <=0. Interval time.Duration `mapstructure:"interval"` + + // prevent unkeyed literal initialization + _ struct{} } // FlushSettings defines settings for configuring the write buffer flushing @@ -194,6 +215,9 @@ type FlushSettings struct { // Interval configures the max age of a document in the send buffer. Interval time.Duration `mapstructure:"interval"` + + // prevent unkeyed literal initialization + _ struct{} } // RetrySettings defines settings for the HTTP request retries in the Elasticsearch exporter. @@ -235,6 +259,9 @@ type MappingsSettings struct { // // If unspecified, all mapping modes are allowed. AllowedModes []string `mapstructure:"allowed_modes"` + + // prevent unkeyed literal initialization + _ struct{} } type MappingMode int diff --git a/exporter/honeycombmarkerexporter/config.go b/exporter/honeycombmarkerexporter/config.go index 53b4bcb0e1ef1..bada6387da190 100644 --- a/exporter/honeycombmarkerexporter/config.go +++ b/exporter/honeycombmarkerexporter/config.go @@ -56,6 +56,9 @@ type Marker struct { type Rules struct { // LogConditions is the list of ottllog conditions that determine a match LogConditions []string `mapstructure:"log_conditions"` + + // prevent unkeyed literal initialization + _ struct{} } var _ component.Config = (*Config)(nil) diff --git a/exporter/loadbalancingexporter/config.go b/exporter/loadbalancingexporter/config.go index 2c9ff2e8f879b..c7accdae63619 100644 --- a/exporter/loadbalancingexporter/config.go +++ b/exporter/loadbalancingexporter/config.go @@ -54,6 +54,8 @@ type Config struct { // Protocol holds the individual protocol-specific settings. Only OTLP is supported at the moment. type Protocol struct { OTLP otlpexporter.Config `mapstructure:"otlp"` + // prevent unkeyed literal initialization + _ struct{} } // ResolverSettings defines the configurations for the backend resolver @@ -62,11 +64,15 @@ type ResolverSettings struct { DNS *DNSResolver `mapstructure:"dns"` K8sSvc *K8sSvcResolver `mapstructure:"k8s"` AWSCloudMap *AWSCloudMapResolver `mapstructure:"aws_cloud_map"` + // prevent unkeyed literal initialization + _ struct{} } // StaticResolver defines the configuration for the resolver providing a fixed list of backends type StaticResolver struct { Hostnames []string `mapstructure:"hostnames"` + // prevent unkeyed literal initialization + _ struct{} } // DNSResolver defines the configuration for the DNS resolver @@ -75,6 +81,8 @@ type DNSResolver struct { Port string `mapstructure:"port"` Interval time.Duration `mapstructure:"interval"` Timeout time.Duration `mapstructure:"timeout"` + // prevent unkeyed literal initialization + _ struct{} } // K8sSvcResolver defines the configuration for the DNS resolver @@ -83,6 +91,8 @@ type K8sSvcResolver struct { Ports []int32 `mapstructure:"ports"` Timeout time.Duration `mapstructure:"timeout"` ReturnHostnames bool `mapstructure:"return_hostnames"` + // prevent unkeyed literal initialization + _ struct{} } type AWSCloudMapResolver struct { diff --git a/exporter/logicmonitorexporter/config.go b/exporter/logicmonitorexporter/config.go index 8b2d73485665b..a6e1003be91a3 100644 --- a/exporter/logicmonitorexporter/config.go +++ b/exporter/logicmonitorexporter/config.go @@ -34,6 +34,8 @@ type Config struct { type APIToken struct { AccessID string `mapstructure:"access_id"` AccessKey configopaque.String `mapstructure:"access_key"` + // prevent unkeyed literal initialization + _ struct{} } type MappingOperation string @@ -58,6 +60,8 @@ func (mop *MappingOperation) UnmarshalText(in []byte) error { type LogsConfig struct { // Operation to be performed for resource mapping. Valid values are `and`, `or`. ResourceMappingOperation MappingOperation `mapstructure:"resource_mapping_op"` + // prevent unkeyed literal initialization + _ struct{} } func (c *Config) Validate() error { diff --git a/exporter/prometheusremotewriteexporter/config.go b/exporter/prometheusremotewriteexporter/config.go index 4b25d658dca65..d52efa3322a83 100644 --- a/exporter/prometheusremotewriteexporter/config.go +++ b/exporter/prometheusremotewriteexporter/config.go @@ -62,11 +62,17 @@ type Config struct { type CreatedMetric struct { // Enabled if true the _created metrics could be exported Enabled bool `mapstructure:"enabled"` + + // prevent unkeyed literal initialization + _ struct{} } type TargetInfo struct { // Enabled if false the target_info metric is not generated by the exporter Enabled bool `mapstructure:"enabled"` + + // prevent unkeyed literal initialization + _ struct{} } // RemoteWriteQueue allows to configure the remote write queue. @@ -82,6 +88,9 @@ type RemoteWriteQueue struct { // NumWorkers configures the number of workers used by // the collector to fan out remote write requests. NumConsumers int `mapstructure:"num_consumers"` + + // prevent unkeyed literal initialization + _ struct{} } // TODO(jbd): Add capacity, max_samples_per_send to QueueConfig. diff --git a/exporter/rabbitmqexporter/config.go b/exporter/rabbitmqexporter/config.go index 6bc095037caae..b256d0ef11ca3 100644 --- a/exporter/rabbitmqexporter/config.go +++ b/exporter/rabbitmqexporter/config.go @@ -38,6 +38,8 @@ type RoutingConfig struct { type AuthConfig struct { Plain PlainAuth `mapstructure:"plain"` + // prevent unkeyed literal initialization + _ struct{} } type PlainAuth struct { diff --git a/extension/azureauthextension/config.go b/extension/azureauthextension/config.go index 71272c5531bdf..7b56566cc00c3 100644 --- a/extension/azureauthextension/config.go +++ b/extension/azureauthextension/config.go @@ -31,17 +31,23 @@ type Config struct { Workload *WorkloadIdentity `mapstructure:"workload_identity"` ServicePrincipal *ServicePrincipal `mapstructure:"service_principal"` UseDefault bool `mapstructure:"use_default"` + // prevent unkeyed literal initialization + _ struct{} } type ManagedIdentity struct { // if left empty, then it is system managed ClientID string `mapstructure:"client_id"` + // prevent unkeyed literal initialization + _ struct{} } type WorkloadIdentity struct { ClientID string `mapstructure:"client_id"` TenantID string `mapstructure:"tenant_id"` FederatedTokenFile string `mapstructure:"federated_token_file"` + // prevent unkeyed literal initialization + _ struct{} } type ServicePrincipal struct { @@ -49,6 +55,8 @@ type ServicePrincipal struct { ClientID string `mapstructure:"client_id"` ClientSecret string `mapstructure:"client_secret"` ClientCertificatePath string `mapstructure:"client_certificate_path"` + // prevent unkeyed literal initialization + _ struct{} } var _ component.Config = (*Config)(nil) diff --git a/extension/encoding/awscloudwatchmetricstreamsencodingextension/config.go b/extension/encoding/awscloudwatchmetricstreamsencodingextension/config.go index a5e06eb12068d..153185dbb9a7e 100644 --- a/extension/encoding/awscloudwatchmetricstreamsencodingextension/config.go +++ b/extension/encoding/awscloudwatchmetricstreamsencodingextension/config.go @@ -24,6 +24,9 @@ type Config struct { // // See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-metricstream.html#cfn-cloudwatch-metricstream-outputformat Format string `mapstructure:"format"` + + // prevent unkeyed literal initialization + _ struct{} } func (cfg *Config) Validate() error { diff --git a/extension/encoding/awslogsencodingextension/config.go b/extension/encoding/awslogsencodingextension/config.go index ce4eaa0cf88ab..98eb8b4bde513 100644 --- a/extension/encoding/awslogsencodingextension/config.go +++ b/extension/encoding/awslogsencodingextension/config.go @@ -36,6 +36,9 @@ type Config struct { Format string `mapstructure:"format"` VPCFlowLogConfig VPCFlowLogConfig `mapstructure:"vpc_flow_log"` + + // prevent unkeyed literal initialization + _ struct{} } type VPCFlowLogConfig struct { @@ -45,6 +48,8 @@ type VPCFlowLogConfig struct { // // See https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs-s3-path.html. FileFormat string `mapstructure:"file_format"` + // prevent unkeyed literal initialization + _ struct{} } func (cfg *Config) Validate() error { diff --git a/extension/encoding/awslogsencodingextension/config_test.go b/extension/encoding/awslogsencodingextension/config_test.go index 97a2a47251cd3..13de217ad2670 100644 --- a/extension/encoding/awslogsencodingextension/config_test.go +++ b/extension/encoding/awslogsencodingextension/config_test.go @@ -38,7 +38,7 @@ func TestLoadConfig(t *testing.T) { expected: &Config{ Format: formatCloudWatchLogsSubscriptionFilter, VPCFlowLogConfig: VPCFlowLogConfig{ - fileFormatPlainText, + FileFormat: fileFormatPlainText, }, }, }, @@ -47,7 +47,7 @@ func TestLoadConfig(t *testing.T) { expected: &Config{ Format: formatVPCFlowLog, VPCFlowLogConfig: VPCFlowLogConfig{ - fileFormatPlainText, + FileFormat: fileFormatPlainText, }, }, }, @@ -56,7 +56,7 @@ func TestLoadConfig(t *testing.T) { expected: &Config{ Format: formatVPCFlowLog, VPCFlowLogConfig: VPCFlowLogConfig{ - fileFormatParquet, + FileFormat: fileFormatParquet, }, }, }, @@ -72,7 +72,7 @@ func TestLoadConfig(t *testing.T) { expected: &Config{ Format: formatS3AccessLog, VPCFlowLogConfig: VPCFlowLogConfig{ - fileFormatPlainText, + FileFormat: fileFormatPlainText, }, }, }, diff --git a/extension/headerssetterextension/config.go b/extension/headerssetterextension/config.go index 6d1b8db64be56..caea441f9b5d3 100644 --- a/extension/headerssetterextension/config.go +++ b/extension/headerssetterextension/config.go @@ -18,6 +18,9 @@ var ( type Config struct { HeadersConfig []HeaderConfig `mapstructure:"headers"` + + // prevent unkeyed literal initialization + _ struct{} } type HeaderConfig struct { diff --git a/extension/observer/cfgardenobserver/config.go b/extension/observer/cfgardenobserver/config.go index 67085def9fe36..49aa78c249e78 100644 --- a/extension/observer/cfgardenobserver/config.go +++ b/extension/observer/cfgardenobserver/config.go @@ -84,6 +84,9 @@ func fieldError(authType authType, param string) error { type GardenConfig struct { // The URL of the CF Garden api. Default is "/var/vcap/data/garden/garden.sock" Endpoint string `mapstructure:"endpoint"` + + // prevent unkeyed literal initialization + _ struct{} } type CfConfig struct { @@ -92,6 +95,9 @@ type CfConfig struct { // Authentication details Auth CfAuth `mapstructure:"auth"` + + // prevent unkeyed literal initialization + _ struct{} } type CfAuth struct { diff --git a/extension/observer/hostobserver/config.go b/extension/observer/hostobserver/config.go index 73ef12082a13c..cf20ffec39d1c 100644 --- a/extension/observer/hostobserver/config.go +++ b/extension/observer/hostobserver/config.go @@ -12,4 +12,7 @@ type Config struct { // RefreshInterval determines how frequency at which the observer // needs to poll for collecting information about new processes. RefreshInterval time.Duration `mapstructure:"refresh_interval"` + + // prevent unkeyed literal initialization + _ struct{} } diff --git a/processor/datadogsemanticsprocessor/config.go b/processor/datadogsemanticsprocessor/config.go index d481cedec2a65..98b168ffc3841 100644 --- a/processor/datadogsemanticsprocessor/config.go +++ b/processor/datadogsemanticsprocessor/config.go @@ -10,4 +10,7 @@ type Config struct { // If it is true, all fields in the "datadog." namespace will be recomputed by the processor. // Default: false. OverrideIncomingDatadogFields bool `mapstructure:"override_incoming_datadog_fields"` + + // prevent unkeyed literal initialization + _ struct{} } diff --git a/processor/deltatorateprocessor/config.go b/processor/deltatorateprocessor/config.go index 58980890bc228..7f10aa8c9532e 100644 --- a/processor/deltatorateprocessor/config.go +++ b/processor/deltatorateprocessor/config.go @@ -11,6 +11,9 @@ import ( type Config struct { // List of delta sum metrics to convert to rates Metrics []string `mapstructure:"metrics"` + + // prevent unkeyed literal initialization + _ struct{} } // Validate checks whether the input configuration has all of the required fields for the processor. diff --git a/processor/groupbyattrsprocessor/config.go b/processor/groupbyattrsprocessor/config.go index c02f29995b107..9b382c525a64e 100644 --- a/processor/groupbyattrsprocessor/config.go +++ b/processor/groupbyattrsprocessor/config.go @@ -8,4 +8,7 @@ type Config struct { // GroupByKeys describes the attribute names that are going to be used for grouping. // Empty value is allowed, since processor in such case can compact data GroupByKeys []string `mapstructure:"keys"` + + // prevent unkeyed literal initialization + _ struct{} } diff --git a/processor/k8sattributesprocessor/config.go b/processor/k8sattributesprocessor/config.go index d75b308b624cb..366674cd2d9cc 100644 --- a/processor/k8sattributesprocessor/config.go +++ b/processor/k8sattributesprocessor/config.go @@ -294,16 +294,25 @@ type PodAssociationConfig struct { // List of pod association sources which should be taken // to identify pod Sources []PodAssociationSourceConfig `mapstructure:"sources"` + + // prevent unkeyed literal initialization + _ struct{} } // ExcludeConfig represent a list of Pods to exclude type ExcludeConfig struct { Pods []ExcludePodConfig `mapstructure:"pods"` + + // prevent unkeyed literal initialization + _ struct{} } // ExcludePodConfig represent a Pod name to ignore type ExcludePodConfig struct { Name string `mapstructure:"name"` + + // prevent unkeyed literal initialization + _ struct{} } type PodAssociationSourceConfig struct { @@ -314,4 +323,7 @@ type PodAssociationSourceConfig struct { // Name represents extracted key name. // e.g. ip, pod_uid, k8s.pod.ip Name string `mapstructure:"name"` + + // prevent unkeyed literal initialization + _ struct{} } diff --git a/processor/metricsgenerationprocessor/config.go b/processor/metricsgenerationprocessor/config.go index 509df3b319c77..f937427cafb8a 100644 --- a/processor/metricsgenerationprocessor/config.go +++ b/processor/metricsgenerationprocessor/config.go @@ -32,6 +32,9 @@ const ( type Config struct { // Set of rules for generating new metrics Rules []Rule `mapstructure:"rules"` + + // prevent unkeyed literal initialization + _ struct{} } type Rule struct { diff --git a/processor/metricstransformprocessor/config.go b/processor/metricstransformprocessor/config.go index d86493b97a281..40da0467d4a3d 100644 --- a/processor/metricstransformprocessor/config.go +++ b/processor/metricstransformprocessor/config.go @@ -44,6 +44,9 @@ const ( type Config struct { // transform specifies a list of transforms on metrics with each transform focusing on one metric. Transforms []transform `mapstructure:"transforms"` + + // prevent unkeyed literal initialization + _ struct{} } // transform defines the transformation applied to the specific metric @@ -94,6 +97,9 @@ type FilterConfig struct { // MatchLabels specifies the label set against which the metric filter will work. // This field is optional. MatchLabels map[string]string `mapstructure:"experimental_match_labels"` + + // prevent unkeyed literal initialization + _ struct{} } // Operation defines the specific operation performed on the selected metrics. @@ -137,6 +143,9 @@ type ValueAction struct { // NewValue specifies the label value to rename to. NewValue string `mapstructure:"new_value"` + + // prevent unkeyed literal initialization + _ struct{} } // ConfigAction is the enum to capture the type of action to perform on a metric. diff --git a/processor/remotetapprocessor/config.go b/processor/remotetapprocessor/config.go index a2ef221c3caf7..0274a4748e966 100644 --- a/processor/remotetapprocessor/config.go +++ b/processor/remotetapprocessor/config.go @@ -19,6 +19,9 @@ type Config struct { // Limit is a float that indicates the maximum number of messages repeated // through the websocket by this processor in messages per second. Defaults to 1. Limit rate.Limit `mapstructure:"limit"` + + // prevent unkeyed literal initialization + _ struct{} } func createDefaultConfig() component.Config { diff --git a/processor/resourceprocessor/config.go b/processor/resourceprocessor/config.go index 6620709863db7..64d9d8830fe2d 100644 --- a/processor/resourceprocessor/config.go +++ b/processor/resourceprocessor/config.go @@ -16,6 +16,9 @@ type Config struct { // AttributesActions specifies the list of actions to be applied on resource attributes. // The set of actions are {INSERT, UPDATE, UPSERT, DELETE, HASH, EXTRACT}. AttributesActions []attraction.ActionKeyValue `mapstructure:"attributes"` + + // prevent unkeyed literal initialization + _ struct{} } var _ component.Config = (*Config)(nil) diff --git a/receiver/apachereceiver/config.go b/receiver/apachereceiver/config.go index 119df95765645..132b441de6926 100644 --- a/receiver/apachereceiver/config.go +++ b/receiver/apachereceiver/config.go @@ -17,6 +17,9 @@ type Config struct { scraperhelper.ControllerConfig `mapstructure:",squash"` confighttp.ClientConfig `mapstructure:",squash"` MetricsBuilderConfig metadata.MetricsBuilderConfig `mapstructure:",squash"` + + // prevent unkeyed literal initialization + _ struct{} } var ( diff --git a/receiver/apachesparkreceiver/config.go b/receiver/apachesparkreceiver/config.go index 1ca1abc224e33..13da4115fe32e 100644 --- a/receiver/apachesparkreceiver/config.go +++ b/receiver/apachesparkreceiver/config.go @@ -27,6 +27,9 @@ type Config struct { metadata.MetricsBuilderConfig `mapstructure:",squash"` confighttp.ClientConfig `mapstructure:",squash"` ApplicationNames []string `mapstructure:"application_names"` + + // prevent unkeyed literal initialization + _ struct{} } // Validate validates missing and invalid configuration fields. diff --git a/receiver/awscloudwatchmetricsreceiver/config.go b/receiver/awscloudwatchmetricsreceiver/config.go index 46d88d49f47b5..da0e3b3d68d10 100644 --- a/receiver/awscloudwatchmetricsreceiver/config.go +++ b/receiver/awscloudwatchmetricsreceiver/config.go @@ -20,12 +20,18 @@ type Config struct { IMDSEndpoint string `mapstructure:"imds_endpoint"` PollInterval time.Duration `mapstructure:"poll_interval"` Metrics *MetricsConfig `mapstructure:"metrics"` + + // prevent unkeyed literal initialization + _ struct{} } // MetricsConfig is the configuration for the metrics part of the receiver // added this so we could expand to other inputs such as autodiscover type MetricsConfig struct { Names []*NamedConfig `mapstructure:"named"` + + // prevent unkeyed literal initialization + _ struct{} } // NamesConfig is the configuration for the metric namespace and metric names @@ -42,6 +48,9 @@ type NamedConfig struct { type MetricDimensionsConfig struct { Name string `mapstructure:"Name"` Value string `mapstructure:"Value"` + + // prevent unkeyed literal initialization + _ struct{} } var ( diff --git a/receiver/awsecscontainermetricsreceiver/config.go b/receiver/awsecscontainermetricsreceiver/config.go index c0b93e21c4183..b64d8bc279181 100644 --- a/receiver/awsecscontainermetricsreceiver/config.go +++ b/receiver/awsecscontainermetricsreceiver/config.go @@ -11,4 +11,7 @@ import ( type Config struct { // CollectionInterval is the interval at which metrics should be collected CollectionInterval time.Duration `mapstructure:"collection_interval"` + + // prevent unkeyed literal initialization + _ struct{} } diff --git a/receiver/awss3receiver/config.go b/receiver/awss3receiver/config.go index cb941a2bdbf95..2013cf9c6693c 100644 --- a/receiver/awss3receiver/config.go +++ b/receiver/awss3receiver/config.go @@ -45,12 +45,18 @@ type SQSConfig struct { // Notifications groups optional notification sources. type Notifications struct { OpAMP *component.ID `mapstructure:"opampextension"` + + // prevent unkeyed literal initialization + _ struct{} } // Encoding defines the encoding configuration for the file receiver. type Encoding struct { Extension component.ID `mapstructure:"extension"` Suffix string `mapstructure:"suffix"` + + // prevent unkeyed literal initialization + _ struct{} } // Config defines the configuration for the file receiver. diff --git a/receiver/awsxrayreceiver/config.go b/receiver/awsxrayreceiver/config.go index d458ac3243a97..ec10f7af83f1f 100644 --- a/receiver/awsxrayreceiver/config.go +++ b/receiver/awsxrayreceiver/config.go @@ -18,4 +18,7 @@ type Config struct { // ProxyServer defines configurations related to the local TCP proxy server. ProxyServer *proxy.Config `mapstructure:"proxy_server"` + + // prevent unkeyed literal initialization + _ struct{} } diff --git a/receiver/azuremonitorreceiver/config.go b/receiver/azuremonitorreceiver/config.go index beaafc9affbe0..01c66ff3e5c4b 100644 --- a/receiver/azuremonitorreceiver/config.go +++ b/receiver/azuremonitorreceiver/config.go @@ -273,6 +273,8 @@ type AuthConfig struct { // AuthenticatorID specifies the name of the azure extension to authenticate the // requests to azure monitor. AuthenticatorID component.ID `mapstructure:"authenticator,omitempty"` + // prevent unkeyed literal initialization + _ struct{} } const ( diff --git a/receiver/chronyreceiver/config.go b/receiver/chronyreceiver/config.go index 280379519d2a5..f46a1f40de4af 100644 --- a/receiver/chronyreceiver/config.go +++ b/receiver/chronyreceiver/config.go @@ -26,6 +26,9 @@ type Config struct { // // The default value is unix:///var/run/chrony/chronyd.sock Endpoint string `mapstructure:"endpoint"` + + // prevent unkeyed literal initialization + _ struct{} } var ( diff --git a/receiver/cloudflarereceiver/config.go b/receiver/cloudflarereceiver/config.go index 59ef966c0d75c..23c81c32fd14a 100644 --- a/receiver/cloudflarereceiver/config.go +++ b/receiver/cloudflarereceiver/config.go @@ -15,6 +15,9 @@ import ( // Config holds all the parameters to start an HTTP server that can be sent logs from CloudFlare type Config struct { Logs LogsConfig `mapstructure:"logs"` + + // prevent unkeyed literal initialization + _ struct{} } type LogsConfig struct { @@ -23,6 +26,9 @@ type LogsConfig struct { TLS *configtls.ServerConfig `mapstructure:"tls"` Attributes map[string]string `mapstructure:"attributes"` TimestampField string `mapstructure:"timestamp_field"` + + // prevent unkeyed literal initialization + _ struct{} } var ( diff --git a/receiver/cloudfoundryreceiver/config.go b/receiver/cloudfoundryreceiver/config.go index ed38825c2ad51..44183abcb3d2a 100644 --- a/receiver/cloudfoundryreceiver/config.go +++ b/receiver/cloudfoundryreceiver/config.go @@ -16,11 +16,17 @@ import ( type RLPGatewayConfig struct { confighttp.ClientConfig `mapstructure:",squash"` ShardID string `mapstructure:"shard_id"` + + // prevent unkeyed literal initialization + _ struct{} } // LimitedTLSClientSetting is a subset of TLSClientSetting, see LimitedClientConfig for more details type LimitedTLSClientSetting struct { InsecureSkipVerify bool `mapstructure:"insecure_skip_verify"` + + // prevent unkeyed literal initialization + _ struct{} } // LimitedClientConfig is a subset of ClientConfig, implemented as a separate type due to the library this @@ -28,18 +34,27 @@ type LimitedTLSClientSetting struct { type LimitedClientConfig struct { Endpoint string `mapstructure:"endpoint"` TLSSetting LimitedTLSClientSetting `mapstructure:"tls"` + + // prevent unkeyed literal initialization + _ struct{} } type UAAConfig struct { LimitedClientConfig `mapstructure:",squash"` Username string `mapstructure:"username"` Password configopaque.String `mapstructure:"password"` + + // prevent unkeyed literal initialization + _ struct{} } // Config defines configuration for Collectd receiver. type Config struct { RLPGateway RLPGatewayConfig `mapstructure:"rlp_gateway"` UAA UAAConfig `mapstructure:"uaa"` + + // prevent unkeyed literal initialization + _ struct{} } func (c *Config) Validate() error { diff --git a/receiver/datadogreceiver/config.go b/receiver/datadogreceiver/config.go index efeafcda77a39..76c6ddef941bc 100644 --- a/receiver/datadogreceiver/config.go +++ b/receiver/datadogreceiver/config.go @@ -25,4 +25,7 @@ type Config struct { ReadTimeout time.Duration `mapstructure:"read_timeout"` // TraceIDCacheSize sets the cache size for the 64 bits to 128 bits mapping TraceIDCacheSize int `mapstructure:"trace_id_cache_size"` + + // prevent unkeyed literal initialization + _ struct{} } diff --git a/receiver/filelogreceiver/filelog.go b/receiver/filelogreceiver/filelog.go index 8889ab9960935..d36e51c626f14 100644 --- a/receiver/filelogreceiver/filelog.go +++ b/receiver/filelogreceiver/filelog.go @@ -52,6 +52,9 @@ func (f ReceiverType) BaseConfig(cfg component.Config) adapter.BaseConfig { type FileLogConfig struct { InputConfig file.Config `mapstructure:",squash"` adapter.BaseConfig `mapstructure:",squash"` + + // prevent unkeyed literal initialization + _ struct{} } // InputConfig unmarshals the input operator diff --git a/receiver/filestatsreceiver/config.go b/receiver/filestatsreceiver/config.go index 3de02c58cf604..ad94dbb8585a8 100644 --- a/receiver/filestatsreceiver/config.go +++ b/receiver/filestatsreceiver/config.go @@ -15,6 +15,9 @@ type Config struct { scraperhelper.ControllerConfig `mapstructure:",squash"` metadata.MetricsBuilderConfig `mapstructure:",squash"` Include string `mapstructure:"include"` + + // prevent unkeyed literal initialization + _ struct{} } func (c Config) Validate() error { diff --git a/receiver/fluentforwardreceiver/config.go b/receiver/fluentforwardreceiver/config.go index 6ebd513ed1903..f4caf21c022de 100644 --- a/receiver/fluentforwardreceiver/config.go +++ b/receiver/fluentforwardreceiver/config.go @@ -9,4 +9,7 @@ type Config struct { // of the form `:` (TCP) or `unix://` (Unix // domain socket). ListenAddress string `mapstructure:"endpoint"` + + // prevent unkeyed literal initialization + _ struct{} } diff --git a/receiver/gitlabreceiver/config.go b/receiver/gitlabreceiver/config.go index f94ffaef0a5ff..8d92ca46b8265 100644 --- a/receiver/gitlabreceiver/config.go +++ b/receiver/gitlabreceiver/config.go @@ -45,6 +45,9 @@ var ( // Config that is exposed to this gitlab receiver through the OTEL config.yaml type Config struct { WebHook WebHook `mapstructure:"webhook"` + + // prevent unkeyed literal initialization + _ struct{} } type WebHook struct { @@ -62,6 +65,9 @@ type WebHook struct { type GitlabHeaders struct { Customizable map[string]string `mapstructure:","` // can be overwritten via required_headers Fixed map[string]string `mapstructure:","` // are not allowed to be overwritten + + // prevent unkeyed literal initialization + _ struct{} } func createDefaultConfig() component.Config { diff --git a/receiver/httpcheckreceiver/config.go b/receiver/httpcheckreceiver/config.go index 3a3700ff9b428..3f0937f5d9c1b 100644 --- a/receiver/httpcheckreceiver/config.go +++ b/receiver/httpcheckreceiver/config.go @@ -26,6 +26,9 @@ type Config struct { scraperhelper.ControllerConfig `mapstructure:",squash"` metadata.MetricsBuilderConfig `mapstructure:",squash"` Targets []*targetConfig `mapstructure:"targets"` + + // prevent unkeyed literal initialization + _ struct{} } // targetConfig defines configuration for individual HTTP checks. diff --git a/receiver/jaegerreceiver/config.go b/receiver/jaegerreceiver/config.go index adb5b087778ae..03e620fb98b68 100644 --- a/receiver/jaegerreceiver/config.go +++ b/receiver/jaegerreceiver/config.go @@ -33,6 +33,9 @@ type RemoteSamplingConfig struct { StrategyFile string `mapstructure:"strategy_file"` StrategyFileReloadInterval time.Duration `mapstructure:"strategy_file_reload_interval"` configgrpc.ClientConfig `mapstructure:",squash"` + + // prevent unkeyed literal initialization + _ struct{} } // Protocols is the configuration for the supported protocols. @@ -41,12 +44,18 @@ type Protocols struct { ThriftHTTP *confighttp.ServerConfig `mapstructure:"thrift_http"` ThriftBinaryUDP *ProtocolUDP `mapstructure:"thrift_binary"` ThriftCompactUDP *ProtocolUDP `mapstructure:"thrift_compact"` + + // prevent unkeyed literal initialization + _ struct{} } // ProtocolUDP is the configuration for a UDP protocol. type ProtocolUDP struct { Endpoint string `mapstructure:"endpoint"` ServerConfigUDP `mapstructure:",squash"` + + // prevent unkeyed literal initialization + _ struct{} } // ServerConfigUDP is the server configuration for a UDP protocol. @@ -55,6 +64,9 @@ type ServerConfigUDP struct { MaxPacketSize int `mapstructure:"max_packet_size"` Workers int `mapstructure:"workers"` SocketBufferSize int `mapstructure:"socket_buffer_size"` + + // prevent unkeyed literal initialization + _ struct{} } // defaultServerConfigUDP creates the default ServerConfigUDP. @@ -71,6 +83,9 @@ func defaultServerConfigUDP() ServerConfigUDP { type Config struct { Protocols `mapstructure:"protocols"` RemoteSampling *RemoteSamplingConfig `mapstructure:"remote_sampling"` + + // prevent unkeyed literal initialization + _ struct{} } var ( diff --git a/receiver/journaldreceiver/config.go b/receiver/journaldreceiver/config.go index dec38676fe4e2..ff440f8784acb 100644 --- a/receiver/journaldreceiver/config.go +++ b/receiver/journaldreceiver/config.go @@ -42,6 +42,9 @@ func (f ReceiverType) BaseConfig(cfg component.Config) adapter.BaseConfig { type JournaldConfig struct { adapter.BaseConfig `mapstructure:",squash"` InputConfig journald.Config `mapstructure:",squash"` + + // prevent unkeyed literal initialization + _ struct{} } // InputConfig unmarshals the input operator diff --git a/receiver/libhoneyreceiver/config.go b/receiver/libhoneyreceiver/config.go index 234803bc08716..59aedc545bbe3 100644 --- a/receiver/libhoneyreceiver/config.go +++ b/receiver/libhoneyreceiver/config.go @@ -22,6 +22,9 @@ type Config struct { AuthAPI string `mapstructure:"auth_api"` Wrapper string `mapstructure:"wrapper"` FieldMapConfig libhoneyevent.FieldMapConfig `mapstructure:"fields"` + + // prevent unkeyed literal initialization + _ struct{} } // HTTPConfig defines the configuration for the HTTP server receiving traces. @@ -30,6 +33,9 @@ type HTTPConfig struct { // The URL path to receive traces on. If omitted "/" will be used. TracesURLPaths []string `mapstructure:"traces_url_paths,omitempty"` + + // prevent unkeyed literal initialization + _ struct{} } // Validate ensures the HTTP configuration is set. diff --git a/receiver/libhoneyreceiver/receiver.go b/receiver/libhoneyreceiver/receiver.go index 728ce13b59d43..675504ceef18f 100644 --- a/receiver/libhoneyreceiver/receiver.go +++ b/receiver/libhoneyreceiver/receiver.go @@ -43,12 +43,18 @@ type libhoneyReceiver struct { // TeamInfo is part of the AuthInfo struct that stores the team slug type TeamInfo struct { Slug string `json:"slug"` + + // prevent unkeyed literal initialization + _ struct{} } // EnvironmentInfo is part of the AuthInfo struct that stores the environment slug and name type EnvironmentInfo struct { Slug string `json:"slug"` Name string `json:"name"` + + // prevent unkeyed literal initialization + _ struct{} } // AuthInfo is used by Libhoney to validate team and environment information against Honeycomb's Auth API @@ -56,6 +62,9 @@ type AuthInfo struct { APIKeyAccess map[string]bool `json:"api_key_access"` Team TeamInfo `json:"team"` Environment EnvironmentInfo `json:"environment"` + + // prevent unkeyed literal initialization + _ struct{} } func newLibhoneyReceiver(cfg *Config, set *receiver.Settings) (*libhoneyReceiver, error) { diff --git a/receiver/lokireceiver/config.go b/receiver/lokireceiver/config.go index 48f280fa314df..4033e7e9b5d2f 100644 --- a/receiver/lokireceiver/config.go +++ b/receiver/lokireceiver/config.go @@ -22,6 +22,9 @@ const ( type Protocols struct { GRPC *configgrpc.ServerConfig `mapstructure:"grpc"` HTTP *confighttp.ServerConfig `mapstructure:"http"` + + // prevent unkeyed literal initialization + _ struct{} } // Config defines configuration for the lokireceiver receiver. @@ -29,6 +32,9 @@ type Config struct { // Protocols is the configuration for the supported protocols, currently gRPC and HTTP (Proto and JSON). Protocols `mapstructure:"protocols"` KeepTimestamp bool `mapstructure:"use_incoming_timestamp"` + + // prevent unkeyed literal initialization + _ struct{} } var ( diff --git a/receiver/mongodbatlasreceiver/config.go b/receiver/mongodbatlasreceiver/config.go index d0cdc2e7104a1..9c5b17106167c 100644 --- a/receiver/mongodbatlasreceiver/config.go +++ b/receiver/mongodbatlasreceiver/config.go @@ -55,6 +55,9 @@ type AlertConfig struct { type LogConfig struct { Enabled bool `mapstructure:"enabled"` Projects []*LogsProjectConfig `mapstructure:"projects"` + + // prevent unkeyed literal initialization + _ struct{} } // EventsConfig is the configuration options for events collection @@ -73,6 +76,9 @@ type LogsProjectConfig struct { EnableAuditLogs bool `mapstructure:"collect_audit_logs"` EnableHostLogs *bool `mapstructure:"collect_host_logs"` AccessLogs *AccessLogsConfig `mapstructure:"access_logs"` + + // prevent unkeyed literal initialization + _ struct{} } type AccessLogsConfig struct { @@ -98,6 +104,9 @@ type ProjectConfig struct { type OrgConfig struct { ID string `mapstructure:"id"` + + // prevent unkeyed literal initialization + _ struct{} } func (pc *ProjectConfig) populateIncludesAndExcludes() { diff --git a/receiver/namedpipereceiver/namedpipe.go b/receiver/namedpipereceiver/namedpipe.go index b81ea71ec31e5..5c1b8b0e34a3c 100644 --- a/receiver/namedpipereceiver/namedpipe.go +++ b/receiver/namedpipereceiver/namedpipe.go @@ -54,6 +54,9 @@ func (f ReceiverType) BaseConfig(cfg component.Config) adapter.BaseConfig { type NamedPipeConfig struct { InputConfig namedpipe.Config `mapstructure:",squash"` adapter.BaseConfig `mapstructure:",squash"` + + // prevent unkeyed literal initialization + _ struct{} } // InputConfig unmarshals the input operator diff --git a/receiver/nginxreceiver/config.go b/receiver/nginxreceiver/config.go index d9e10d1ca3adb..7df980075661c 100644 --- a/receiver/nginxreceiver/config.go +++ b/receiver/nginxreceiver/config.go @@ -14,4 +14,7 @@ type Config struct { scraperhelper.ControllerConfig `mapstructure:",squash"` confighttp.ClientConfig `mapstructure:",squash"` MetricsBuilderConfig metadata.MetricsBuilderConfig `mapstructure:",squash"` + + // prevent unkeyed literal initialization + _ struct{} } diff --git a/receiver/opencensusreceiver/config.go b/receiver/opencensusreceiver/config.go index 33d0c601f4644..1a2bfc0730c78 100644 --- a/receiver/opencensusreceiver/config.go +++ b/receiver/opencensusreceiver/config.go @@ -18,6 +18,9 @@ type Config struct { // An empty list means that CORS is not enabled at all. A wildcard (*) can be // used to match any origin or one or more characters of an origin. CorsOrigins []string `mapstructure:"cors_allowed_origins"` + + // prevent unkeyed literal initialization + _ struct{} } func (cfg *Config) buildOptions() []ocOption { diff --git a/receiver/otelarrowreceiver/config.go b/receiver/otelarrowreceiver/config.go index 662c3ed6ea92d..60888c0a3e7a5 100644 --- a/receiver/otelarrowreceiver/config.go +++ b/receiver/otelarrowreceiver/config.go @@ -18,6 +18,9 @@ import ( type Protocols struct { GRPC configgrpc.ServerConfig `mapstructure:"grpc"` Arrow ArrowConfig `mapstructure:"arrow"` + + // prevent unkeyed literal initialization + _ struct{} } type AdmissionConfig struct { @@ -30,6 +33,9 @@ type AdmissionConfig struct { // This is a dimension of memory limiting to ensure waiters are not consuming an // unexpectedly large amount of memory in the arrow receiver. WaitingLimitMiB uint64 `mapstructure:"waiting_limit_mib"` + + // prevent unkeyed literal initialization + _ struct{} } // ArrowConfig support configuring the Arrow receiver. @@ -47,6 +53,9 @@ type ArrowConfig struct { // Zstd settings apply to OTel-Arrow use of gRPC specifically. Zstd zstd.DecoderConfig `mapstructure:"zstd"` + + // prevent unkeyed literal initialization + _ struct{} } // Config defines configuration for OTel Arrow receiver. @@ -55,6 +64,9 @@ type Config struct { Protocols `mapstructure:"protocols"` // Admission is the configuration for controlling amount of request memory entering the receiver. Admission AdmissionConfig `mapstructure:"admission"` + + // prevent unkeyed literal initialization + _ struct{} } var ( diff --git a/receiver/purefareceiver/config.go b/receiver/purefareceiver/config.go index 1bde48af1fb83..45c8bace86fa4 100644 --- a/receiver/purefareceiver/config.go +++ b/receiver/purefareceiver/config.go @@ -50,6 +50,9 @@ type Config struct { type Settings struct { ReloadIntervals *ReloadIntervals `mapstructure:"reload_intervals"` + + // prevent unkeyed literal initialization + _ struct{} } type ReloadIntervals struct { @@ -58,6 +61,9 @@ type ReloadIntervals struct { Directories time.Duration `mapstructure:"directories"` Pods time.Duration `mapstructure:"pods"` Volumes time.Duration `mapstructure:"volumes"` + + // prevent unkeyed literal initialization + _ struct{} } func (c *Config) Validate() error { diff --git a/receiver/purefbreceiver/config.go b/receiver/purefbreceiver/config.go index 5e6ce50d35aa2..bc73337ca2e81 100644 --- a/receiver/purefbreceiver/config.go +++ b/receiver/purefbreceiver/config.go @@ -38,12 +38,18 @@ type Config struct { type Settings struct { ReloadIntervals *ReloadIntervals `mapstructure:"reload_intervals"` + + // prevent unkeyed literal initialization + _ struct{} } type ReloadIntervals struct { Array time.Duration `mapstructure:"array"` Clients time.Duration `mapstructure:"clients"` Usage time.Duration `mapstructure:"usage"` + + // prevent unkeyed literal initialization + _ struct{} } func (c *Config) Validate() error { diff --git a/receiver/snmpreceiver/config.go b/receiver/snmpreceiver/config.go index d7c9992672d19..ed39fd126ce62 100644 --- a/receiver/snmpreceiver/config.go +++ b/receiver/snmpreceiver/config.go @@ -152,6 +152,9 @@ type ResourceAttributeConfig struct { // as an attribute on that resource. The related indexed metric values will then be used to associate metric datapoints to // those resources. IndexedValuePrefix string `mapstructure:"indexed_value_prefix"` // required and valid if no oid or scalar_oid field + + // prevent unkeyed literal initialization + _ struct{} } // AttributeConfig contains config info about all of the metric attributes that will be used by this receiver. @@ -192,6 +195,9 @@ type MetricConfig struct { type GaugeMetric struct { // ValueType is required and can be either int or double ValueType string `mapstructure:"value_type"` + + // prevent unkeyed literal initialization + _ struct{} } // SumMetric contains info about the value of the sum metric @@ -202,6 +208,9 @@ type SumMetric struct { Monotonic bool `mapstructure:"monotonic"` // ValueType is required and can be either int or double ValueType string `mapstructure:"value_type"` + + // prevent unkeyed literal initialization + _ struct{} } // ScalarOID holds OID info for a scalar metric as well as any {resource} attributes @@ -214,6 +223,9 @@ type ScalarOID struct { // Attributes is optional and may contain names and values associated with enum // AttributeConfigs to associate with the value of the scalar OID Attributes []Attribute `mapstructure:"attributes"` + + // prevent unkeyed literal initialization + _ struct{} } // ColumnOID holds OID info for an indexed metric as well as any attributes diff --git a/receiver/solacereceiver/config.go b/receiver/solacereceiver/config.go index ceae502ecde72..739453ecdbb2f 100644 --- a/receiver/solacereceiver/config.go +++ b/receiver/solacereceiver/config.go @@ -79,18 +79,27 @@ type Authentication struct { PlainText *SaslPlainTextConfig `mapstructure:"sasl_plain"` XAuth2 *SaslXAuth2Config `mapstructure:"sasl_xauth2"` External *SaslExternalConfig `mapstructure:"sasl_external"` + + // prevent unkeyed literal initialization + _ struct{} } // SaslPlainTextConfig defines SASL PLAIN authentication. type SaslPlainTextConfig struct { Username string `mapstructure:"username"` Password configopaque.String `mapstructure:"password"` + + // prevent unkeyed literal initialization + _ struct{} } // SaslXAuth2Config defines the configuration for the SASL XAUTH2 authentication. type SaslXAuth2Config struct { Username string `mapstructure:"username"` Bearer string `mapstructure:"bearer"` + + // prevent unkeyed literal initialization + _ struct{} } // SaslExternalConfig defines the configuration for the SASL External used in conjunction with TLS client authentication. @@ -99,9 +108,15 @@ type SaslExternalConfig struct{} // FlowControl defines the configuration for what to do in backpressure scenarios, e.g. memorylimiter errors type FlowControl struct { DelayedRetry *FlowControlDelayedRetry `mapstructure:"delayed_retry"` + + // prevent unkeyed literal initialization + _ struct{} } // FlowControlDelayedRetry represents the strategy of waiting for a defined amount of time (in time.Duration) and attempt redelivery type FlowControlDelayedRetry struct { Delay time.Duration `mapstructure:"delay"` + + // prevent unkeyed literal initialization + _ struct{} } diff --git a/receiver/solacereceiver/config_test.go b/receiver/solacereceiver/config_test.go index 08fadf7c43303..66ba3d6a1ce5e 100644 --- a/receiver/solacereceiver/config_test.go +++ b/receiver/solacereceiver/config_test.go @@ -91,15 +91,15 @@ func TestConfigValidateMissingAuth(t *testing.T) { func TestConfigValidateMultipleAuth(t *testing.T) { cfg := createDefaultConfig().(*Config) cfg.Queue = "someQueue" - cfg.Auth.PlainText = &SaslPlainTextConfig{"Username", "Password"} - cfg.Auth.XAuth2 = &SaslXAuth2Config{"Username", "Bearer"} + cfg.Auth.PlainText = &SaslPlainTextConfig{Username: "Username", Password: "Password"} + cfg.Auth.XAuth2 = &SaslXAuth2Config{Username: "Username", Bearer: "Bearer"} err := xconfmap.Validate(cfg) assert.ErrorContains(t, err, errTooManyAuthDetails.Error()) } func TestConfigValidateMissingQueue(t *testing.T) { cfg := createDefaultConfig().(*Config) - cfg.Auth.PlainText = &SaslPlainTextConfig{"Username", "Password"} + cfg.Auth.PlainText = &SaslPlainTextConfig{Username: "Username", Password: "Password"} err := xconfmap.Validate(cfg) assert.ErrorContains(t, err, errMissingQueueName.Error()) } @@ -107,7 +107,7 @@ func TestConfigValidateMissingQueue(t *testing.T) { func TestConfigValidateMissingFlowControl(t *testing.T) { cfg := createDefaultConfig().(*Config) cfg.Queue = "someQueue" - cfg.Auth.PlainText = &SaslPlainTextConfig{"Username", "Password"} + cfg.Auth.PlainText = &SaslPlainTextConfig{Username: "Username", Password: "Password"} // this should never happen in reality, test validation anyway cfg.Flow.DelayedRetry = nil err := cfg.Validate() @@ -117,7 +117,7 @@ func TestConfigValidateMissingFlowControl(t *testing.T) { func TestConfigValidateInvalidFlowControlDelayedRetryDelay(t *testing.T) { cfg := createDefaultConfig().(*Config) cfg.Queue = "someQueue" - cfg.Auth.PlainText = &SaslPlainTextConfig{"Username", "Password"} + cfg.Auth.PlainText = &SaslPlainTextConfig{Username: "Username", Password: "Password"} cfg.Flow.DelayedRetry = &FlowControlDelayedRetry{ Delay: -30 * time.Second, } @@ -128,7 +128,7 @@ func TestConfigValidateInvalidFlowControlDelayedRetryDelay(t *testing.T) { func TestConfigValidateSuccess(t *testing.T) { successCases := map[string]func(*Config){ "With Plaintext Auth": func(c *Config) { - c.Auth.PlainText = &SaslPlainTextConfig{"Username", "Password"} + c.Auth.PlainText = &SaslPlainTextConfig{Username: "Username", Password: "Password"} }, "With XAuth2 Auth": func(c *Config) { c.Auth.XAuth2 = &SaslXAuth2Config{ diff --git a/receiver/sqlqueryreceiver/config.go b/receiver/sqlqueryreceiver/config.go index 680c3f31ac1ae..80afea8cac22b 100644 --- a/receiver/sqlqueryreceiver/config.go +++ b/receiver/sqlqueryreceiver/config.go @@ -16,6 +16,9 @@ type Config struct { sqlquery.Config `mapstructure:",squash"` // The maximumn number of open connections to the sql server. <= 0 means unlimited MaxOpenConn int `mapstructure:"max_open_conn"` + + // prevent unkeyed literal initialization + _ struct{} } func createDefaultConfig() component.Config { diff --git a/receiver/stefreceiver/config.go b/receiver/stefreceiver/config.go index 215c80af21199..89b87fe232d4c 100644 --- a/receiver/stefreceiver/config.go +++ b/receiver/stefreceiver/config.go @@ -13,6 +13,9 @@ import ( type Config struct { configgrpc.ServerConfig `mapstructure:",squash"` AckInterval time.Duration `mapstructure:"ack_interval"` + + // prevent unkeyed literal initialization + _ struct{} } func (c *Config) Validate() error { diff --git a/receiver/syslogreceiver/syslog.go b/receiver/syslogreceiver/syslog.go index c71d11cf07f11..bc63f076d24f1 100644 --- a/receiver/syslogreceiver/syslog.go +++ b/receiver/syslogreceiver/syslog.go @@ -51,6 +51,9 @@ func (f ReceiverType) BaseConfig(cfg component.Config) adapter.BaseConfig { type SysLogConfig struct { InputConfig syslog.Config `mapstructure:",squash"` adapter.BaseConfig `mapstructure:",squash"` + + // prevent unkeyed literal initialization + _ struct{} } // InputConfig unmarshals the input operator diff --git a/receiver/tcpcheckreceiver/config.go b/receiver/tcpcheckreceiver/config.go index b72ac8bd2fcc2..56a5809c5c797 100644 --- a/receiver/tcpcheckreceiver/config.go +++ b/receiver/tcpcheckreceiver/config.go @@ -29,6 +29,9 @@ type Config struct { scraperhelper.ControllerConfig `mapstructure:",squash"` metadata.MetricsBuilderConfig `mapstructure:",squash"` Targets []*confignet.TCPAddrConfig `mapstructure:"targets"` + + // prevent unkeyed literal initialization + _ struct{} } func validatePort(port string) error { diff --git a/receiver/tcplogreceiver/tcp.go b/receiver/tcplogreceiver/tcp.go index c5e571c3d9b48..fcb01092a53ff 100644 --- a/receiver/tcplogreceiver/tcp.go +++ b/receiver/tcplogreceiver/tcp.go @@ -46,6 +46,9 @@ func (f ReceiverType) BaseConfig(cfg component.Config) adapter.BaseConfig { type TCPLogConfig struct { InputConfig tcp.Config `mapstructure:",squash"` adapter.BaseConfig `mapstructure:",squash"` + + // prevent unkeyed literal initialization + _ struct{} } // InputConfig unmarshals the input operator diff --git a/receiver/tlscheckreceiver/config.go b/receiver/tlscheckreceiver/config.go index 55659fea02b48..19e28f7b90593 100644 --- a/receiver/tlscheckreceiver/config.go +++ b/receiver/tlscheckreceiver/config.go @@ -27,6 +27,9 @@ var errInvalidEndpoint = errors.New(`"endpoint" must be in the form of