Skip to content

Commit

Permalink
Merge pull request nephio-project#177 from nokia/porchctl-full-resour…
Browse files Browse the repository at this point in the history
…ce-path

Use full resource paths in porchctl repo/rpkg get
  • Loading branch information
nephio-prow[bot] authored Feb 6, 2025
2 parents f9ed20a + a778894 commit 1d6ba30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions pkg/cli/commands/repo/get/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import (
)

const (
command = "cmdrepoget"
command = "cmdrepoget"
resourceName = "repositories.config.porch.kpt.dev"
)

func NewCommand(ctx context.Context, rcg *genericclioptions.ConfigFlags) *cobra.Command {
Expand Down Expand Up @@ -108,10 +109,10 @@ func (r *runner) runE(cmd *cobra.Command, args []string) error {
b = b.Unstructured()

if len(args) > 0 {
b.ResourceNames("repository", args...)
b.ResourceNames(resourceName, args...)
} else {
b = b.SelectAllParam(true).
ResourceTypes("repository")
ResourceTypes(resourceName)
}

b = b.ContinueOnError().Latest().Flatten()
Expand Down
7 changes: 4 additions & 3 deletions pkg/cli/commands/rpkg/get/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import (
)

const (
command = "cmdrpkgget"
command = "cmdrpkgget"
resourceName = "packagerevisions.porch.kpt.dev"
)

func newRunner(ctx context.Context, rcg *genericclioptions.ConfigFlags) *runner {
Expand Down Expand Up @@ -126,12 +127,12 @@ func (r *runner) runE(cmd *cobra.Command, args []string) error {

useSelectors := true
if len(args) > 0 {
b = b.ResourceNames("packagerevisions", args...)
b = b.ResourceNames(resourceName, args...)
// We can't pass selectors here, get an error "Error: selectors and the all flag cannot be used when passing resource/name arguments"
// TODO: cli-utils bug? I think there is a metadata.name field selector (used for single object watch)
useSelectors = false
} else {
b = b.ResourceTypes("packagerevisions")
b = b.ResourceTypes(resourceName)
}

if useSelectors {
Expand Down

0 comments on commit 1d6ba30

Please sign in to comment.