From a598b2d72d13758845e2b58c0cba38e74c5cc78b Mon Sep 17 00:00:00 2001 From: Richard Wei <54336863+WaysonWei@users.noreply.github.com> Date: Tue, 23 Nov 2021 09:51:02 +1300 Subject: [PATCH] change the namespace selector behavior (#5768) --- api/http/handler/stacks/create_kubernetes_stack.go | 6 ------ app/kubernetes/views/deploy/deployController.js | 9 ++++++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/api/http/handler/stacks/create_kubernetes_stack.go b/api/http/handler/stacks/create_kubernetes_stack.go index 654bda92f..a872304b4 100644 --- a/api/http/handler/stacks/create_kubernetes_stack.go +++ b/api/http/handler/stacks/create_kubernetes_stack.go @@ -54,9 +54,6 @@ func (payload *kubernetesStringDeploymentPayload) Validate(r *http.Request) erro if govalidator.IsNull(payload.StackFileContent) { return errors.New("Invalid stack file content") } - if govalidator.IsNull(payload.Namespace) { - return errors.New("Invalid namespace") - } if govalidator.IsNull(payload.StackName) { return errors.New("Invalid stack name") } @@ -64,9 +61,6 @@ func (payload *kubernetesStringDeploymentPayload) Validate(r *http.Request) erro } func (payload *kubernetesGitDeploymentPayload) Validate(r *http.Request) error { - if govalidator.IsNull(payload.Namespace) { - return errors.New("Invalid namespace") - } if govalidator.IsNull(payload.RepositoryURL) || !govalidator.IsURL(payload.RepositoryURL) { return errors.New("Invalid repository URL. Must correspond to a valid URL format") } diff --git a/app/kubernetes/views/deploy/deployController.js b/app/kubernetes/views/deploy/deployController.js index b7d41c87b..41bcb92c2 100644 --- a/app/kubernetes/views/deploy/deployController.js +++ b/app/kubernetes/views/deploy/deployController.js @@ -70,6 +70,7 @@ class KubernetesDeployController { RepositoryFetchInterval: '5m', RepositoryWebhookURL: this.WebhookHelper.returnStackWebhookUrl(uuidv4()), }; + this.ManifestDeployTypes = KubernetesDeployManifestTypes; this.BuildMethods = KubernetesDeployBuildMethods; this.endpointId = this.EndpointProvider.endpointID(); @@ -209,9 +210,15 @@ class KubernetesDeployController { throw new PortainerError('Unable to determine build method'); } + let deployNamespace = ''; + + if (this.formValues.Namespace !== 'default') { + deployNamespace = this.formValues.Namespace; + } + const payload = { ComposeFormat: composeFormat, - Namespace: this.formValues.Namespace, + Namespace: deployNamespace, StackName: this.formValues.StackName, };