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:
neha_gupta
2022-10-11 13:23:47 +05:30
committed by GitHub
parent 0739aca920
commit b9513868ed
74 changed files with 1289 additions and 304 deletions
+19 -7
View File
@@ -61,7 +61,11 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
mqtName = id.String()
}
fnName := input.String(flagkey.MqtFnName)
fnNamespace := input.String(flagkey.NamespaceFunction)
userProvidedNS, fnNamespace, err := util.GetResourceNamespace(input, flagkey.NamespaceFunction)
if err != nil {
return errors.Wrap(err, "error in deleting function ")
}
mqtKind := input.String(flagkey.MqtKind)
@@ -94,7 +98,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
contentType = "application/json"
}
err := checkMQTopicAvailability(mqType, mqtKind, topic, respTopic)
err = checkMQTopicAvailability(mqType, mqtKind, topic, respTopic)
if err != nil {
return err
}
@@ -136,7 +140,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
exists, err := fr.ExistsInSpecs(fv1.Function{
ObjectMeta: metav1.ObjectMeta{
Name: fnName,
Namespace: fnNamespace,
Namespace: userProvidedNS,
},
})
if err != nil {
@@ -153,11 +157,19 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
}
}
opts.trigger = &fv1.MessageQueueTrigger{
ObjectMeta: metav1.ObjectMeta{
m := metav1.ObjectMeta{
Name: mqtName,
Namespace: fnNamespace,
}
if input.Bool(flagkey.SpecSave) || input.Bool(flagkey.SpecDry) {
m = metav1.ObjectMeta{
Name: mqtName,
Namespace: fnNamespace,
},
Namespace: userProvidedNS,
}
}
opts.trigger = &fv1.MessageQueueTrigger{
ObjectMeta: m,
Spec: fv1.MessageQueueTriggerSpec{
FunctionReference: fv1.FunctionReference{
Type: fv1.FunctionReferenceTypeFunctionName,