feat(template/gitops): support to add/update k8s custom template with git repository method

This commit is contained in:
oscarzhou
2022-10-18 15:28:32 +13:00
parent 64cd8d0bc1
commit aedae9b4ca
10 changed files with 219 additions and 43 deletions
@@ -53,6 +53,7 @@ func (b *K8sStackFileContentBuilder) SetUniqueInfo(payload *StackPayload) FileCo
b.stack.Namespace = payload.Namespace
b.stack.CreatedBy = b.User.Username
b.stack.IsComposeFormat = payload.ComposeFormat
b.stack.FromAppTemplate = payload.FromAppTemplate
return b
}
@@ -1,6 +1,7 @@
package stackbuilders
import (
"fmt"
"strconv"
"time"
@@ -76,7 +77,12 @@ func (b *GitMethodStackBuilder) SetGitRepository(payload *StackPayload) GitMetho
// Set the project path on the disk
b.stack.ProjectPath = b.fileService.GetStackProjectPath(stackFolder)
commitHash, err := stackutils.DownloadGitRepository(b.stack.ID, repoConfig, b.gitService, b.fileService)
getProjectPath := func() string {
stackFolder := fmt.Sprintf("%d", b.stack.ID)
return b.fileService.GetStackProjectPath(stackFolder)
}
commitHash, err := stackutils.DownloadGitRepository(repoConfig, b.gitService, getProjectPath)
if err != nil {
b.err = httperror.InternalServerError(err.Error(), err)
return b