Skip to content

feat(cmd): add 'update' subcommand for build resources - #413

Closed
mohit-bhandari45 wants to merge 5 commits into
shipwright-io:mainfrom
mohit-bhandari45:feat/add-build-update-subcommand
Closed

feat(cmd): add 'update' subcommand for build resources#413
mohit-bhandari45 wants to merge 5 commits into
shipwright-io:mainfrom
mohit-bhandari45:feat/add-build-update-subcommand

Conversation

@mohit-bhandari45

Copy link
Copy Markdown

Changes

Introduced the missing update subcommand for build resource manager (shp build update):

  • shp build update <name> [flags]: Allows updating existing Build object specifications (e.g. --source-git-url, --source-git-revision, --output-image, --strategy-name, --source-context-dir, --dockerfile, --builder-image, etc.) directly from the CLI.
  • Selective Field Updates: Inspects which CLI flags were explicitly provided by the user using Cobra's Flags().Changed(...) to only modify specified fields without overwriting un-flagged spec fields.
  • Error Handling: Gracefully handles missing builds with a user-friendly Build 'xyz' not found in namespace 'default'. error message.
  • Unit Tests: Added comprehensive unit test suite in pkg/shp/cmd/build/update_test.go covering success and NotFound cases (100% passing).

Related Issue

Fixes #411

Type of PR

/kind feature

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Kind label has been set
  • Release notes block has been filled in, or marked NONE

Release Notes

Added `shp build update <name>` subcommand allowing users to modify existing Build resource specifications directly from the CLI.

Signed-off-by: mohit-bhandari45 <mohitbhandari852@gmail.com>
Signed-off-by: mohit-bhandari45 <mohitbhandari852@gmail.com>
Signed-off-by: mohit-bhandari45 <mohitbhandari852@gmail.com>
Signed-off-by: mohit-bhandari45 <mohitbhandari852@gmail.com>
Signed-off-by: mohit-bhandari45 <mohitbhandari852@gmail.com>
Copilot AI balanced review requested due to automatic review settings September 11, 2026 07:03
@openshift-ci

openshift-ci Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci openshift-ci Bot added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 11, 2026
@pull-request-size pull-request-size Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 11, 2026
@openshift-ci openshift-ci Bot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Sep 11, 2026
@openshift-ci

openshift-ci Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign heavywombat for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Critical correctness, lint, and generated-documentation issues remain unresolved.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds get commands for Build and BuildRun resources and a selective build update command with tests.

Changes:

  • Adds table, JSON, and YAML retrieval.
  • Adds flag-based Build updates and not-found handling.
  • Registers new commands and adds unit tests.
File summaries
File Summary
pkg/shp/cmd/buildrun/get.go Adds BuildRun retrieval; exported methods need revive comments (critical, 1 vote).
pkg/shp/cmd/buildrun/get_test.go Tests BuildRun retrieval output and errors.
pkg/shp/cmd/buildrun/buildrun.go Registers get; generated BuildRun docs are missing (critical, 3 votes).
pkg/shp/cmd/build/update.go Some flags are silently ignored, local sources can be removed, and deprecated aliases skip updates (critical/moderate findings).
pkg/shp/cmd/build/update_test.go Tests successful and missing Build updates.
pkg/shp/cmd/build/get.go Can panic when a Build has no source (critical, 3 votes).
pkg/shp/cmd/build/get_test.go Tests Build output formats and not-found handling.
pkg/shp/cmd/build/build.go Registers commands; generated Build docs are missing (critical, 3 votes).
Review details

Suppressed comments (2)

pkg/shp/cmd/build/update.go:82

  • --source-url is a registered deprecated alias for --source-git-url and writes to the same value, but Cobra tracks Changed separately for each flag. Using the advertised alias leaves this condition false, so the URL update is silently skipped; include flags.SourceURLFlag in the changed check.
	if c.cmd.Flags().Changed(flags.SourceGitURLFlag) && c.buildSpec.Source != nil && c.buildSpec.Source.Git != nil {

pkg/shp/cmd/build/update.go:94

  • --source-revision is a registered deprecated alias for --source-git-revision, but Cobra tracks Changed separately for each flag. Using that alias leaves this condition false and silently skips the revision update; include flags.SourceRevisionFlag in the changed check.
	if c.cmd.Flags().Changed(flags.SourceGitRevisionFlag) && c.buildSpec.Source != nil && c.buildSpec.Source.Git != nil {
  • Files reviewed: 8/8 changed files
  • Comments generated: 6
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/shp/cmd/build/build.go
Comment thread pkg/shp/cmd/build/get.go
Comment thread pkg/shp/cmd/build/update.go
Comment thread pkg/shp/cmd/build/update.go
Comment thread pkg/shp/cmd/buildrun/buildrun.go
Comment thread pkg/shp/cmd/buildrun/get.go
@mohit-bhandari45

Copy link
Copy Markdown
Author

closed because of unnecessary changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. kind/feature Categorizes issue or PR as related to a new feature. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add missing get and update subcommands for build and buildrun

3 participants