datadog-agent icon indicating copy to clipboard operation
datadog-agent copied to clipboard

Adds 'print-default-build-tags' invoke task

Open scottopell opened this issue 3 years ago • 3 comments

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 Triage milestone is set.
  • [ ] Use the major_change label 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-changelog label has been applied.
  • [ ] Changed code has automated tests for its functionality.
  • [ ] Adequate QA/testing plan information is provided if the qa/skip-qa label 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/operator and need-change/helm labels 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.

scottopell avatar Jul 28 '22 19:07 scottopell

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

paulcacheux avatar Jul 29 '22 07:07 paulcacheux

Thanks for the suggestion, works great

scottopell avatar Jul 29 '22 17:07 scottopell

No particular rush for this to get in, moving it to 7.40

scottopell avatar Aug 05 '22 19:08 scottopell