datadog-agent
datadog-agent copied to clipboard
Adds 'print-default-build-tags' invoke task
What does this PR do?
Adds an extra invoke task to print out go build tags for a given build configuration.
eg:
$ inv print-default-build-tags
apm,consul,containerd,cri,docker,ec2,etcd,gce,jetson,jmx,kubeapiserver,kubelet,netcgo,orchestrator,otlp,podman,process,python,secrets,systemd,zk,zlib
$ inv print-default-build-tags -a arm64 -b agent -f iotoo
'iotoo' does not correspond to an agent flavor. Options: ['base', 'iot', 'heroku', 'dogstatsd']
$ inv print-default-build-tags --help
Usage: inv[oke] [--core-opts] print-default-build-tags [--options] [other tasks here ...]
Docstring:
Build the default list of tags based on the build type and current platform.
Prints as comma separated list suitable for go tooling (eg, gopls, govulncheck)
The container integrations are currently only supported on Linux, disabling on
the Windows and Darwin builds.
Options:
-a STRING, --arch=STRING
-b STRING, --build=STRING
-f STRING, --flavor=STRING
Motivation
Various go tooling takes in a build-tags parameter to run checks/analysis against a codebase.
I implemented this as a convenience for developers to configure their tooling correctly when working on the agent codebase.
Additional Notes
Possible Drawbacks / Trade-offs
Describe how to test/QA your changes
N/A
Reviewer's Checklist
- [ ] If known, an appropriate milestone has been selected; otherwise the
Triagemilestone is set. - [ ] Use the
major_changelabel if your change either has a major impact on the code base, is impacting multiple teams or is changing important well-established internals of the Agent. This label will be use during QA to make sure each team pay extra attention to the changed behavior. For any customer facing change use a releasenote. - [ ] A release note has been added or the
changelog/no-changeloglabel has been applied. - [ ] Changed code has automated tests for its functionality.
- [ ] Adequate QA/testing plan information is provided if the
qa/skip-qalabel is not applied. - [ ] At least one
team/..label has been applied, indicating the team(s) that should QA this change. - [ ] If applicable, docs team has been notified or an issue has been opened on the documentation repo.
- [ ] If applicable, the
need-change/operatorandneed-change/helmlabels have been applied. - [ ] If applicable, the
k8s/<min-version>label, indicating the lowest Kubernetes version compatible with this feature. - [ ] If applicable, the config template has been updated.
Maybe you can use something like
@task
def print_default_build_tags(ctx, build="agent", arch="x64", flavor=AgentFlavor.base.name):
"""
Build the default list of tags based on the build type and current platform.
Prints as comma separated list suitable for go tooling (eg, gopls, govulncheck)
The container integrations are currently only supported on Linux, disabling on
the Windows and Darwin builds.
"""
try:
flavor = AgentFlavor[flavor]
except KeyError:
raise Exit(message=f"`{flavor}` is not an agent flavor", code=1)
print(",".join(sorted(get_default_build_tags(build, arch, flavor))))
for the flavor issue
Thanks for the suggestion, works great
No particular rush for this to get in, moving it to 7.40