add namespace param for fn and env (#2556)
This PR moves fission CLI as closer as possible to kubectl command behaviour. We have improved namespace handling behaviour across CLI. * add namespace param for fn and env * use common fn for ns check * update validation * default namespace for httpTrigger, env and package, config and triggers * use default ns * add namespace filter to spec * add forceNamespace flag * set current namespace * add default namespace in config * add namespace specific destroy * add all namespace in the list of resources * add namespace as global tag * use %s instead of %v * add test cases for namespace * use ns in get all functions
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
)
|
||||
|
||||
@@ -39,13 +40,18 @@ func ListPods(input cli.Input) error {
|
||||
return (&ListPodsSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *ListPodsSubCommand) do(input cli.Input) error {
|
||||
func (opts *ListPodsSubCommand) do(input cli.Input) (err error) {
|
||||
|
||||
_, currentNS, err := util.GetResourceNamespace(input, flagkey.NamespaceEnvironment)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating environment")
|
||||
}
|
||||
|
||||
// validate environment
|
||||
_, err := opts.Client().V1().Environment().Get(
|
||||
_, err = opts.Client().V1().Environment().Get(
|
||||
&metav1.ObjectMeta{
|
||||
Name: input.String(flagkey.EnvName),
|
||||
Namespace: input.String(flagkey.NamespaceEnvironment),
|
||||
Namespace: currentNS,
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting environment")
|
||||
@@ -54,7 +60,7 @@ func (opts *ListPodsSubCommand) do(input cli.Input) error {
|
||||
m := &metav1.ObjectMeta{
|
||||
Name: input.String(flagkey.EnvName),
|
||||
Labels: map[string]string{
|
||||
v1.ENVIRONMENT_NAMESPACE: input.String(flagkey.NamespaceEnvironment),
|
||||
v1.ENVIRONMENT_NAMESPACE: currentNS,
|
||||
v1.EXECUTOR_TYPE: input.String(flagkey.EnvExecutorType),
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user