From 98b8d6d0b2e068d447e6ab7b20a3ca3335f6dff7 Mon Sep 17 00:00:00 2001 From: Hui Date: Fri, 12 Nov 2021 11:52:09 +1300 Subject: [PATCH] fix(stack): git credential got reset when updating docker stack EE-1967 --- api/http/handler/stacks/stack_update_git.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/http/handler/stacks/stack_update_git.go b/api/http/handler/stacks/stack_update_git.go index da4df4e42..75713e14d 100644 --- a/api/http/handler/stacks/stack_update_git.go +++ b/api/http/handler/stacks/stack_update_git.go @@ -136,7 +136,6 @@ func (handler *Handler) stackUpdateGit(w http.ResponseWriter, r *http.Request) * stack.UpdatedBy = user.Username stack.UpdateDate = time.Now().Unix() - stack.GitConfig.Authentication = nil if payload.RepositoryAuthentication { password := payload.RepositoryPassword if password == "" && stack.GitConfig != nil && stack.GitConfig.Authentication != nil { @@ -150,6 +149,8 @@ func (handler *Handler) stackUpdateGit(w http.ResponseWriter, r *http.Request) * if err != nil { return &httperror.HandlerError{StatusCode: http.StatusInternalServerError, Message: "Unable to fetch git repository", Err: err} } + } else { + stack.GitConfig.Authentication = nil } if payload.AutoUpdate != nil && payload.AutoUpdate.Interval != "" {