Skip to content

Commit

Permalink
fix misleading messaging when using -A flag
Browse files Browse the repository at this point in the history
Before:

```
$ flux get source git -A
✗ no GitRepository objects found in flux-system namespace
```

After:

```
$ flux get source git -A
✗ no GitRepository objects found in any namespace
```

Signed-off-by: Max Jonas Werner <max@e13.dev>
  • Loading branch information
makkes committed Jan 30, 2023
1 parent 7da8ffd commit 0648f56
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions cmd/flux/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,16 @@ func (get getCommand) run(cmd *cobra.Command, args []string) error {

if get.list.len() == 0 {
if len(args) > 0 {
logger.Failuref("%s object '%s' not found in '%s' namespace", get.kind, args[0], *kubeconfigArgs.Namespace)
logger.Failuref("%s object '%s' not found in %s namespace",
get.kind,
args[0],
namespaceNameOrAny(getArgs.allNamespaces, *kubeconfigArgs.Namespace),
)
} else if !getAll {
logger.Failuref("no %s objects found in %s namespace", get.kind, *kubeconfigArgs.Namespace)
logger.Failuref("no %s objects found in %s namespace",
get.kind,
namespaceNameOrAny(getArgs.allNamespaces, *kubeconfigArgs.Namespace),
)
}
return nil
}
Expand All @@ -192,6 +199,13 @@ func (get getCommand) run(cmd *cobra.Command, args []string) error {
return nil
}

func namespaceNameOrAny(allNamespaces bool, namespaceName string) string {
if allNamespaces {
return "any"
}
return fmt.Sprintf("%q", namespaceName)
}

func getRowsToPrint(getAll bool, list summarisable) ([][]string, error) {
noFilter := true
var conditionType, conditionStatus string
Expand Down

0 comments on commit 0648f56

Please sign in to comment.