Skip to content

Commit

Permalink
Fix JSON/YAML output when there are no outputs (#101)
Browse files Browse the repository at this point in the history
* Fix JSON/YAML output

* Update output_test.go
  • Loading branch information
rbren authored Jul 9, 2020
1 parent 20f146d commit 88b8501
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/api/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ type Instance struct {

// DisplayOutput prints the output based on desired variables
func (instance *Instance) DisplayOutput() error {
if len(instance.Outputs) == 0 {
fmt.Println("There were no apiVersions found that match our records.")
if len(instance.Outputs) == 0 && (instance.OutputFormat == "normal" || instance.OutputFormat == "wide") {
fmt.Println("There were no resources found with known deprecated apiVersions.")
return nil
}
instance.filterOutput()
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func ExampleInstance_DisplayOutput_zeroLength() {
}
_ = instance.DisplayOutput()

// Output: There were no apiVersions found that match our records.
// Output: There were no resources found with known deprecated apiVersions.
}

func TestGetReturnCode(t *testing.T) {
Expand Down

0 comments on commit 88b8501

Please sign in to comment.