Skip to content

Commit b18fac6

Browse files
authored
Merge pull request #1370 from devstream-io/main
bugfix for v0.10.3
2 parents 17ddd2c + e15442c commit b18fac6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+724
-1069
lines changed

.github/ISSUE_TEMPLATE/bug-report.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ body:
2828
label: 'DevStream Version'
2929
description: "To find out the version run: `dtm version`"
3030
options:
31-
- < v0.10.0
32-
- v0.10.0
31+
- < v0.10.3
32+
- v0.10.3
3333
- latest
3434
validations:
3535
required: true

.github/sync-staging-repo.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
devstream-io/dtm-gitlab-share-library:
2-
- source: staging/dtm-gitlab-share-library/
1+
devstream-io/dtm-jenkins-share-library:
2+
- source: staging/dtm-jenkins-share-library/
33
dest: .
44
deleteOrphaned: true
55
devstream-io/dtm-pipeline-templates:

.github/workflows/automated-release.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ jobs:
4141
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
4242
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
4343
aws-region: ap-southeast-1
44+
- name: check md5 & commit
45+
run: git rev-parse HEAD && md5sum dtm*
4446
- name: upload core
4547
run: bash -e ./hack/release/upload_dtm_core.sh ${{ secrets.GITHUB_TOKEN }} ${{ env.TAG }} ${{ env.GOOS }} ${{ env.GOARCH }}
4648
- name: upload plugin
@@ -83,4 +85,3 @@ jobs:
8385
run: bash -e ./hack/release/upload_dtm_core.sh ${{ secrets.GITHUB_TOKEN }} ${{ env.TAG }} ${{ env.GOOS }} ${{ env.GOARCH }}
8486
- name: upload plugins to s3
8587
run: aws s3 cp ~/.devstream/plugins/ s3://download.devstream.io/${{ env.TAG }}/ --recursive --acl public-read
86-

cmd/devstream/init.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@ func GetPluginsFromFlags() (tools configmanager.Tools, err error) {
9191
// check if plugins to download are supported by dtm
9292
for _, plugin := range pluginsName {
9393
if _, ok := list.PluginNamesMap()[plugin]; !ok {
94-
return nil, fmt.Errorf("Plugin %s is not supported by dtm", plugin)
94+
return nil, fmt.Errorf("plugin %s is not supported by dtm", plugin)
9595
}
9696
}
9797
}
9898

9999
if len(pluginsName) == 0 {
100-
return nil, errors.New("Please use --plugins to specify plugins to download or use --all to download all plugins.")
100+
return nil, errors.New("please use --plugins to specify plugins to download or use --all to download all plugins")
101101
}
102102
log.Debugf("plugins to download: %v", pluginsName)
103103

104104
if initOS == "" || initArch == "" {
105-
return nil, fmt.Errorf("Once you use the --all flag, you must specify the --os and --arch flags")
105+
return nil, fmt.Errorf("once you use the --all flag, you must specify the --os and --arch flags")
106106
}
107107

108108
log.Infof("Plugins to download: %v", pluginsName)

hack/release/auto-release-darwin-arm64.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pip3 install awscli
7373
aws s3 cp $plugin_dir $STORAGE_URL_WITH_TAG --recursive --acl public-read
7474

7575
# check if the number of plugins on s3 is correct
76-
local_plugin_nums=$(../../dtm list plugins |wc -l)
76+
local_plugin_nums=$(./dtm list plugins |wc -l)
7777
((local_plugin_file_nums=local_plugin_nums*6))
7878
s3_plugin_file_total_nums=$(aws s3 ls download.devstream.io/"$tag"/|awk '{print $NF}'|uniq|wc -l)
7979
((s3_plugin_file_nums=s3_plugin_file_total_nums-3))

