From c037100b316635ca00bf8ee16d2b01054b242b29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Moreno=20Garc=C3=ADa?= Date: Wed, 27 Apr 2022 10:49:17 +0200 Subject: [PATCH] Allow to use bundle with no kubeconfig It should be possible to list and push bundles without having to have a valid kubeconfig. This change makes sure that no error is thrown if no kubeconfig is found while invoking `tkn bundle`. --- pkg/cmd/bundle/bundle.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/bundle/bundle.go b/pkg/cmd/bundle/bundle.go index 4f3a74ca7..eb61ba3eb 100644 --- a/pkg/cmd/bundle/bundle.go +++ b/pkg/cmd/bundle/bundle.go @@ -16,6 +16,7 @@ package bundle import ( "errors" + "strings" "github.com/spf13/cobra" "github.com/tektoncd/cli/pkg/cli" @@ -35,7 +36,16 @@ func Command(p cli.Params) *cobra.Command { "commandType": "main", }, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { - return flags.InitParams(p, cmd) + if err := flags.InitParams(p, cmd); err != nil { + // this check allows tkn version to be run without + // a kubeconfig so users can list and push bundles + noConfigErr := strings.Contains(err.Error(), "no configuration has been provided") + if noConfigErr { + return nil + } + return err + } + return nil }, }