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

Improve update-codegen.sh to copy generated files into SEDNA_ROOT. #218

Merged
merged 1 commit into from
Oct 26, 2021

Conversation

vcozzolino
Copy link
Contributor

The update-codegen.sh script won't work if the user cloned Sedna into a custom folder that is different from the standard one for GO projects. For someone new to GO, this can be very misleading as no errors are prompted and the user will never see the updated generated code. I think that this is a high-priority change as I can see many people having this problem, myself included.

This patch enhances the script so that it will copy the generated code into the SEDNA_ROOT, if necessary.

@kubeedge-bot kubeedge-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 21, 2021
Copy link

@llhuii llhuii left a comment

Choose a reason for hiding this comment

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

Thank you for pointing it out.

@@ -26,3 +26,15 @@ ${SEDNA_ROOT}/hack/generate-groups.sh "deepcopy,client,informer,lister" \
${SEDNA_GO_PACKAGE}/pkg/client ${SEDNA_GO_PACKAGE}/pkg/apis \
"sedna:v1alpha1" \
--go-header-file ${SEDNA_ROOT}/hack/boilerplate/boilerplate.generatego.txt

# Check if Sedna home is different from the standard directory where GO projects are located
if [ "${GOPATH}/src/${SEDNA_GO_PACKAGE}/" != "$${SEDNA_ROOT}/" ]; then
Copy link

Choose a reason for hiding this comment

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

  1. $${SEDNA_ROOT} => ${SEDNA_ROOT}
  2. we need to check they are the same location instead of only checking equal string, such as symbol link relation

Copy link

Choose a reason for hiding this comment

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

More word, the user may create the symbol link directory for $SEDNA_ROOT in ${GOPATH}/src

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Did you have in mind something like this:

if ! [[ ${GOPATH}/src/${SEDNA_GO_PACKAGE}/ -ef ${SEDNA_ROOT}/ ]]; then ...

This should also help with symbolic links comparison.

Copy link

Choose a reason for hiding this comment

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

-ef is good choice.

PS: quote "${SEDNA_ROOT}" is a good habit

hack/update-codegen.sh Outdated Show resolved Hide resolved
@kubeedge-bot kubeedge-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 25, 2021
hack/update-codegen.sh Outdated Show resolved Hide resolved
@kubeedge-bot kubeedge-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 25, 2021
@vcozzolino vcozzolino force-pushed the feature-improve-codegen branch from d804a4c to 86e32f2 Compare October 25, 2021 10:33
hack/update-codegen.sh Outdated Show resolved Hide resolved
hack/update-codegen.sh Outdated Show resolved Hide resolved
hack/update-codegen.sh Outdated Show resolved Hide resolved
hack/update-codegen.sh Outdated Show resolved Hide resolved
Signed-off-by: Vittorio Cozzolino <[email protected]>
@vcozzolino vcozzolino force-pushed the feature-improve-codegen branch from 87774b5 to ea2f333 Compare October 26, 2021 07:28
@llhuii
Copy link

llhuii commented Oct 26, 2021

/lgtm

@kubeedge-bot kubeedge-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 26, 2021
@llhuii
Copy link

llhuii commented Oct 26, 2021

/approve
Thanks.

@kubeedge-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: llhuii

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

@kubeedge-bot kubeedge-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 26, 2021
@kubeedge-bot kubeedge-bot merged commit fa6df45 into kubeedge:main Oct 26, 2021
@vcozzolino vcozzolino deleted the feature-improve-codegen branch October 28, 2021 11:09
@llhuii
Copy link

llhuii commented Nov 8, 2021

kubernetes/gengo#215 would add module support for kubernetes gengo.

After that effort has merged, we don't need this rsync avoidance.

@llhuii
Copy link

llhuii commented Dec 13, 2021

For zz_generated.deepcopy generated by deepcopy-gen, can be fixed by kubernetes/gengo#221

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. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants