Skip to content

Commit 8397c4b

Browse files
authored
fix: change operand list Run signature to include package name argument (#40)
Signed-off-by: Daniel Sover <[email protected]>
1 parent 8fb217d commit 8397c4b

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

internal/cmd/operator_list_operands.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ Operand kinds are determined from the owned CustomResourceDefinitions listed in
4242
the operator's ClusterServiceVersion.`,
4343
Args: cobra.ExactArgs(1),
4444
Run: func(cmd *cobra.Command, args []string) {
45-
l.PackageName = args[0]
46-
4745
writeOutput := func(io.Writer, *unstructured.UnstructuredList) error { panic("writeOutput was not set") }
4846
switch output {
4947
case "json":
@@ -56,7 +54,7 @@ the operator's ClusterServiceVersion.`,
5654
log.Fatalf("invalid value for flag output %q, expected one of %s", output, strings.Join(validOutputs, "|"))
5755
}
5856

59-
operands, err := l.Run(cmd.Context())
57+
operands, err := l.Run(cmd.Context(), args[0])
6058
if err != nil {
6159
log.Fatalf("list operands: %v", err)
6260
}

pkg/action/operator_list_operands.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ import (
1616

1717
// OperatorListOperands knows how to find and list custom resources given a package name and namespace.
1818
type OperatorListOperands struct {
19-
config *Configuration
20-
PackageName string
19+
config *Configuration
2120
}
2221

2322
func NewOperatorListOperands(cfg *Configuration) *OperatorListOperands {
@@ -26,9 +25,9 @@ func NewOperatorListOperands(cfg *Configuration) *OperatorListOperands {
2625
}
2726
}
2827

29-
func (o *OperatorListOperands) Run(ctx context.Context) (*unstructured.UnstructuredList, error) {
28+
func (o *OperatorListOperands) Run(ctx context.Context, packageName string) (*unstructured.UnstructuredList, error) {
3029
opKey := types.NamespacedName{
31-
Name: fmt.Sprintf("%s.%s", o.PackageName, o.config.Namespace),
30+
Name: fmt.Sprintf("%s.%s", packageName, o.config.Namespace),
3231
}
3332

3433
result, err := o.listAll(ctx, opKey)

0 commit comments

Comments
 (0)