diff --git a/api/http/handler/stacks/stack_update_git.go b/api/http/handler/stacks/stack_update_git.go index fa8d0f3d4..8df53c616 100644 --- a/api/http/handler/stacks/stack_update_git.go +++ b/api/http/handler/stacks/stack_update_git.go @@ -146,6 +146,7 @@ func (handler *Handler) stackUpdateGit(w http.ResponseWriter, r *http.Request) * if stack.CurrentDeploymentInfo == nil && stack.GitConfig != nil { stack.CurrentDeploymentInfo = &portainer.StackDeploymentInfo{ RepositoryURL: stack.GitConfig.URL, + ReferenceName: stack.GitConfig.ReferenceName, ConfigFilePath: stack.GitConfig.ConfigFilePath, AdditionalFiles: stack.AdditionalFiles, ConfigHash: stack.GitConfig.ConfigHash, diff --git a/api/http/handler/stacks/stack_update_git_redeploy.go b/api/http/handler/stacks/stack_update_git_redeploy.go index f745477bc..db4e4529b 100644 --- a/api/http/handler/stacks/stack_update_git_redeploy.go +++ b/api/http/handler/stacks/stack_update_git_redeploy.go @@ -1,6 +1,7 @@ package stacks import ( + "cmp" "context" "net/http" "time" @@ -26,7 +27,7 @@ type stackGitRedeployPayload struct { RepositoryUsername string RepositoryPassword string Env []portainer.Pair - Prune bool + Prune *bool // RepullImageAndRedeploy indicates whether to force repulling images and redeploying the stack RepullImageAndRedeploy bool @@ -128,16 +129,23 @@ func (handler *Handler) stackGitRedeploy(w http.ResponseWriter, r *http.Request) return httperror.BadRequest("Invalid request payload", err) } payload.RepullImageAndRedeploy = payload.RepullImageAndRedeploy || payload.PullImage - stack.GitConfig.ReferenceName = payload.RepositoryReferenceName - stack.Env = payload.Env - if stack.Type == portainer.DockerSwarmStack || stack.Type == portainer.DockerComposeStack { - if stack.Option == nil { - stack.Option = &portainer.StackOption{} - } - stack.Option.Prune = payload.Prune + + stack.GitConfig.ReferenceName = cmp.Or(payload.RepositoryReferenceName, stack.GitConfig.ReferenceName) + + if payload.Env != nil { + stack.Env = payload.Env } - if stack.Type == portainer.KubernetesStack { + if payload.Prune != nil { + if stack.Type == portainer.DockerSwarmStack || stack.Type == portainer.DockerComposeStack { + if stack.Option == nil { + stack.Option = &portainer.StackOption{} + } + stack.Option.Prune = *payload.Prune + } + } + + if stack.Type == portainer.KubernetesStack && payload.StackName != "" { stack.Name = payload.StackName } @@ -186,6 +194,7 @@ func (handler *Handler) stackGitRedeploy(w http.ResponseWriter, r *http.Request) } stack.CurrentDeploymentInfo = &portainer.StackDeploymentInfo{ RepositoryURL: stack.GitConfig.URL, + ReferenceName: stack.GitConfig.ReferenceName, ConfigFilePath: stack.GitConfig.ConfigFilePath, AdditionalFiles: stack.AdditionalFiles, ConfigHash: stack.GitConfig.ConfigHash, diff --git a/api/portainer.go b/api/portainer.go index ca6484665..dd87cfce1 100644 --- a/api/portainer.go +++ b/api/portainer.go @@ -344,6 +344,8 @@ type ( RepositoryURL string `json:"RepositoryURL,omitempty"` // ConfigFilePath is the path to the config file in the git repository used for deploying the stack ConfigFilePath string `json:"ConfigFilePath,omitempty"` + // ReferenceName is the git reference (branch/tag) used for deploying the stack + ReferenceName string `json:"ReferenceName,omitempty"` // AdditionalFiles are the additional files used for deploying the stack AdditionalFiles []string `json:"AdditionalFiles,omitempty"` } diff --git a/api/stacks/deployments/deploy.go b/api/stacks/deployments/deploy.go index 79d3f079b..8909fc33a 100644 --- a/api/stacks/deployments/deploy.go +++ b/api/stacks/deployments/deploy.go @@ -146,6 +146,7 @@ func redeployWhenChangedSecondStage( stack.CurrentDeploymentInfo = &portainer.StackDeploymentInfo{ RepositoryURL: stack.GitConfig.URL, + ReferenceName: stack.GitConfig.ReferenceName, ConfigFilePath: stack.GitConfig.ConfigFilePath, AdditionalFiles: stack.AdditionalFiles, ConfigHash: stack.GitConfig.ConfigHash, diff --git a/app/kubernetes/__module.js b/app/kubernetes/__module.js index 965b86321..83fc6c4fd 100644 --- a/app/kubernetes/__module.js +++ b/app/kubernetes/__module.js @@ -268,6 +268,9 @@ angular.module('portainer.kubernetes', ['portainer.app', registriesModule, custo const application = { name: 'kubernetes.applications.application', url: '/:namespace/:name?resource-type', + params: { + openGitSettings: { value: null, dynamic: true }, + }, views: { 'content@': { component: 'applicationDetailsView', diff --git a/app/kubernetes/views/applications/create/createApplication.html b/app/kubernetes/views/applications/create/createApplication.html index 6b061ad1f..ba32499a3 100644 --- a/app/kubernetes/views/applications/create/createApplication.html +++ b/app/kubernetes/views/applications/create/createApplication.html @@ -103,7 +103,7 @@ > -