-
Notifications
You must be signed in to change notification settings - Fork 104
Generate deep-copy functions #3967
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
Conversation
| # Fix internal Azure SDK import path and type references. | ||
| sed -i \ | ||
| -e 's|resource "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/internal/resource"|azcorearm "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"|g' \ | ||
| -e 's|resource\.ResourceID|azcorearm.ResourceID|g' \ | ||
| "${f}" | ||
|
|
||
| # Fix pointer-type azcorearm.ResourceID fields: replace two-line | ||
| # *out = new(azcorearm.ResourceID) | ||
| # (*in).DeepCopyInto(*out) | ||
| # with single-line call to DeepCopyResourceID. | ||
| sed -i -E \ | ||
| "/\*out = new\(azcorearm\.ResourceID\)/{N;s|\*out = new\(azcorearm\.ResourceID\)\n[[:space:]]*\(\*in\)\.DeepCopyInto\(\*out\)|*out = ${RESOURCEID_FUNC}(*in)|;}" \ | ||
| "${f}" | ||
|
|
||
| # Fix value-type azcorearm.ResourceID field (e.g. ServiceProviderCluster.ResourceID). | ||
| sed -i \ | ||
| "s/in\.ResourceID\.DeepCopyInto(&out\.ResourceID)/out.ResourceID = *${RESOURCEID_FUNC}(\&in.ResourceID)/g" \ | ||
| "${f}" | ||
|
|
||
| # Fix pointer-type time.Time fields (time.Time has no DeepCopyInto). | ||
| sed -i \ | ||
| '/\*out = new(time\.Time)/{n;s/(\*in)\.DeepCopyInto(\*out)/**out = **in/;}' \ | ||
| "${f}" | ||
|
|
||
| # Fix value-type time.Time fields. | ||
| for field in LastTransitionTime StartTime ExpirationTimestamp EndOfLifeTimestamp; do | ||
| sed -i \ | ||
| "s/in\.${field}\.DeepCopyInto(&out\.${field})/out.${field} = in.${field}/g" \ | ||
| "${f}" | ||
| done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super ugly. probably still easier.
| if [[ ! -z "$(git status --short)" ]]; then | ||
| echo "deepcopy generated files are out of date, rerun 'make deepcopy' to update them and check the changes in" | ||
| git status | ||
| git diff | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also ugly (hate mutating the worktree), but in keeping with what we have.
cffb4cb to
4a226a1
Compare
|
This looks good enough to me /hold cancel |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, stevekuznetsov The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest |
4a226a1 to
234ea72
Compare
|
New changes are detected. LGTM label has been removed. |
234ea72 to
bd84b1f
Compare
|
New changes are detected. LGTM label has been removed. |
This is ugly, but it appears accurate. It is using the kube deepcopy, but because we use azcorearm.ResourceID, we cannot create deepcopy functions on the type. Modification to deepcopy-gen is doable, but a long term effort.