Fix : Prints empty list in json/yaml is no repositories are present (#7949)

* Prints empty repolist in json/yaml if there are no repos and output format is given as json/yaml rather that printing the error msg "no repositories to show"

Signed-off-by: Anshul Verma <anshulvermapatel@gmail.com>

* Prints empty repolist in json/yaml if there are no repos and output format is given as json/yaml rather that printing the error msg "no repositories to show"

Signed-off-by: Anshul Verma <anshulvermapatel@gmail.com>
pull/8011/head
Anshul Verma 5 years ago committed by GitHub
parent e29ed7a108
commit cd50d0c362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -38,7 +38,7 @@ func newRepoListCmd(out io.Writer) *cobra.Command {
Args: require.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
f, err := repo.LoadFile(settings.RepositoryConfig)
if isNotExist(err) || len(f.Repositories) == 0 {
if isNotExist(err) || (len(f.Repositories) == 0 && !(outfmt == output.JSON || outfmt == output.YAML)) {
return errors.New("no repositories to show")
}

Loading…
Cancel
Save