Skip to content

Commit 8fe8d95

Browse files
committed
fix: argocdapp option error and log
Signed-off-by: Meng JiaFeng <[email protected]>
1 parent 39de21d commit 8fe8d95

File tree

23 files changed

+395
-448
lines changed

23 files changed

+395
-448
lines changed

cmd/devstream/init.go

Lines changed: 3 additions & 3 deletions
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)

internal/pkg/configmanager/pipelineDefault.go

Lines changed: 5 additions & 3 deletions
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

Lines changed: 5 additions & 3 deletions
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/plugin/argocdapp/argocdapp.go

Lines changed: 4 additions & 1 deletion
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

Lines changed: 4 additions & 3 deletions
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

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

Lines changed: 2 additions & 3 deletions
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/show/config/plugins/argocdapp.yaml

Lines changed: 2 additions & 0 deletions
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)