From 988d4103d430338a159ed0c17bbb656ebf0026c7 Mon Sep 17 00:00:00 2001 From: Prabhat Khera <91852476+prabhat-org@users.noreply.github.com> Date: Tue, 20 Feb 2024 09:23:46 +1300 Subject: [PATCH] fix(git): update stack name for git stacks [EE-6670] (#11217) --- api/http/handler/stacks/stack_update_git_redeploy.go | 6 ++++++ .../views/applications/create/createApplication.html | 1 + .../kubernetes-redeploy-app-git-form.controller.js | 4 ++++ .../kubernetes-redeploy-app-git-form.js | 1 + app/portainer/services/api/stackService.js | 1 + 5 files changed, 13 insertions(+) diff --git a/api/http/handler/stacks/stack_update_git_redeploy.go b/api/http/handler/stacks/stack_update_git_redeploy.go index 764886610..478ed0ae9 100644 --- a/api/http/handler/stacks/stack_update_git_redeploy.go +++ b/api/http/handler/stacks/stack_update_git_redeploy.go @@ -27,6 +27,8 @@ type stackGitRedployPayload struct { Prune bool // Force a pulling to current image with the original tag though the image is already the latest PullImage bool `example:"false"` + + StackName string } func (payload *stackGitRedployPayload) Validate(r *http.Request) error { @@ -136,6 +138,10 @@ func (handler *Handler) stackGitRedeploy(w http.ResponseWriter, r *http.Request) } } + if payload.StackName != "" { + stack.Name = payload.StackName + } + repositoryUsername := "" repositoryPassword := "" if payload.RepositoryAuthentication { diff --git a/app/kubernetes/views/applications/create/createApplication.html b/app/kubernetes/views/applications/create/createApplication.html index d045f654a..6298345da 100644 --- a/app/kubernetes/views/applications/create/createApplication.html +++ b/app/kubernetes/views/applications/create/createApplication.html @@ -180,6 +180,7 @@ ng-if="ctrl.state.appType === ctrl.KubernetesDeploymentTypes.GIT" stack="ctrl.stack" namespace="ctrl.formValues.ResourcePool.Namespace.Name" + stack-name="ctrl.formValues.StackName" > diff --git a/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.controller.js b/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.controller.js index e4eff1ca6..9123401a5 100644 --- a/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.controller.js +++ b/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.controller.js @@ -126,6 +126,10 @@ class KubernetesRedeployAppGitFormController { return; } + if (this.stack.Name !== this.stackName) { + this.formValues.StackName = this.stackName; + } + this.state.redeployInProgress = true; await this.StackService.updateKubeGit(this.stack.Id, this.stack.EndpointId, this.namespace, this.formValues); this.Notifications.success('Success', 'Pulled and redeployed stack successfully'); diff --git a/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.js b/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.js index 1590621bb..58b085d40 100644 --- a/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.js +++ b/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.js @@ -7,6 +7,7 @@ const kubernetesRedeployAppGitForm = { bindings: { stack: '<', namespace: '<', + stackName: '<', }, }; diff --git a/app/portainer/services/api/stackService.js b/app/portainer/services/api/stackService.js index 993c35c10..95af739f9 100644 --- a/app/portainer/services/api/stackService.js +++ b/app/portainer/services/api/stackService.js @@ -461,6 +461,7 @@ angular.module('portainer.app').factory('StackService', [ RepositoryAuthentication: gitConfig.RepositoryAuthentication, RepositoryUsername: gitConfig.RepositoryUsername, RepositoryPassword: gitConfig.RepositoryPassword, + StackName: gitConfig.StackName, } ).$promise; }