Skip to content

Commit 829157c

Browse files
atoulmegithub-actions[bot]evan-bradleycodeboten
authored
[chore] add checkapi to tools (#12954)
Adds checkapi to the tools and a make target to run it. Fixes #12360 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Evan Bradley <[email protected]> Co-authored-by: Alex Boten <[email protected]>
1 parent 56c7da2 commit 829157c

File tree

15 files changed

+38
-0
lines changed

15 files changed

+38
-0
lines changed

.checkapi.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ignored_paths:
2+
- confmap/doc_test.go
3+
excluded_files:
4+
- example_*.go
5+
- "*_test.go"
6+
unkeyed_literal_initialization:
7+
enabled: true
8+
limit: 6

.github/workflows/build-and-test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ jobs:
111111
run: make misspell
112112
- name: checkdoc
113113
run: make checkdoc
114+
- name: checkapi
115+
run: make checkapi
114116
- name: Check for go mod dependency changes
115117
run: |
116118
make gotidy

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ certs:
315315
certs-dryrun:
316316
@internal/buildscripts/gen-certs.sh -d
317317

318+
.PHONY: checkapi
319+
checkapi: $(CHECKAPI)
320+
$(CHECKAPI) -folder . -config .checkapi.yaml
321+
318322
# Verify existence of READMEs for components specified as default components in the collector.
319323
.PHONY: checkdoc
320324
checkdoc: $(CHECKFILE)

Makefile.Common

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ JUNIT_OUT_DIR ?= $(TOOLS_MOD_DIR)/testresults
2626

2727
ADDLICENSE := $(TOOLS_BIN_DIR)/addlicense
2828
APIDIFF := $(TOOLS_BIN_DIR)/apidiff
29+
CHECKAPI := $(TOOLS_BIN_DIR)/checkapi
2930
CHECKFILE := $(TOOLS_BIN_DIR)/checkfile
3031
CHLOGGEN := $(TOOLS_BIN_DIR)/chloggen
3132
CROSSLINK := $(TOOLS_BIN_DIR)/crosslink

component/build_info.go

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ type BuildInfo struct {
1414

1515
// Version string.
1616
Version string
17+
18+
// prevent unkeyed literal initialization
19+
_ struct{}
1720
}
1821

1922
// NewDefaultBuildInfo returns a default BuildInfo.

config/configmiddleware/configmiddleware.go

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ var (
2929
type Config struct {
3030
// ID specifies the name of the extension to use.
3131
ID component.ID `mapstructure:"id,omitempty"`
32+
// prevent unkeyed literal initialization
33+
_ struct{}
3234
}
3335

3436
// GetHTTPClientRoundTripper attempts to select the appropriate

config/configtls/tpm.go

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ type TPMConfig struct {
2121
Path string `mapstructure:"path"`
2222
OwnerAuth string `mapstructure:"owner_auth"`
2323
Auth string `mapstructure:"auth"`
24+
// prevent unkeyed literal initialization
25+
_ struct{}
2426
}
2527

2628
func (c TPMConfig) tpmCertificate(keyPem []byte, certPem []byte, openTPM func() (transport.TPMCloser, error)) (tls.Certificate, error) {

confmap/provider.go

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ type ChangeEvent struct {
9898
// Error is nil if the config is changed and needs to be re-fetched.
9999
// Any non-nil error indicates that there was a problem with watching the config changes.
100100
Error error
101+
// prevent unkeyed literal initialization
102+
_ struct{}
101103
}
102104

103105
// Retrieved holds the result of a call to the Retrieve method of a Provider object.

internal/tools/go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require (
1212
github.com/jcchavezs/porto v0.7.0
1313
github.com/pavius/impi v0.0.3
1414
github.com/rhysd/actionlint v1.7.7
15+
go.opentelemetry.io/build-tools/checkapi v0.23.0
1516
go.opentelemetry.io/build-tools/checkfile v0.23.0
1617
go.opentelemetry.io/build-tools/chloggen v0.23.0
1718
go.opentelemetry.io/build-tools/crosslink v0.23.0

internal/tools/go.sum

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/tools/tools.go

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
_ "github.com/jcchavezs/porto/cmd/porto"
1919
_ "github.com/pavius/impi/cmd/impi"
2020
_ "github.com/rhysd/actionlint/cmd/actionlint"
21+
_ "go.opentelemetry.io/build-tools/checkapi"
2122
_ "go.opentelemetry.io/build-tools/checkfile"
2223
_ "go.opentelemetry.io/build-tools/chloggen"
2324
_ "go.opentelemetry.io/build-tools/crosslink"

otelcol/config.go

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ type Config struct {
3636
Extensions map[component.ID]component.Config `mapstructure:"extensions"`
3737

3838
Service service.Config `mapstructure:"service"`
39+
40+
// prevent unkeyed literal initialization
41+
_ struct{}
3942
}
4043

4144
// Validate returns an error if the config is invalid.

otelcol/configprovider.go

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ type ConfigProvider struct {
2828
type ConfigProviderSettings struct {
2929
// ResolverSettings are the settings to configure the behavior of the confmap.Resolver.
3030
ResolverSettings confmap.ResolverSettings
31+
// prevent unkeyed literal initialization
32+
_ struct{}
3133
}
3234

3335
// NewConfigProvider returns a new ConfigProvider that provides the service configuration:

receiver/receivertest/contract_checker.go

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ type CheckConsumeContractParams struct {
6363
// GenerateCount specifies the number of times to call the generator.Generate()
6464
// for each test scenario.
6565
GenerateCount int
66+
// prevent unkeyed literal initialization
67+
_ struct{}
6668
}
6769

6870
// CheckConsumeContract checks the contract between the receiver and its next consumer. For the contract

service/config.go

+3
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ type Config struct {
1919

2020
// Pipelines are the set of data pipelines configured for the service.
2121
Pipelines pipelines.Config `mapstructure:"pipelines"`
22+
23+
// prevent unkeyed literal initialization
24+
_ struct{}
2225
}

0 commit comments

Comments
 (0)