Skip to content

porchctl improvments (v2) - #1168

Open
mozesl-nokia wants to merge 3 commits into
kptdev:mainfrom
nokia:porchctl-improv-v2
Open

porchctl improvments (v2)#1168
mozesl-nokia wants to merge 3 commits into
kptdev:mainfrom
nokia:porchctl-improv-v2

Conversation

@mozesl-nokia

@mozesl-nokia mozesl-nokia commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

porchctl improvments

Supersedes #554


Description

  • What changed:
    • Cleaned up porchctl rpkg get field selectors, made the selectors additive
    • Explicit --namespace is no longer necessary for most commands, will try to default to kubeconfig context, env var, or "default"
    • Added a bunch of aliases and shorthands for command flags
    • porchctl rpkg pull can now overwrite a folder's contents if it is the same package or --force is passed to it
  • Why it’s needed: To make porchctl more user friendly
  • How it works: See "What changed"

Related Issue(s)

  • None

Type of Change

  • Bug fix
  • Enhancement
  • Refactor
  • Tests

Checklist

  • Code follows project style guidelines
  • Self-reviewed changes
  • Tests added/updated
  • Documentation added/updated
  • All tests and gating checks pass

Additional Notes (Optional)

  • Review notes: A lot of the code is tests and test code, plus duplication for v1alpha2

AI Disclosure

  • I have used AI in the creation of this PR.

If so, please describe how:

  • Claude Sonnet 5 was used to analyse how the rebase should be done
  • Cursor Grok 4.6 did the porting over

Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Assisted-by: Cursor:claude-sonnet-5
Assisted-by: Cursor:grok-4.6
@mozesl-nokia
mozesl-nokia requested review from a team September 1, 2026 15:00
@mozesl-nokia mozesl-nokia added the enhancement New feature or request label Sep 1, 2026
@mozesl-nokia mozesl-nokia added go Pull requests that update go code refactoring #b33d8f labels Sep 1, 2026
@netlify

netlify Bot commented Sep 1, 2026

Copy link
Copy Markdown

Deploy Preview for kpt-porch ready!

Name Link
🔨 Latest commit 1773dae
🔍 Latest deploy log https://app.netlify.com/projects/kpt-porch/deploys/6a97de447d09fa00083d3c49
😎 Deploy Preview https://deploy-preview-1168--kpt-porch.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves porchctl CLI ergonomics by making namespace resolution more automatic, adding flag aliases/shorthands, refining rpkg get selectors to be additive, and enabling safer overwrites for rpkg pull, with corresponding unit and e2e test updates (including v1alpha2 parity).

Changes:

  • Add namespace auto-resolution (EnsureNamespace) and apply it across multiple rpkg/repo commands (v1alpha1 and v1alpha2).
  • Enhance CLI UX: new/updated flag shorthands and aliases, plus additive field selectors for rpkg get (incl. repository filtering).
  • Update/add tests and docs for the new behaviors; add install-porchctl make target and adjust main command execution wrapper.

