add cli changes to move to v1beta1#304
add cli changes to move to v1beta1#304openshift-merge-bot[bot] merged 1 commit intoshipwright-io:mainfrom
Conversation
HeavyWombat
left a comment
There was a problem hiding this comment.
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.
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.
I believe this doc is auto-generated, so it needs to be made in the respective go code.
pkg/shp/cmd/build/create.go
Outdated
| buildv1beta1 "github.com/shipwright-io/build/pkg/apis/build/v1beta1" | ||
| "github.com/spf13/cobra" | ||
|
|
||
| v1 "k8s.io/api/core/v1" |
There was a problem hiding this comment.
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.
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.
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.
adambkaplan
left a comment
There was a problem hiding this comment.
/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.
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.
Risk of nil pointer dereference panic?
There was a problem hiding this comment.
Looks like the nil dereference risk is still here...
There was a problem hiding this comment.
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.
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 DetailsNeeds 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.
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.
@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.
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.
@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.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.
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.
@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.
| 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.
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.
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
| 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.
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 <karan.kumar6@ibm.com>
fa0e537 to
0afb42b
Compare
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