internal/pkg/configmanager/pipelineDefault.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ func pipelineArgocdAppGenerator(options RawOptions, globalVars *pipelineGlobalOp
8383
sourceMap := source.(RawOptions)
8484
if _, repoURLExist := sourceMap["repoURL"]; !repoURLExist {
8585
sourceMap["repoURL"] = globalVars.Repo.GetCloneURL()
86+
sourceMap["repoBranch"] = globalVars.Repo.Branch
8687
}
8788
options["source"] = sourceMap
8889
} else {
8990
options["source"] = RawOptions{
90-
"valuefile": "values.yaml",
91-
"path": fmt.Sprintf("helm/%s", globalVars.AppName),
92-
"repoURL": string(globalVars.Repo.GetCloneURL()),
91+
"valuefile": "values.yaml",
92+
"path": fmt.Sprintf("helm/%s", globalVars.AppName),
93+
"repoURL": string(globalVars.Repo.GetCloneURL()),
94+
"repoBranch": globalVars.Repo.Branch,
9395
}
9496
}
9597
// config imageRepo default options

internal/pkg/configmanager/pipelineDefault_test.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ var _ = Describe("pipelineArgocdAppGenerator func", func() {
6969
},
7070
Repo: &git.RepoInfo{
7171
CloneURL: "scm.test.com",
72+
Branch: "testBranch",
7273
},
7374
AppName: "test_app",
7475
}
@@ -85,9 +86,10 @@ var _ = Describe("pipelineArgocdAppGenerator func", func() {
8586
"namespace": "default",
8687
},
8788
"source": RawOptions{
88-
"valuefile": "values.yaml",
89-
"path": "helm/test_app",
90-
"repoURL": "https://scm.test.com",
89+
"valuefile": "values.yaml",
90+
"path": "helm/test_app",
91+
"repoURL": "https://scm.test.com",
92+
"repoBranch": "testBranch",
9193
},
9294
"imageRepo": RawOptions{
9395
"owner": "test_user",

internal/pkg/configmanager/variables.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ import (
88
func renderConfigWithVariables(fileContent string, variables map[string]interface{}) ([]byte, error) {
99
logFunc(fileContent, variables)
1010

11-
str, err := template.New().
12-
FromContent(fileContent).
13-
AddDotForVariablesInConfigProcessor().
14-
AddQuoteForVariablesInConfigProcessor().
15-
SetDefaultRender(fileContent, variables).
16-
Render()
11+
str, err := template.NewRenderClient(&template.TemplateOption{
12+
Name: "configmanager",
13+
}, template.ContentGetter, template.AddDotForVariablesInConfigProcessor, template.AddQuoteForVariablesInConfigProcessor,
14+
).Render(fileContent, variables)
1715

1816
if err != nil {
1917
return nil, err

internal/pkg/develop/plugin/plugin.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ func (p *Plugin) renderTplString(tplStr string) (string, error) {
7979
"dirFormat": pluginTpl.FormatPackageDirName,
8080
}
8181

82-
res, err := templateUtil.New().FromContent(tplStr).SetDefaultRender("default", *p, funcMap).Render()
82+
res, err := templateUtil.NewRenderClient(
83+
&templateUtil.TemplateOption{
84+
Name: "plugins",
85+
FuncMap: funcMap,
86+
}, templateUtil.ContentGetter,
87+
).Render(tplStr, *p)
8388
if err != nil {
8489
log.Debugf("Template execute failed: %s.", err)
8590
log.Debugf("Template content: %s.", tplStr)

internal/pkg/plugin/argocdapp/argocdapp.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ func pushArgocdConfigFiles(rawOptions configmanager.RawOptions) error {
2222
}
2323

2424
// 1. init scm client for check argocdapp config exists and push argocdapp files
25-
repoInfo := &git.RepoInfo{CloneURL: git.ScmURL(opts.Source.RepoURL)}
25+
repoInfo := &git.RepoInfo{
26+
CloneURL: git.ScmURL(opts.Source.RepoURL),
27+
Branch: opts.Source.RepoBranch,
28+
}
2629
scmClient, err := scm.NewClientWithAuth(repoInfo)
2730
if err != nil {
2831
return err

internal/pkg/plugin/argocdapp/options.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ type destination struct {
4343

4444
// source is the struct for the source of an ArgoCD app.
4545
type source struct {
46-
Valuefile string `mapstructure:"valuefile"`
47-
Path string `mapstructure:"path" validate:"required"`
48-
RepoURL string `mapstructure:"repoURL" validate:"required"`
46+
Valuefile string `mapstructure:"valuefile"`
47+
Path string `mapstructure:"path" validate:"required"`
48+
RepoURL string `mapstructure:"repoURL" validate:"required"`
49+
RepoBranch string `mapstructure:"repoBranch"`
4950
}
5051

5152
// / newOptions create options by raw options
@@ -82,7 +83,9 @@ func (o *options) getArgocdDefaultConfigFiles(configLocation downloader.Resource
8283
}
8384
// 3. get file content
8485
fContentFunc := func(filePath string) ([]byte, error) {
85-
renderContent, err := template.New().FromLocalFile(filePath).SetDefaultRender("argocd config", o).Render()
86+
renderContent, err := template.NewRenderClient(&template.TemplateOption{
87+
Name: "argocd",
88+
}, template.LocalFileGetter).Render(filePath, o)
8689
if err != nil {
8790
return nil, err
8891
}

internal/pkg/plugin/gitlabcedocker/options.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ func (opts *Options) setGitLabURL() {
5858

5959
func showHelpMsg(options configmanager.RawOptions) error {
6060
log.Infof("GitLab access URL: %s", gitlabURL)
61-
log.Infof("GitLab initial root password: execute the command -> docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password")
61+
log.Info("Execute these two command to get/set GitLab root password: ")
62+
log.Info("1. docker exec -it gitlab bash")
63+
log.Info(`2. gitlab-rake "gitlab:password:reset"`)
6264

6365
return nil
6466
}

internal/pkg/plugin/gitlabci/gitlabci.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ func createGitlabRunnerByHelm(repoInfo *git.RepoInfo) error {
6464
return err
6565
}
6666
// 2. else create runner for this project
67-
valuesYaml, err := template.New().FromContent(helmValueTpl).SetDefaultRender(
68-
"gitlab-runner tpl", map[string]any{
67+
valuesYaml, err := template.NewRenderClient(&template.TemplateOption{
68+
Name: "gitlab-runner"}, template.ContentGetter).Render(
69+
helmValueTpl, map[string]any{
6970
"GitlabURL": repoInfo.BaseURL,
7071
"RegisterToken": runnerToken,
71-
},
72-
).Render()
72+
})
7373
if err != nil {
7474
return err
7575
}

internal/pkg/plugin/harbordocker/harbordocker.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ func renderConfig(options configmanager.RawOptions) (configmanager.RawOptions, e
5757
return nil, err
5858
}
5959

60-
content, err := template.New().FromContent(HarborConfigTemplate).SetDefaultRender("compose", opts).Render()
60+
content, err := template.NewRenderClient(&template.TemplateOption{
61+
Name: "docker-compose",
62+
}, template.ContentGetter).Render(HarborConfigTemplate, opts)
6163
if err != nil {
6264
return nil, err
6365
}

internal/pkg/plugin/installer/ci/cifile/cifile.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ func (c *CIFileConfig) newCIServerClient() (ciClient server.CIServerOptions) {
6868
func (c *CIFileConfig) renderContent(ciFileContent string) (string, error) {
6969
needRenderContent := len(c.Vars) > 0
7070
if needRenderContent {
71-
return template.New().FromContent(ciFileContent).SetDefaultRender(ciTemplateName, c.Vars).Render()
71+
return template.NewRenderClient(&template.TemplateOption{
72+
Name: fmt.Sprintf("ci-%s", ciTemplateName),
73+
}, template.ContentGetter).Render(ciFileContent, c.Vars)
7274
}
7375
return ciFileContent, nil
7476

internal/pkg/plugin/installer/ci/cifile/utils.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cifile
22

33
import (
4+
"fmt"
45
"os"
56

67
"github.com/devstream-io/devstream/pkg/util/file"
@@ -16,7 +17,9 @@ func processCIFilesFunc(vars map[string]interface{}) file.DirFileContentFunc {
1617
if len(vars) == 0 {
1718
return os.ReadFile(filePath)
1819
}
19-
renderContent, err := template.New().FromLocalFile(filePath).SetDefaultRender(ciTemplateName, vars).Render()
20+
renderContent, err := template.NewRenderClient(&template.TemplateOption{
21+
Name: fmt.Sprintf("ci-%s", ciTemplateName),
22+
}, template.LocalFileGetter).Render(filePath, vars)
2023
if err != nil {
2124
return nil, err
2225
}

internal/pkg/plugin/installer/goclient/installer.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package goclient
22

33
import (
4-
"errors"
4+
"fmt"
55
"strings"
66

77
appsv1 "k8s.io/api/apps/v1"
@@ -27,8 +27,7 @@ func DealWithNsWhenInstall(options configmanager.RawOptions) error {
2727

2828
// Namespace should not be empty
2929
if opts.Namespace == "" {
30-
log.Debugf("No namespace is given.")
31-
return errors.New("No namespace is given.")
30+
return fmt.Errorf("config options should set namespace config")
3231
}
3332
log.Debugf("Prepare to create the namespace: %s.", opts.Namespace)
3433

internal/pkg/plugin/installer/kubectl/installer.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ func ProcessByContent(action, content string) installer.BaseOperation {
2525
}
2626

2727
func renderKubectlContent(content string, options configmanager.RawOptions) (io.Reader, error) {
28-
content, err := template.New().FromContent(content).SetDefaultRender("kubectl", options).Render()
28+
content, err := template.NewRenderClient(&template.TemplateOption{
29+
Name: "kubectl",
30+
}, template.ContentGetter).Render(content, options)
2931
if err != nil {
3032
return nil, err
3133
}
@@ -38,7 +40,9 @@ func renderKubectlContent(content string, options configmanager.RawOptions) (io.
3840

3941
func ProcessByURL(action, url string) installer.BaseOperation {
4042
return func(options configmanager.RawOptions) error {
41-
content, err := template.New().FromURL(url).SetDefaultRender("kubectl", options).Render()
43+
content, err := template.NewRenderClient(&template.TemplateOption{
44+
Name: "kubectl",
45+
}, template.URLGetter).Render(url, options)
4246
if err != nil {
4347
return err
4448
}

internal/pkg/plugin/installer/reposcaffolding/utils.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ func processRepoFileFunc(appName string, vars map[string]interface{}) file.DirFi
4949
log.Debugf("Walk: found file: %s.", filePath)
5050
// if file endswith tpl, render this file, else copy this file directly
5151
if strings.Contains(filePath, "tpl") {
52-
fileContentStr, err := template.New().FromLocalFile(filePath).SetDefaultRender(appName, vars).Render()
52+
fileContentStr, err := template.NewRenderClient(&template.TemplateOption{
53+
Name: "repo-scaffolding",
54+
}, template.LocalFileGetter).Render(filePath, vars)
5355
if err != nil {
5456
log.Warnf("repo render file failed: %s", err)
5557
return fileContent, err

internal/pkg/plugin/jiragithub/render.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ func renderTemplate(workflow *github.Workflow, options *Options) (string, error)
1414
return "", err
1515
}
1616

17-
return template.New().FromContent(workflow.WorkflowContent).SetDefaultRender("jiragithub", opts).Render()
17+
return template.NewRenderClient(&template.TemplateOption{
18+
Name: "jiragithub",
19+
}, template.ContentGetter).Render(workflow.WorkflowContent, opts)
1820
}

internal/pkg/show/config/gen_embed_var.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ func copyTemplates(src, dst string) error {
7777

7878
// generate generates the code for Option `o` into a file named by `o.Path`.
7979
func generate(o *Option) {
80-
content, err := templateUtil.New().
81-
FromContent(templateCode).
82-
SetDefaultRender("gen", o, o.Funcs).
83-
Render()
80+
content, err := templateUtil.NewRenderClient(&templateUtil.TemplateOption{
81+
Name: "gen_embed",
82+
FuncMap: o.Funcs,
83+
}, templateUtil.ContentGetter).Render(templateCode, o)
8484

8585
if err != nil {
8686
log.Fatal("template Execute error:", err)

internal/pkg/show/config/plugins/argocdapp.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ tools:
2727
path: charts/go-hello-http
2828
# Helm chart repo URL, this is only an example, do not use this
2929
repoURL: YOUR_CHART_REPO_URL
30+
# Helm chart repo branch
31+
repoBranch: YOUR_CHART_REPO_BRANCH
3032
# if repo doesn't contain path, use imageRepo to create a helm config
3133
imageRepo:
3234
# imageRepo address

0 commit comments

Comments
 (0)