Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code generation outside GOPATH #106964

Merged
merged 1 commit into from Dec 11, 2021

Conversation

ncdc
Copy link
Member

@ncdc ncdc commented Dec 10, 2021

/kind cleanup

What this PR does / why we need it:

Add support for the generators in k8s.io/code-generator to output generated files anywhere and not just in GOPATH.

The updated version of k8s.io/gengo now supports a --trim-path-prefix flag to trim a prefix from a generated file's path before creating it. This can be passed to the generate-groups.sh script in k8s.io/code-generator. For example, if you're generating code for github.com/foo/bar, and you have it cloned somewhere not in GOPATH, you can do this:

generate-groups.sh \
  all \
  github.com/foo/bar/pkg/client \
  github.com/foo/bar/pkg/apis \
  myapi:v1alpha1 \
  --trim-path-prefix github.com/foo/bar

and the generated files will essentially be written relative to the current directory (assuming it's the root of your repo). So github.com/foo/bar/pkg/client will be written to just pkg/client/... and so on.

Which issue(s) this PR fixes:

Fixes kubernetes/code-generator#133

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


Signed-off-by: Andy Goldstein <andy.goldstein@redhat.com>
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/code-generation area/dependency Issues or PRs related to dependency changes labels Dec 10, 2021
@k8s-ci-robot k8s-ci-robot added area/kubectl sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Dec 10, 2021
@dims
Copy link
Member

dims commented Dec 10, 2021

/assign @thockin @liggitt

@thockin
Copy link
Member

thockin commented Dec 10, 2021

Oof. I have not visited this in a while. Will look.

Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 10, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ncdc, thockin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 10, 2021
@ncdc
Copy link
Member Author

ncdc commented Dec 11, 2021

/retest

1 similar comment
@ncdc
Copy link
Member Author

ncdc commented Dec 11, 2021

/retest

@k8s-ci-robot k8s-ci-robot merged commit 8b9e1d7 into kubernetes:master Dec 11, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.24 milestone Dec 11, 2021
@leilajal
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 14, 2021
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 1, 2022
kubernetes/kubernetes#106964 fixed a bug whereby
codegen outside of GOPATH would put generated files under github.com/
relative to the repo root. Revendor to pull in the fix, update our
script to use the `--trim-path-prefix` flag, and check in the resulting
incidental deltas to generated files.

HIVE-1723
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 2, 2022
kubernetes/kubernetes#106964 fixed a bug whereby codegen outside of
GOPATH would put generated files under github.com/ relative to the repo
root. Revendor k8s.io/code-generator to pull in the fix and update our
script to use the --trim-path-prefix flag it introduced.

The update resulted in dependency hell, including needing to move to go
1.17.

Changes in actual hive code to accommodate updated dependencies include:
- Accommodate a new method on workqueue.Interface.
- Remove the `--v` flag from the hiveadmission executable --
logging-related CLI options were removed from the underlying command at
some point.
- Rewrite the logr wrapper we pass to controller-runtime to initialize
the managers for the operator and controllers
- Repoint where we get our fake clock from for testing expectations.

HIVE-1723
HIVE-1753
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 3, 2022
kubernetes/kubernetes#106964 fixed a bug whereby codegen outside of
GOPATH would put generated files under github.com/ relative to the repo
root. Revendor k8s.io/code-generator to pull in the fix and update our
script to use the --trim-path-prefix flag it introduced.

The update resulted in dependency hell, including needing to move to go
1.17.

Changes in actual hive code to accommodate updated dependencies include:
- Accommodate a new method on workqueue.Interface.
- Remove the `--v` flag from the hiveadmission executable --
logging-related CLI options were removed from the underlying command at
some point.
- Rewrite the logr wrapper we pass to controller-runtime to initialize
the managers for the operator and controllers
- Repoint where we get our fake clock from for testing expectations.

HIVE-1723
HIVE-1753
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 3, 2022
kubernetes/kubernetes#106964 fixed a bug whereby codegen outside of
GOPATH would put generated files under github.com/ relative to the repo
root. Revendor k8s.io/code-generator to pull in the fix and update our
script to use the --trim-path-prefix flag it introduced.

The update resulted in dependency hell, including needing to move to go
1.17.

Changes in actual hive code to accommodate updated dependencies include:
- Accommodate a new method on workqueue.Interface.
- Remove the `--v` flag from the hiveadmission executable --
logging-related CLI options were removed from the underlying command at
some point.
- Rewrite the logr wrapper we pass to controller-runtime to initialize
the managers for the operator and controllers
- Repoint where we get our fake clock from for testing expectations.

HIVE-1723
HIVE-1753
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 3, 2022
kubernetes/kubernetes#106964 fixed a bug whereby codegen outside of
GOPATH would put generated files under github.com/ relative to the repo
root. Revendor k8s.io/code-generator to pull in the fix and update our
script to use the --trim-path-prefix flag it introduced.

The update resulted in dependency hell, including needing to move to go
1.17.

Changes in actual hive code to accommodate updated dependencies include:
- Accommodate a new method on workqueue.Interface.
- Remove the `--v` flag from the hiveadmission executable --
logging-related CLI options were removed from the underlying command at
some point.
- Rewrite the logr wrapper we pass to controller-runtime to initialize
the managers for the operator and controllers
- Repoint where we get our fake clock from for testing expectations.

HIVE-1723
HIVE-1753
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 4, 2022
kubernetes/kubernetes#106964 fixed a bug whereby codegen outside of
GOPATH would put generated files under github.com/ relative to the repo
root. Revendor k8s.io/code-generator to pull in the fix and update our
script to use the --trim-path-prefix flag it introduced.

The update resulted in dependency hell, including needing to move to go
1.17.

Changes in actual hive code to accommodate updated dependencies include:
- Accommodate a new method on workqueue.Interface.
- Remove the `--v` flag from the hiveadmission executable --
logging-related CLI options were removed from the underlying command at
some point.
- Rewrite the logr wrapper we pass to controller-runtime to initialize
the managers for the operator and controllers
- Repoint where we get our fake clock from for testing expectations.

HIVE-1723
HIVE-1753
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 4, 2022
kubernetes/kubernetes#106964 fixed a bug whereby codegen outside of
GOPATH would put generated files under github.com/ relative to the repo
root. Revendor k8s.io/code-generator to pull in the fix and update our
script to use the --trim-path-prefix flag it introduced.

The update resulted in dependency hell, including needing to move to go
1.17.

Changes in actual hive code to accommodate updated dependencies include:
- Accommodate a new method on workqueue.Interface.
- Remove the `--v` flag from the hiveadmission executable --
logging-related CLI options were removed from the underlying command at
some point.
- Rewrite the logr wrapper we pass to controller-runtime to initialize
the managers for the operator and controllers
- Repoint where we get our fake clock from for testing expectations.

HIVE-1723
HIVE-1753
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 4, 2022
kubernetes/kubernetes#106964 fixed a bug whereby codegen outside of
GOPATH would put generated files under github.com/ relative to the repo
root. Revendor k8s.io/code-generator to pull in the fix and update our
script to use the --trim-path-prefix flag it introduced.

The update resulted in dependency hell, including needing to move to go
1.17.

Changes in actual hive code to accommodate updated dependencies include:
- Accommodate a new method on workqueue.Interface.
- Remove the `--v` flag from the hiveadmission executable --
logging-related CLI options were removed from the underlying command at
some point.
- Rewrite the logr wrapper we pass to controller-runtime to initialize
the managers for the operator and controllers
- Repoint where we get our fake clock from for testing expectations.

HIVE-1723
HIVE-1753
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 4, 2022
kubernetes/kubernetes#106964 fixed a bug whereby codegen outside of
GOPATH would put generated files under github.com/ relative to the repo
root. Revendor k8s.io/code-generator to pull in the fix and update our
script to use the --trim-path-prefix flag it introduced.

The update resulted in dependency hell, including needing to move to go
1.17.

Changes in actual hive code to accommodate updated dependencies include:
- Accommodate a new method on workqueue.Interface.
- Remove the `--v` flag from the hiveadmission executable --
logging-related CLI options were removed from the underlying command at
some point.
- Rewrite the logr wrapper we pass to controller-runtime to initialize
the managers for the operator and controllers
- Repoint where we get our fake clock from for testing expectations.

HIVE-1723
HIVE-1753
2uasimojo added a commit to 2uasimojo/hive that referenced this pull request Feb 4, 2022
kubernetes/kubernetes#106964 fixed a bug whereby codegen outside of
GOPATH would put generated files under github.com/ relative to the repo
root. Revendor k8s.io/code-generator to pull in the fix and update our
script to use the --trim-path-prefix flag it introduced.

The update resulted in dependency hell, including needing to move to go
1.17.

Changes in actual hive code to accommodate updated dependencies include:
- Accommodate a new method on workqueue.Interface.
- Remove the `--v` flag from the hiveadmission executable --
logging-related CLI options were removed from the underlying command at
some point.
- Rewrite the logr wrapper we pass to controller-runtime to initialize
the managers for the operator and controllers
- Repoint where we get our fake clock from for testing expectations.

HIVE-1723
HIVE-1753
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/code-generation area/dependency Issues or PRs related to dependency changes area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

deepcopy-gen relative output without symlinks
6 participants