[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 <11745660+evan-bradley@users.noreply.github.com>
Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
This commit is contained in:
Antoine Toulme 2025-05-05 08:52:16 -07:00 committed by GitHub
parent 56c7da2107
commit 829157cef7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 38 additions and 0 deletions

8
.checkapi.yaml Normal file
View File

@ -0,0 +1,8 @@
ignored_paths:
- confmap/doc_test.go
excluded_files:
- example_*.go
- "*_test.go"
unkeyed_literal_initialization:
enabled: true
limit: 6

View File

@ -111,6 +111,8 @@ jobs:
run: make misspell
- name: checkdoc
run: make checkdoc
- name: checkapi
run: make checkapi
- name: Check for go mod dependency changes
run: |
make gotidy

View File

@ -315,6 +315,10 @@ certs:
certs-dryrun:
@internal/buildscripts/gen-certs.sh -d
.PHONY: checkapi
checkapi: $(CHECKAPI)
$(CHECKAPI) -folder . -config .checkapi.yaml
# Verify existence of READMEs for components specified as default components in the collector.
.PHONY: checkdoc
checkdoc: $(CHECKFILE)

View File

@ -26,6 +26,7 @@ JUNIT_OUT_DIR ?= $(TOOLS_MOD_DIR)/testresults
ADDLICENSE := $(TOOLS_BIN_DIR)/addlicense
APIDIFF := $(TOOLS_BIN_DIR)/apidiff
CHECKAPI := $(TOOLS_BIN_DIR)/checkapi
CHECKFILE := $(TOOLS_BIN_DIR)/checkfile
CHLOGGEN := $(TOOLS_BIN_DIR)/chloggen
CROSSLINK := $(TOOLS_BIN_DIR)/crosslink

View File

@ -14,6 +14,9 @@ type BuildInfo struct {
// Version string.
Version string
// prevent unkeyed literal initialization
_ struct{}
}
// NewDefaultBuildInfo returns a default BuildInfo.

View File

@ -29,6 +29,8 @@ var (
type Config struct {
// ID specifies the name of the extension to use.
ID component.ID `mapstructure:"id,omitempty"`
// prevent unkeyed literal initialization
_ struct{}
}
// GetHTTPClientRoundTripper attempts to select the appropriate

View File

@ -21,6 +21,8 @@ type TPMConfig struct {
Path string `mapstructure:"path"`
OwnerAuth string `mapstructure:"owner_auth"`
Auth string `mapstructure:"auth"`
// prevent unkeyed literal initialization
_ struct{}
}
func (c TPMConfig) tpmCertificate(keyPem []byte, certPem []byte, openTPM func() (transport.TPMCloser, error)) (tls.Certificate, error) {

View File

@ -98,6 +98,8 @@ type ChangeEvent struct {
// Error is nil if the config is changed and needs to be re-fetched.
// Any non-nil error indicates that there was a problem with watching the config changes.
Error error
// prevent unkeyed literal initialization
_ struct{}
}
// Retrieved holds the result of a call to the Retrieve method of a Provider object.

View File

@ -12,6 +12,7 @@ require (
github.com/jcchavezs/porto v0.7.0
github.com/pavius/impi v0.0.3
github.com/rhysd/actionlint v1.7.7
go.opentelemetry.io/build-tools/checkapi v0.23.0
go.opentelemetry.io/build-tools/checkfile v0.23.0
go.opentelemetry.io/build-tools/chloggen v0.23.0
go.opentelemetry.io/build-tools/crosslink v0.23.0

2
internal/tools/go.sum generated
View File

@ -524,6 +524,8 @@ go-simpler.org/sloglint v0.11.0 h1:JlR1X4jkbeaffiyjLtymeqmGDKBDO1ikC6rjiuFAOco=
go-simpler.org/sloglint v0.11.0/go.mod h1:CFDO8R1i77dlciGfPEPvYke2ZMx4eyGiEIWkyeW2Pvw=
go.opentelemetry.io/build-tools v0.23.0 h1:92R7QXKZ+02Jr6vXJvxhaEchShIyggHq8ooWm3AAFcw=
go.opentelemetry.io/build-tools v0.23.0/go.mod h1:ORnHNf2mImNjM63JUoVZ5YJhs+HAvQ6aAtE++KQF9Kc=
go.opentelemetry.io/build-tools/checkapi v0.23.0 h1:rKhsyo19EV6DT4IZFPaM42uqFLVnhj7aGIYo0pqiw9Q=
go.opentelemetry.io/build-tools/checkapi v0.23.0/go.mod h1:J7KC/+bPtDVUhRWk7eGd61Uxhn3UvuOQuynJ5W6dW5c=
go.opentelemetry.io/build-tools/checkfile v0.23.0 h1:xwkGOwHhoJWGFkvOla4dXYHJ4zIkK+0MFhtXAOW9OBo=
go.opentelemetry.io/build-tools/checkfile v0.23.0/go.mod h1:cJr2PBIQbubYHFE9bvbRWzAAHdQdFMVdI5VD9ETycvw=
go.opentelemetry.io/build-tools/chloggen v0.23.0 h1:S1/HBnF5ekYmYD6gkjlXm77OxZUnxwNa+Afu7FcXCbo=

View File

@ -18,6 +18,7 @@ import (
_ "github.com/jcchavezs/porto/cmd/porto"
_ "github.com/pavius/impi/cmd/impi"
_ "github.com/rhysd/actionlint/cmd/actionlint"
_ "go.opentelemetry.io/build-tools/checkapi"
_ "go.opentelemetry.io/build-tools/checkfile"
_ "go.opentelemetry.io/build-tools/chloggen"
_ "go.opentelemetry.io/build-tools/crosslink"

View File

@ -36,6 +36,9 @@ type Config struct {
Extensions map[component.ID]component.Config `mapstructure:"extensions"`
Service service.Config `mapstructure:"service"`
// prevent unkeyed literal initialization
_ struct{}
}
// Validate returns an error if the config is invalid.

View File

@ -28,6 +28,8 @@ type ConfigProvider struct {
type ConfigProviderSettings struct {
// ResolverSettings are the settings to configure the behavior of the confmap.Resolver.
ResolverSettings confmap.ResolverSettings
// prevent unkeyed literal initialization
_ struct{}
}
// NewConfigProvider returns a new ConfigProvider that provides the service configuration:

View File

@ -63,6 +63,8 @@ type CheckConsumeContractParams struct {
// GenerateCount specifies the number of times to call the generator.Generate()
// for each test scenario.
GenerateCount int
// prevent unkeyed literal initialization
_ struct{}
}
// CheckConsumeContract checks the contract between the receiver and its next consumer. For the contract

View File

@ -19,4 +19,7 @@ type Config struct {
// Pipelines are the set of data pipelines configured for the service.
Pipelines pipelines.Config `mapstructure:"pipelines"`
// prevent unkeyed literal initialization
_ struct{}
}