Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

karanibm6
Copy link

@karanibm6 karanibm6 commented Mar 24, 2025

Changes

Add code changes to move to v1beta1 from v1alpha1

Fixes #294

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

Add code changes to move to v1beta1 from v1alpha1

@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Mar 24, 2025
@openshift-ci openshift-ci bot requested review from HeavyWombat and qu1queee March 24, 2025 06:28
Copy link
Contributor

@HeavyWombat HeavyWombat left a 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.

Comment on lines 32 to 33
--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)
Copy link
Contributor

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.

Suggested change
--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)

Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

"github.com/spf13/cobra"

v1 "k8s.io/api/core/v1"
Copy link
Contributor

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".

Suggested change
v1 "k8s.io/api/core/v1"
corev1 "k8s.io/api/core/v1"

Comment on lines +22 to +28
Git: &buildv1beta1.Git{
Revision: ptr.To(""),
CloneSecret: ptr.To(""),
},
OCIArtifact: &buildv1beta1.OCIArtifact{
Prune: &pruneOption,
PullSecret: ptr.To(""),
Copy link
Contributor

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?

Copy link
Member

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.

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.

/approve

Giving the 👍 for this change to go into v0.16. I called out a few items I noticed in my review.

Comment on lines 32 to 33
--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)
Copy link
Member

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.

Comment on lines 106 to 108
if dockerfile != nil && *dockerfile != "" {
buildSpecFlags.Env = append(buildSpecFlags.Env, v1.EnvVar{Name: "dockerfile", Value: *dockerfile})
}
Copy link
Member

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

Comment on lines 110 to 112
if builderImage != nil && *builderImage != "" {
buildSpecFlags.Env = append(buildSpecFlags.Env, v1.EnvVar{Name: "builder-image", Value: *builderImage})
}
Copy link
Member

Choose a reason for hiding this comment

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

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)
Copy link
Member

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?

Copy link
Author

Choose a reason for hiding this comment

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

Done

Comment on lines +22 to +28
Git: &buildv1beta1.Git{
Revision: ptr.To(""),
CloneSecret: ptr.To(""),
},
OCIArtifact: &buildv1beta1.OCIArtifact{
Prune: &pruneOption,
PullSecret: ptr.To(""),
Copy link
Member

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.

&source.OCIArtifact.Image,
SourceOciArtifactImageFlag,
"",
"source bundle image location, e.g. ghcr.io/shipwright-io/sample-go/source-bundle:latest",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"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",

// SourceBundleImageFlag command-line flag
SourceBundleImageFlag = "source-bundle-image"
SourceOciArtifactImageFlag = "source-oci-artifact-image"
Copy link
Member

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

Suggested change
SourceOciArtifactImageFlag = "source-oci-artifact-image"
SourceOCIArtifactImageFlag = "source-oci-artifact-image"

Comment on lines 34 to 36
SourceOciArtifactPruneFlag = "source-oci-artifact-prune"
// SourceOciArtifactPullSecretFlag command-line flag
SourceOciArtifactPullSecretFlag = "source-oci-artifact-pull-secret" // #nosec G101
Copy link
Member

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

Suggested change
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

"",
"path to dockerfile relative to repository",
)
flags.MarkDeprecated("builder-image", "builder-image parameter is deprecated")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.")

Comment on lines 199 to 204
flags.BoolVar(
sa.Generate,
ServiceAccountGenerateFlag,
false,
"generate a Kubernetes service-account for the build",
)
Copy link
Member

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.

Copy link
Contributor

openshift-ci bot commented Mar 26, 2025

[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 /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 Mar 26, 2025
@karanibm6 karanibm6 force-pushed the update-cli-params branch 2 times, most recently from 8320cbf to 74ec843 Compare April 7, 2025 03:43
@pull-request-size pull-request-size bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 7, 2025
@karanibm6 karanibm6 force-pushed the update-cli-params branch 4 times, most recently from 1db8031 to 964803e Compare April 7, 2025 06:05
@karanibm6 karanibm6 force-pushed the update-cli-params branch from e051935 to 359459c Compare April 7, 2025 18:24
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. release-note size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

[FEATURE] Use v1beta1 APIs Only
3 participants