mirror of
https://github.com/ipedrazas/drone-helm.git
synced 2026-06-04 18:24:13 +08:00
issue #68 add stable_repo_url to change default stable repository
This commit is contained in:
+5
-1
@@ -9,7 +9,6 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"text/template"
|
||||
)
|
||||
|
||||
@@ -49,6 +48,7 @@ type (
|
||||
HelmRepos []string `json:"helm_repos"`
|
||||
Purge bool `json:"purge"`
|
||||
UpdateDependencies bool `json:"update_dependencies"`
|
||||
StableRepoURL string `json:"stable_repo_url"`
|
||||
}
|
||||
// Plugin default
|
||||
Plugin struct {
|
||||
@@ -194,6 +194,10 @@ func doHelmRepoAdd(repo string) ([]string, error) {
|
||||
func doHelmInit(p *Plugin) []string {
|
||||
init := make([]string, 1)
|
||||
init[0] = "init"
|
||||
if p.Config.StableRepoURL != "" {
|
||||
init = append(init, "--stable-repo-url")
|
||||
init = append(init, p.Config.StableRepoURL)
|
||||
}
|
||||
if p.Config.TillerNs != "" {
|
||||
init = append(init, "--tiller-namespace")
|
||||
init = append(init, p.Config.TillerNs)
|
||||
|
||||
@@ -513,3 +513,30 @@ func TestResolveSecretsFallback(t *testing.T) {
|
||||
t.Errorf("envar ${NOTTOKEN} has not been resolved to 99999, not using prefix")
|
||||
}
|
||||
}
|
||||
func TestHelmInitByAliyunStableRepo(t *testing.T) {
|
||||
plugin := &Plugin{
|
||||
Config: Config{
|
||||
HelmCommand: "",
|
||||
Namespace: "default",
|
||||
SkipTLSVerify: true,
|
||||
Debug: true,
|
||||
DryRun: true,
|
||||
Chart: "./chart/test",
|
||||
Release: "test-release",
|
||||
Prefix: "MY",
|
||||
Values: "image.tag=$TAG,api=${API_SERVER},nameOverride=my-over-app,second.tag=${TAG}",
|
||||
StringValues: "long_string_value=1234567890",
|
||||
StableRepoURL: "https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts",
|
||||
},
|
||||
}
|
||||
init := doHelmInit(plugin)
|
||||
result := strings.Join(init, " ")
|
||||
expected := "init "
|
||||
if plugin.Config.StableRepoURL != "" {
|
||||
expected = expected + "--stable-repo-url"
|
||||
}
|
||||
|
||||
if expected != result {
|
||||
t.Error("Helm cannot init for stable repository")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user