Skip to content

Commit 23379a6

Browse files
[chore] apply unkeyed literal initialization prevention
1 parent 0658f77 commit 23379a6

File tree

66 files changed

+364
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+364
-0
lines changed

.checkapi.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ ignored_functions:
6767
- ^Test.*
6868
- ^Benchmark.*
6969
- ^Fuzz.*
70+
71+
unkeyed_literal_initialization:
72+
enabled: true
73+
limit: 1 # this limit will increase over time to 5.

connector/datadogconnector/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ var _ component.Config = (*Config)(nil)
1515
type Config struct {
1616
// Traces defines the Traces specific configuration
1717
Traces datadogconfig.TracesConnectorConfig `mapstructure:"traces"`
18+
// prevent unkeyed literal initialization
19+
_ struct{}
1820
}
1921

2022
// Validate checks if the configuration is valid

connector/exceptionsconnector/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ import (
1313
type Dimension struct {
1414
Name string `mapstructure:"name"`
1515
Default *string `mapstructure:"default"`
16+
// prevent unkeyed literal initialization
17+
_ struct{}
1618
}
1719

1820
type Exemplars struct {
1921
Enabled bool `mapstructure:"enabled"`
22+
// prevent unkeyed literal initialization
23+
_ struct{}
2024
}
2125

2226
// Config defines the configuration options for exceptionsconnector

connector/servicegraphconnector/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,7 @@ type StoreConfig struct {
6262
MaxItems int `mapstructure:"max_items"`
6363
// TTL is the time to live for items in the store.
6464
TTL time.Duration `mapstructure:"ttl"`
65+
66+
// prevent unkeyed literal initialization
67+
_ struct{}
6568
}

connector/spanmetricsconnector/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,30 @@ type HistogramConfig struct {
107107
type ExemplarsConfig struct {
108108
Enabled bool `mapstructure:"enabled"`
109109
MaxPerDataPoint *int `mapstructure:"max_per_data_point"`
110+
// prevent unkeyed literal initialization
111+
_ struct{}
110112
}
111113

112114
type ExponentialHistogramConfig struct {
113115
MaxSize int32 `mapstructure:"max_size"`
116+
// prevent unkeyed literal initialization
117+
_ struct{}
114118
}
115119

116120
type ExplicitHistogramConfig struct {
117121
// Buckets is the list of durations representing explicit histogram buckets.
118122
Buckets []time.Duration `mapstructure:"buckets"`
123+
// prevent unkeyed literal initialization
124+
_ struct{}
119125
}
120126

121127
type EventsConfig struct {
122128
// Enabled is a flag to enable events.
123129
Enabled bool `mapstructure:"enabled"`
124130
// Dimensions defines the list of dimensions to add to the events metric.
125131
Dimensions []Dimension `mapstructure:"dimensions"`
132+
// prevent unkeyed literal initialization
133+
_ struct{}
126134
}
127135

128136
var _ xconfmap.Validator = (*Config)(nil)

exporter/awss3exporter/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ const (
7373
type ResourceAttrsToS3 struct {
7474
// S3Prefix indicates the mapping of the key (directory) prefix used for writing into the bucket to a specific resource attribute value.
7575
S3Prefix string `mapstructure:"s3_prefix"`
76+
// prevent unkeyed literal initialization
77+
_ struct{}
7678
}
7779

7880
// Config contains the main configuration options for the s3 exporter

exporter/cassandraexporter/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,19 @@ type Config struct {
2323
type Replication struct {
2424
Class string `mapstructure:"class"`
2525
ReplicationFactor int `mapstructure:"replication_factor"`
26+
// prevent unkeyed literal initialization
27+
_ struct{}
2628
}
2729

2830
type Compression struct {
2931
Algorithm string `mapstructure:"algorithm"`
32+
// prevent unkeyed literal initialization
33+
_ struct{}
3034
}
3135

3236
type Auth struct {
3337
UserName string `mapstructure:"username"`
3438
Password configopaque.String `mapstructure:"password"`
39+
// prevent unkeyed literal initialization
40+
_ struct{}
3541
}

exporter/elasticsearchexporter/config.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,27 +129,42 @@ type TelemetrySettings struct {
129129

130130
LogFailedDocsInput bool `mapstructure:"log_failed_docs_input"`
131131
LogFailedDocsInputRateLimit time.Duration `mapstructure:"log_failed_docs_input_rate_limit"`
132+
133+
// prevent unkeyed literal initialization
134+
_ struct{}
132135
}
133136

134137
type LogstashFormatSettings struct {
135138
Enabled bool `mapstructure:"enabled"`
136139
PrefixSeparator string `mapstructure:"prefix_separator"`
137140
DateFormat string `mapstructure:"date_format"`
141+
142+
// prevent unkeyed literal initialization
143+
_ struct{}
138144
}
139145

140146
type DynamicIndexSetting struct {
141147
// Enabled enables dynamic index routing.
142148
//
143149
// Deprecated: [v0.122.0] This config is now ignored. Dynamic index routing is always done by default.
144150
Enabled bool `mapstructure:"enabled"`
151+
152+
// prevent unkeyed literal initialization
153+
_ struct{}
145154
}
146155

147156
type DynamicIDSettings struct {
148157
Enabled bool `mapstructure:"enabled"`
158+
159+
// prevent unkeyed literal initialization
160+
_ struct{}
149161
}
150162

151163
type DynamicPipelineSettings struct {
152164
Enabled bool `mapstructure:"enabled"`
165+
166+
// prevent unkeyed literal initialization
167+
_ struct{}
153168
}
154169

155170
// AuthenticationSettings defines user authentication related settings.
@@ -164,6 +179,9 @@ type AuthenticationSettings struct {
164179
//
165180
// https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html
166181
APIKey configopaque.String `mapstructure:"api_key"`
182+
183+
// prevent unkeyed literal initialization
184+
_ struct{}
167185
}
168186

169187
// DiscoverySettings defines Elasticsearch node discovery related settings.
@@ -183,6 +201,9 @@ type DiscoverySettings struct {
183201
// Interval instructs the exporter to renew the list of Elasticsearch URLs
184202
// with the given interval. URLs will not be updated if Interval is <=0.
185203
Interval time.Duration `mapstructure:"interval"`
204+
205+
// prevent unkeyed literal initialization
206+
_ struct{}
186207
}
187208

188209
// FlushSettings defines settings for configuring the write buffer flushing
@@ -194,6 +215,9 @@ type FlushSettings struct {
194215

195216
// Interval configures the max age of a document in the send buffer.
196217
Interval time.Duration `mapstructure:"interval"`
218+
219+
// prevent unkeyed literal initialization
220+
_ struct{}
197221
}
198222

199223
// RetrySettings defines settings for the HTTP request retries in the Elasticsearch exporter.
@@ -235,6 +259,9 @@ type MappingsSettings struct {
235259
//
236260
// If unspecified, all mapping modes are allowed.
237261
AllowedModes []string `mapstructure:"allowed_modes"`
262+
263+
// prevent unkeyed literal initialization
264+
_ struct{}
238265
}
239266

240267
type MappingMode int

exporter/honeycombmarkerexporter/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ type Marker struct {
5656
type Rules struct {
5757
// LogConditions is the list of ottllog conditions that determine a match
5858
LogConditions []string `mapstructure:"log_conditions"`
59+
60+
// prevent unkeyed literal initialization
61+
_ struct{}
5962
}
6063

6164
var _ component.Config = (*Config)(nil)

exporter/loadbalancingexporter/config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ type Config struct {
5454
// Protocol holds the individual protocol-specific settings. Only OTLP is supported at the moment.
5555
type Protocol struct {
5656
OTLP otlpexporter.Config `mapstructure:"otlp"`
57+
// prevent unkeyed literal initialization
58+
_ struct{}
5759
}
5860

5961
// ResolverSettings defines the configurations for the backend resolver
@@ -62,11 +64,15 @@ type ResolverSettings struct {
6264
DNS *DNSResolver `mapstructure:"dns"`
6365
K8sSvc *K8sSvcResolver `mapstructure:"k8s"`
6466
AWSCloudMap *AWSCloudMapResolver `mapstructure:"aws_cloud_map"`
67+
// prevent unkeyed literal initialization
68+
_ struct{}
6569
}
6670

6771
// StaticResolver defines the configuration for the resolver providing a fixed list of backends
6872
type StaticResolver struct {
6973
Hostnames []string `mapstructure:"hostnames"`
74+
// prevent unkeyed literal initialization
75+
_ struct{}
7076
}
7177

7278
// DNSResolver defines the configuration for the DNS resolver
@@ -75,6 +81,8 @@ type DNSResolver struct {
7581
Port string `mapstructure:"port"`
7682
Interval time.Duration `mapstructure:"interval"`
7783
Timeout time.Duration `mapstructure:"timeout"`
84+
// prevent unkeyed literal initialization
85+
_ struct{}
7886
}
7987

8088
// K8sSvcResolver defines the configuration for the DNS resolver
@@ -83,6 +91,8 @@ type K8sSvcResolver struct {
8391
Ports []int32 `mapstructure:"ports"`
8492
Timeout time.Duration `mapstructure:"timeout"`
8593
ReturnHostnames bool `mapstructure:"return_hostnames"`
94+
// prevent unkeyed literal initialization
95+
_ struct{}
8696
}
8797

8898
type AWSCloudMapResolver struct {

0 commit comments

Comments
 (0)