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

CRD usage of pointers vs non-pointers #945

Conversation

shahulsonhal
Copy link
Member

@shahulsonhal shahulsonhal commented Nov 18, 2021

Changes

We were not following the pointer vs non-pointer fields for custom resource definitions having required and optional fields.
Fixes #397

Update required custom resource fields to non-pointer
Update optional custom resource fields that do not have a built-in nil value to pointers

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

See the contributor guide
for details on coding conventions, github and prow interactions, and the code review process.

Release Notes

action required: We have cleaned up our APIs to provide a consistent representation of optional fields in Go. If you consume our Go types, many optional field types have been converted to pointers.

@openshift-ci openshift-ci bot added the release-note-none Label for when a PR does not need a release note label Nov 18, 2021
@shahulsonhal shahulsonhal added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Nov 18, 2021
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

@adambkaplan @gabemontero @HeavyWombat Looking for other opinions on optional fields. Imo we should use pointers for objects and fields where we must distinguish the "default value (""/false/0) and nil. In other cases we should use omitempty.

pkg/apis/build/v1alpha1/build_types.go Show resolved Hide resolved
pkg/apis/build/v1alpha1/build_types.go Show resolved Hide resolved
pkg/apis/build/v1alpha1/build_types.go Show resolved Hide resolved
pkg/apis/build/v1alpha1/buildrun_types.go Show resolved Hide resolved
pkg/apis/build/v1alpha1/buildrun_types.go Show resolved Hide resolved
pkg/apis/build/v1alpha1/buildrun_types.go Show resolved Hide resolved
pkg/apis/build/v1alpha1/buildrun_types.go Outdated Show resolved Hide resolved
pkg/apis/build/v1alpha1/buildrun_types.go Outdated Show resolved Hide resolved
pkg/apis/build/v1alpha1/buildrun_types.go Outdated Show resolved Hide resolved
@openshift-ci openshift-ci bot added release-note-action-required and removed release-note-none Label for when a PR does not need a release note labels Nov 18, 2021
@shahulsonhal
Copy link
Member Author

@adambkaplan @gabemontero @HeavyWombat Looking for other opinions on optional fields. Imo we should use pointers for objects and fields where we must distinguish the "default value (""/false/0) and nil. In other cases we should use omitempty.

@SaschaSchwarze0 Thanks.

we ask that pointers always be used with optional fields that do not have a built-in nil value

I saw this line in api-conventions and decided to use the pointers for primitive types as well.

@SaschaSchwarze0
Copy link
Member

@adambkaplan @gabemontero @HeavyWombat Looking for other opinions on optional fields. Imo we should use pointers for objects and fields where we must distinguish the "default value (""/false/0) and nil. In other cases we should use omitempty.

@SaschaSchwarze0 Thanks.

we ask that pointers always be used with optional fields that do not have a built-in nil value

I saw this line in api-conventions and decided to use the pointers for primitive types as well.

I see. Okay. Let's wait for further feedback and if needed bring it up in next Monday's community meeting.

@SaschaSchwarze0
Copy link
Member

/hold

Adding hold so that we merge this after the 0.7.0 release. We should merge this then soon and do the necessary changes in the CLI.

@openshift-ci openshift-ci bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Dec 8, 2021
@SaschaSchwarze0
Copy link
Member

/unhold

@shahulsonhal this needs a rebase

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 10, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 13, 2021
@shahulsonhal shahulsonhal force-pushed the crd-pointers-vs-non-pointers branch 4 times, most recently from 9a679f6 to 922848f Compare December 14, 2021 07:19
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 21, 2022
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

I recently learned that the functions with Ptr suffix in the pointer package are deprecated. That's most of my comments. A few others. If you do not have time for it @shahulsonhal, you can also grant me write access to your fork, I'll then append a commit.

pkg/reconciler/buildrun/buildrun.go Outdated Show resolved Hide resolved
pkg/reconciler/buildrun/buildrun.go Outdated Show resolved Hide resolved
pkg/reconciler/buildrun/resources/credentials_test.go Outdated Show resolved Hide resolved
pkg/reconciler/buildrun/resources/credentials_test.go Outdated Show resolved Hide resolved
pkg/reconciler/buildrun/resources/credentials_test.go Outdated Show resolved Hide resolved
test/integration/build_to_git_test.go Outdated Show resolved Hide resolved
test/integration/build_to_git_test.go Outdated Show resolved Hide resolved
test/integration/build_to_git_test.go Outdated Show resolved Hide resolved
test/integration/build_to_git_test.go Outdated Show resolved Hide resolved
test/integration/build_to_git_test.go Outdated Show resolved Hide resolved
@shahulsonhal shahulsonhal force-pushed the crd-pointers-vs-non-pointers branch 2 times, most recently from 0358d7e to a7554c5 Compare January 21, 2022 11:13
@shahulsonhal shahulsonhal force-pushed the crd-pointers-vs-non-pointers branch 2 times, most recently from 2921259 to ca71729 Compare January 21, 2022 12:19
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 21, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SaschaSchwarze0

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 21, 2022
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 27, 2022
Shahul added 4 commits January 28, 2022 09:25
We were not following the pointer vs non-pointer fields for custom resource definitions having required and optional fields.
Fixes shipwright-io#397

Update required custom resource fields to non-pointer
Update optional custom resource fields that do not have a built-in nil value to pointers
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 28, 2022
@gabemontero gabemontero modified the milestones: release-v0.8.0, Backlog Jan 31, 2022
@SaschaSchwarze0
Copy link
Member

We decided to merge this after the v0.8 release so that we have enough time to adopt the CLI and test things there.

Copy link
Member

@adambkaplan adambkaplan left a comment

Choose a reason for hiding this comment

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

/lgtm

Now that v0.8.0 is out, we can merge this.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 15, 2022
@openshift-merge-robot openshift-merge-robot merged commit 3adca80 into shipwright-io:main Feb 15, 2022
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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note-action-required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Review CRD usage of pointers vs non-pointers
6 participants