-
Notifications
You must be signed in to change notification settings - Fork 29
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
base: main
Are you sure you want to change the base?
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.
/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.
pkg/shp/cmd/build/create.go
Outdated
if dockerfile != nil && *dockerfile != "" { | ||
buildSpecFlags.Env = append(buildSpecFlags.Env, v1.EnvVar{Name: "dockerfile", Value: *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.
If the intent is to mimic the conversion webhook logic, the Dockerfile
should be made a parameter, not an environment variable: https://github.com/shipwright-io/build/blob/main/pkg/apis/build/v1beta1/build_conversion.go#L169-L177
pkg/shp/cmd/build/create.go
Outdated
if builderImage != nil && *builderImage != "" { | ||
buildSpecFlags.Env = append(buildSpecFlags.Env, v1.EnvVar{Name: "builder-image", Value: *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.
Ditto - convert to a parameter: https://github.com/shipwright-io/build/blob/main/pkg/apis/build/v1beta1/build_conversion.go#L180-L188
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
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.
pkg/shp/flags/flags.go
Outdated
&source.OCIArtifact.Image, | ||
SourceOciArtifactImageFlag, | ||
"", | ||
"source bundle image location, e.g. ghcr.io/shipwright-io/sample-go/source-bundle:latest", |
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.
"source bundle image location, e.g. ghcr.io/shipwright-io/sample-go/source-bundle:latest", | |
"source OCI artifact reference, e.g. ghcr.io/shipwright-io/sample-go/source-bundle:latest", |
pkg/shp/flags/flags.go
Outdated
// SourceBundleImageFlag command-line flag | ||
SourceBundleImageFlag = "source-bundle-image" | ||
SourceOciArtifactImageFlag = "source-oci-artifact-image" |
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 - OCI is an acronym and should be in caps
SourceOciArtifactImageFlag = "source-oci-artifact-image" | |
SourceOCIArtifactImageFlag = "source-oci-artifact-image" |
pkg/shp/flags/flags.go
Outdated
SourceOciArtifactPruneFlag = "source-oci-artifact-prune" | ||
// SourceOciArtifactPullSecretFlag command-line flag | ||
SourceOciArtifactPullSecretFlag = "source-oci-artifact-pull-secret" // #nosec G101 |
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 - OCI should be capitalized
SourceOciArtifactPruneFlag = "source-oci-artifact-prune" | |
// SourceOciArtifactPullSecretFlag command-line flag | |
SourceOciArtifactPullSecretFlag = "source-oci-artifact-pull-secret" // #nosec G101 | |
SourceOCIArtifactPruneFlag = "source-oci-artifact-prune" | |
// SourceOCIArtifactPullSecretFlag command-line flag | |
SourceOCIArtifactPullSecretFlag = "source-oci-artifact-pull-secret" // #nosec G101 |
pkg/shp/flags/flags.go
Outdated
"", | ||
"path to dockerfile relative to repository", | ||
) | ||
flags.MarkDeprecated("builder-image", "builder-image parameter is deprecated") |
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.
flags.MarkDeprecated("builder-image", "builder-image parameter is deprecated") | |
flags.MarkDeprecated("builder-image", "builder-image flag is deprecated, and will be removed in a future release. Use an appropriate parameter for the build strategy instead.") |
pkg/shp/flags/flags.go
Outdated
flags.BoolVar( | ||
sa.Generate, | ||
ServiceAccountGenerateFlag, | ||
false, | ||
"generate a Kubernetes service-account for the build", | ||
) |
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.
This flag should be retained and marked deprecated. OK if this flag does nothing.
[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
1db8031
to
964803e
Compare
Signed-off-by: Karan Kumar <[email protected]>
Signed-off-by: Karan Kumar <[email protected]>
Signed-off-by: Karan Kumar <[email protected]>
8cb2147
to
cfea747
Compare
Signed-off-by: Karan Kumar <[email protected]>
e051935
to
359459c
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