Reviewed changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/e2e/cli/testdata/rpkg-pull-overwrite/config.yaml New e2e coverage for rpkg pull overwrite/--force behavior.
test/e2e/cli/testdata/rpkg-get/config.yaml Update golden output for --show-kptfile flag incompatibility message.
test/e2e/cli/testdata/rpkg-get-selectors/config.yaml New e2e coverage validating additive rpkg get selectors.
test/e2e/cli/testdata/rpkg-default-namespace/config.yaml New e2e coverage for default namespace resolution (no explicit --namespace).
test/e2e/cli/suite.go Test harness updates for default-namespace runs and repo registration handling.
test/e2e/cli/config.go Add defaultNamespace test-case configuration flag.
test/e2e/cli/cluster.go Logging format tweak for kubectl readiness checks.
test/e2e/cli-v1alpha2/testdata/rpkg-get/config.yaml Update v1alpha2 golden output for --show-kptfile incompatibility message.
pkg/cli/commands/rpkg/util/common.go Add EnsureNamespace, package-metadata helpers, and flag-alias normalization utility; update RunForEachPackage.
pkg/cli/commands/rpkg/util/common_test.go Add tests for namespace resolution, alias normalization, and metadata-based package comparison.
pkg/cli/commands/rpkg/reject/v1alpha2.go Use EnsureNamespace for v1alpha2 reject.
pkg/cli/commands/rpkg/reject/command.go Switch RunForEachPackage to pass ConfigFlags for namespace resolution.
pkg/cli/commands/rpkg/push/command.go Use EnsureNamespace when creating resources.
pkg/cli/commands/rpkg/pull/command.go Add --force/-f and allow overwriting dir when safe/forced.
pkg/cli/commands/rpkg/pull/command_test.go Add unit tests for overwrite behavior (same package vs different + --force).
pkg/cli/commands/rpkg/proposedelete/v1alpha2.go Use EnsureNamespace for v1alpha2 propose-delete.
pkg/cli/commands/rpkg/proposedelete/command.go Switch RunForEachPackage to pass ConfigFlags.
pkg/cli/commands/rpkg/propose/v1alpha2.go Use EnsureNamespace for v1alpha2 propose.
pkg/cli/commands/rpkg/propose/command.go Switch RunForEachPackage to pass ConfigFlags.
pkg/cli/commands/rpkg/init/v1alpha2.go Use EnsureNamespace for v1alpha2 init checks/creation.
pkg/cli/commands/rpkg/init/command.go Add -d/-r/-w and aliases (--repo/--ws/--desc) via normalization; use EnsureNamespace.
pkg/cli/commands/rpkg/get/v1alpha2.go Make selectors additive via shared selector builder; add repository filtering.
pkg/cli/commands/rpkg/get/v1alpha2_test.go Add v1alpha2 repository filter test.
pkg/cli/commands/rpkg/get/command.go Add --repository/-r and aliases; implement additive selector string; add repository filtering.
pkg/cli/commands/rpkg/get/command_test.go Update/extend tests for repository filtering and alias parsing.
pkg/cli/commands/rpkg/docs/docs.go Update docs to reflect new flags/aliases and rpkg pull --force.
pkg/cli/commands/rpkg/del/v1alpha2.go Use EnsureNamespace for v1alpha2 delete.
pkg/cli/commands/rpkg/del/command.go Use EnsureNamespace for v1alpha1 delete.
pkg/cli/commands/rpkg/copy/v1alpha2.go Use EnsureNamespace for v1alpha2 copy.
pkg/cli/commands/rpkg/copy/command.go Add -w/--ws aliasing and use EnsureNamespace.
pkg/cli/commands/rpkg/copy/command_test.go Add alias parsing test for --ws.
pkg/cli/commands/rpkg/clone/v1alpha2.go Use EnsureNamespace for v1alpha2 clone.
pkg/cli/commands/rpkg/clone/command.go Use EnsureNamespace for v1alpha1 clone paths.
pkg/cli/commands/rpkg/approve/v1alpha2.go Use EnsureNamespace for v1alpha2 approve.
pkg/cli/commands/rpkg/approve/command.go Switch RunForEachPackage to pass ConfigFlags.
pkg/cli/commands/repo/unreg/command.go Replace manual namespace handling with EnsureNamespace.
pkg/cli/commands/repo/reg/command.go Add -d and flag aliases; use EnsureNamespace instead of manual kubeconfig namespace logic.
pkg/cli/commands/repo/docs/docs.go Update repo docs for new aliases/flag formatting.
make/build.mk Add install-porchctl make target.
cmd/porchctl/main.go Replace component-base/cli helper with local wrapper to avoid global normalization side-effects.

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

Comment thread test/e2e/cli/suite.go
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@sonarqubecloud

sonarqubecloud Bot commented Sep 2, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
78.7% Coverage on New Code (required ≥ 80%)
8.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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

Labels

enhancement New feature or request go Pull requests that update go code refactoring #b33d8f

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants