diff --git a/cli/cmd/tap.go b/cli/cmd/tap.go index abb10e801..00e59e90a 100644 --- a/cli/cmd/tap.go +++ b/cli/cmd/tap.go @@ -33,10 +33,6 @@ Supported protocols are HTTP and gRPC.`, return errors.New("unexpected number of arguments") } - if err := config.Config.Validate(); err != nil { - return errormessage.FormatError(err) - } - if err := config.Config.Tap.Validate(); err != nil { return errormessage.FormatError(err) } diff --git a/cli/cmd/tapRunner.go b/cli/cmd/tapRunner.go index e7341cc28..762c1222f 100644 --- a/cli/cmd/tapRunner.go +++ b/cli/cmd/tapRunner.go @@ -72,6 +72,14 @@ func RunMizuTap() { targetNamespaces := getNamespaces(kubernetesProvider) + if config.Config.IsNsRestrictedMode() { + if len(targetNamespaces) != 1 || !mizu.Contains(targetNamespaces, config.Config.MizuResourcesNamespace) { + logger.Log.Errorf("Not supported mode. Mizu can't resolve IPs in other namespaces when running in namespace restricted mode.\n"+ + "You can use the same namespace for --%s and --%s", configStructs.NamespacesTapName, config.MizuResourcesNamespaceConfigName) + return + } + } + var namespacesStr string if !mizu.Contains(targetNamespaces, mizu.K8sAllNamespaces) { namespacesStr = fmt.Sprintf("namespaces \"%s\"", strings.Join(targetNamespaces, "\", \"")) diff --git a/cli/config/config.go b/cli/config/config.go index 4bd8d97f2..e1f66c036 100644 --- a/cli/config/config.go +++ b/cli/config/config.go @@ -3,7 +3,6 @@ package config import ( "errors" "fmt" - "github.com/up9inc/mizu/cli/config/configStructs" "github.com/up9inc/mizu/cli/logger" "github.com/up9inc/mizu/cli/mizu" "io/ioutil" @@ -32,17 +31,6 @@ var ( cmdName string ) -func (config *ConfigStruct) Validate() error { - if config.IsNsRestrictedMode() { - if config.Tap.AllNamespaces || len(config.Tap.Namespaces) != 1 || config.Tap.Namespaces[0] != config.MizuResourcesNamespace { - return fmt.Errorf("Not supported mode. Mizu can't resolve IPs in other namespaces when running in namespace restricted mode.\n"+ - "You can use the same namespace for --%s and --%s", configStructs.NamespacesTapName, MizuResourcesNamespaceConfigName) - } - } - - return nil -} - func InitConfig(cmd *cobra.Command) error { cmdName = cmd.Name()