Skip to content

Allow specifying custom build tags for the generated deepcopy files #871

@irbekrm

Description

@irbekrm

It would be great if it was possible to specify custom Go build tags to be passed to deep copy generation, in the same way as it is currently possible to pass a custom header to be used, i.e

go run  sigs.k8s.io/controller-tools/cmd/controller-gen  \
	object:headerFile=<header-file-path> \
        object:buildTags="!plan9,!windows" \
        paths=./k8s-operator/apis/...

For the context - our Kubernetes custom resources live in a monorepo with our main application codebase, which is not Kubernetes specific. We build and run tests for various platforms, including plan9.

In our Kubernetes-specific code we need to import apimachinery library, but that contains code that cannot be built on plan9, i.e syscall.Errno here, so we exclude the Kubernetes-specific code from plan9 builds/tests with a !plan9 Go build tag.

Currently there is no way how to pass build tags to the generated deepcopy files, so we end up using a sed script to modify these files after they have been generated- this is a bit hacky and also prevents us from being able to generate deepcopy files using go generate which would be our preferred way.

I would be happy to PR a new flag to deepcopy generator for this.

Metadata

Metadata

Assignees

Labels

lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions