-
Notifications
You must be signed in to change notification settings - Fork 35
add cli changes to move to v1beta1 #304
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
add cli changes to move to v1beta1 #304
Conversation
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.
Thanks for all the work. Nice. I just left some comments and questions after an initial pass.
docs/shp_build_create.md
Outdated
--source-oci-artifact-image string source oci artifact image location, e.g. ghcr.io/shipwright-io/sample-go/source-bundle:latest | ||
--source-oci-artifact-prune pruneOption source oci artifact image prune option, either Never, or AfterPull (default Never) |
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.
Nit: I think I should try uppercase since it's an acronym.
--source-oci-artifact-image string source oci artifact image location, e.g. ghcr.io/shipwright-io/sample-go/source-bundle:latest | |
--source-oci-artifact-prune pruneOption source oci artifact image prune option, either Never, or AfterPull (default Never) | |
--source-oci-artifact-image string source OCI artifact image location, e.g. ghcr.io/shipwright-io/sample-go/source-bundle:latest | |
--source-oci-artifact-prune pruneOption source OCI artifact image prune option, either Never, or AfterPull (default Never) |
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.
I believe this doc is auto-generated, so it needs to be made in the respective go code.
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.
Done.
pkg/shp/cmd/build/create.go
Outdated
"github.com/spf13/cobra" | ||
|
||
v1 "k8s.io/api/core/v1" |
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.
For consistency, we should use "full name".
v1 "k8s.io/api/core/v1" | |
corev1 "k8s.io/api/core/v1" |
Git: &buildv1beta1.Git{ | ||
Revision: ptr.To(""), | ||
CloneSecret: ptr.To(""), | ||
}, | ||
OCIArtifact: &buildv1beta1.OCIArtifact{ | ||
Prune: &pruneOption, | ||
PullSecret: ptr.To(""), |
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.
Seems a bit a weird to me to initialize everything with pointers to empty strings just to be later updated by flag values, if I understand it correctly. Is there any way we can simplify this? What do you think?
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.
I think we can take this up as a follow-up item to address. Since this PR is a pure refactor, I'd prefer to keep the existing behavior as close as possible to status quo.
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.
Filed #310 so we don't lose track of this.
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.
/approve
Giving the 👍 for this change to go into v0.16. I called out a few items I noticed in my review.
docs/shp_build_create.md
Outdated
--source-oci-artifact-image string source oci artifact image location, e.g. ghcr.io/shipwright-io/sample-go/source-bundle:latest | ||
--source-oci-artifact-prune pruneOption source oci artifact image prune option, either Never, or AfterPull (default Never) |
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.
I believe this doc is auto-generated, so it needs to be made in the respective go code.
return err | ||
} | ||
fmt.Fprintf(ioStreams.Out, "BuildRun created %q for Build %q\n", c.name, br.Spec.BuildRef.Name) | ||
fmt.Fprintf(ioStreams.Out, "BuildRun created %q for Build %q\n", c.name, *br.Spec.Build.Name) |
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.
Risk of nil pointer dereference panic?
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.
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.
Looks like the nil dereference risk is still here...
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.
I think in this context, we never have a standalone buildrun but always one that references a build? If so, would be worth a comment.
Git: &buildv1beta1.Git{ | ||
Revision: ptr.To(""), | ||
CloneSecret: ptr.To(""), | ||
}, | ||
OCIArtifact: &buildv1beta1.OCIArtifact{ | ||
Prune: &pruneOption, | ||
PullSecret: ptr.To(""), |
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.
I think we can take this up as a follow-up item to address. Since this PR is a pure refactor, I'd prefer to keep the existing behavior as close as possible to status quo.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adambkaplan 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 |
8320cbf
to
74ec843
Compare
8cb2147
to
cfea747
Compare
e051935
to
359459c
Compare
} | ||
} | ||
|
||
if c.dockerfile != nil && *c.dockerfile != "" { |
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.
nit (not going to block on this) - you can do both checks in golang using len
, since it is safe to use on nil pointers:
if c.dockerfile != nil && *c.dockerfile != "" { | |
if len(c.dockerfile) > 0 { |
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.
@adambkaplan , I know it works with arrays, but I tried this : https://go.dev/play/p/_nEyrfl96EZ and it didn't work for pointer strings.
c.buildSpec.ParamValues = append(c.buildSpec.ParamValues, dockerfileParam) | ||
} | ||
|
||
if c.builderImage != nil && *c.builderImage != "" { |
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.
nit (not blocking) - ditto on using len
:
if c.builderImage != nil && *c.builderImage != "" { | |
if len(c.builderImage) > 0 { |
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.
@adambkaplan , I know it works with arrays, but I tried this : https://go.dev/play/p/_nEyrfl96EZ and it didn't work for pointer strings.
if buildRun == nil { | ||
return "", fmt.Errorf("no buildrun provided, given reference is nil") | ||
} | ||
|
||
if buildRun.Spec.BuildRef != nil { | ||
name, namespace := buildRun.Spec.BuildRef.Name, buildRun.Namespace | ||
if buildRun.Spec.Build.Name != nil && *buildRun.Spec.Build.Name != "" { |
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.
nit - ditto on use of len:
if buildRun.Spec.Build.Name != nil && *buildRun.Spec.Build.Name != "" { | |
if len(buildRun.Spec.Build.Name) > 0 { |
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.
@adambkaplan , I know it works with arrays, but I tried this : https://go.dev/play/p/_nEyrfl96EZ and it didn't work for pointer strings.
ServiceAccountGenerateFlag, | ||
false, | ||
"generate a Kubernetes service-account for the build", | ||
) | ||
flags.MarkDeprecated("sa-generate", fmt.Sprintf("this flag has no effect, please use --%s for service account", ServiceAccountNameFlag)) |
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.
Note that with this change, we should also remove the service account generation logic in the BuildRun controller. Filed shipwright-io/build#1873
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.
So, we don't need any change in cli. Right ?
@karanibm6 almost there! I found one item that was missed in your updates, plus a few nits that otherwise wouldn't block merge. Once these are done, please squash your commits and then this should be ready to merge 😄 ! |
359459c
to
fa0e537
Compare
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.
Nice work.
return err | ||
} | ||
fmt.Fprintf(ioStreams.Out, "BuildRun created %q for Build %q\n", c.name, br.Spec.BuildRef.Name) | ||
fmt.Fprintf(ioStreams.Out, "BuildRun created %q for Build %q\n", c.name, *br.Spec.Build.Name) |
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.
I think in this context, we never have a standalone buildrun but always one that references a build? If so, would be worth a comment.
Signed-off-by: Karan Kumar <[email protected]>
fa0e537
to
0afb42b
Compare
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.
/lgtm
Changes
Add code changes to move to v1beta1 from v1alpha1
Fixes #294
Submitter Checklist
See the contributor guide
for details on coding conventions, github and prow interactions, and the code review process.
Release Notes