Skip to content

Commit

Permalink
Merge pull request #80 from dgeorgievski/fix-porchctl-cmds
Browse files Browse the repository at this point in the history
Porchctl repo command fixes
  • Loading branch information
nephio-prow[bot] authored Nov 14, 2024
2 parents a69870d + 1152765 commit a974d65
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/cli/commands/repo/get/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ func (r *runner) preRunE(cmd *cobra.Command, _ []string) error {
} else {
r.requestTable = true
}

allNamespacesFlag := cmd.Flags().Lookup("all-namespaces").Value.String()
if strings.Contains(allNamespacesFlag, "true") {
r.printFlags.HumanReadableFlags.WithNamespace = true
} else {
r.printFlags.HumanReadableFlags.WithNamespace = false
}
return nil
}

Expand Down
11 changes: 11 additions & 0 deletions pkg/cli/commands/repo/reg/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ type runner struct {

func (r *runner) preRunE(_ *cobra.Command, _ []string) error {
const op errors.Op = command + ".preRunE"

// todo if namespace flag missing, use kubeconfig
if *r.cfg.Namespace == "" {
// Get the namespace from kubeconfig
namespace, _, err := r.cfg.ToRawKubeConfigLoader().Namespace()
if err != nil {
return fmt.Errorf("error getting namespace: %w", err)
}
r.cfg.Namespace = &namespace
}

client, err := porch.CreateClientWithFlags(r.cfg)
if err != nil {
return errors.E(op, err)
Expand Down
10 changes: 10 additions & 0 deletions pkg/cli/commands/repo/unreg/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ type runner struct {

func (r *runner) preRunE(_ *cobra.Command, _ []string) error {
const op errors.Op = command + ".preRunE"

if *r.cfg.Namespace == "" {
// Get the namespace from kubeconfig
namespace, _, err := r.cfg.ToRawKubeConfigLoader().Namespace()
if err != nil {
return fmt.Errorf("error getting namespace: %w", err)
}
r.cfg.Namespace = &namespace
}

client, err := porch.CreateClientWithFlags(r.cfg)
if err != nil {
return errors.E(op, err)
Expand Down

0 comments on commit a974d65

Please sign in to comment.