diff --git a/cmd/backup/app.go b/cmd/backup/app.go index f261e0ab..7393dca6 100644 --- a/cmd/backup/app.go +++ b/cmd/backup/app.go @@ -17,6 +17,7 @@ import ( "github.com/easysoft/qcadmin/internal/api/cne" "github.com/easysoft/qcadmin/internal/pkg/util/factory" + "github.com/easysoft/qcadmin/internal/pkg/util/kutil" "github.com/easysoft/qcadmin/internal/pkg/util/output" ) @@ -43,6 +44,9 @@ func newCmdBackupAppCreate(f factory.Factory) *cobra.Command { if len(app) == 0 || len(ns) == 0 { return errors.New("missing app or ns") } + if !kutil.ValidNamespace(ns) { + return errors.New("allow support quickon prefix namespace") + } return nil }, Run: func(cmd *cobra.Command, args []string) { @@ -99,6 +103,9 @@ func newCmdBackupAppList(f factory.Factory) *cobra.Command { if len(app) == 0 || len(ns) == 0 { return errors.New("missing app or ns") } + if !kutil.ValidNamespace(ns) { + return errors.New("allow support quickon prefix namespace") + } return nil }, RunE: func(cmd *cobra.Command, args []string) error { diff --git a/internal/pkg/util/kutil/kutil.go b/internal/pkg/util/kutil/kutil.go index f0258cb2..5e63de84 100644 --- a/internal/pkg/util/kutil/kutil.go +++ b/internal/pkg/util/kutil/kutil.go @@ -86,3 +86,13 @@ func GetConsoleURL(cfg *config.Config) string { } return domain } + +// ValidNamespace valid namespace +func ValidNamespace(ns string) bool { + switch ns { + case common.DefaultAppNamespace, common.DefaultSystemNamespace: + return true + default: + return false + } +}