Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package helmfile for openSUSE:Factory checked in at 2021-01-30 13:57:13 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/helmfile (Old) and /work/SRC/openSUSE:Factory/.helmfile.new.28504 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "helmfile" Sat Jan 30 13:57:13 2021 rev:17 rq:867923 version:0.138.1 Changes: -------- --- /work/SRC/openSUSE:Factory/helmfile/helmfile.changes 2021-01-13 18:36:24.210344600 +0100 +++ /work/SRC/openSUSE:Factory/.helmfile.new.28504/helmfile.changes 2021-01-30 13:58:05.314429551 +0100 @@ -1,0 +2,15 @@ +Sat Jan 30 09:58:45 UTC 2021 - Manfred Hollstein <[email protected]> + +- v0.138.1: fix: fixed up OCI repos so they support paths and URLs + that differ fr??? + * 8212b63 (HEAD, tag: v0.138.1, origin/master, origin/HEAD, master) + fix: fixed up OCI repos so they support paths and URLs that differ + from chart names contained there (#1661) + +- v0.138.0: feat: added in oci repository flag and added helm + methods to pull and??? + * 2a71640 (HEAD, tag: v0.138.0, origin/master, origin/HEAD, master) + feat: added in oci repository flag and added helm methods to pull + and export charts (#1629) + +------------------------------------------------------------------- Old: ---- helmfile-0.137.0.tar.gz New: ---- helmfile-0.138.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ helmfile.spec ++++++ --- /var/tmp/diff_new_pack.x9Sfm7/_old 2021-01-30 13:58:06.306431223 +0100 +++ /var/tmp/diff_new_pack.x9Sfm7/_new 2021-01-30 13:58:06.314431237 +0100 @@ -16,9 +16,9 @@ # Please submit bugfixes or comments via https://bugs.opensuse.org/ # -%define git_commit 33880dab77a032b205a226b718728fd0855c8773 +%define git_commit 8212b630ff694b300b77cab0d87ca0053a08525e Name: helmfile -Version: 0.137.0 +Version: 0.138.1 Release: 0 Summary: Deploy Kubernetes Helm Charts License: MIT ++++++ _service ++++++ --- /var/tmp/diff_new_pack.x9Sfm7/_old 2021-01-30 13:58:06.350431297 +0100 +++ /var/tmp/diff_new_pack.x9Sfm7/_new 2021-01-30 13:58:06.350431297 +0100 @@ -5,7 +5,7 @@ <param name="exclude">.git</param> <param name="versionformat">@PARENT_TAG@</param> <param name="versionrewrite-pattern">v(.*)</param> - <param name="revision">v0.137.0</param> + <param name="revision">v0.138.1</param> <param name="changesgenerate">enable</param> </service> <service name="recompress" mode="disabled"> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.x9Sfm7/_old 2021-01-30 13:58:06.374431338 +0100 +++ /var/tmp/diff_new_pack.x9Sfm7/_new 2021-01-30 13:58:06.374431338 +0100 @@ -1,4 +1,4 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/roboll/helmfile.git</param> - <param name="changesrevision">33880dab77a032b205a226b718728fd0855c8773</param></service></servicedata> + <param name="changesrevision">8212b630ff694b300b77cab0d87ca0053a08525e</param></service></servicedata> ++++++ helmfile-0.137.0.tar.gz -> helmfile-0.138.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.137.0/Dockerfile new/helmfile-0.138.1/Dockerfile --- old/helmfile-0.137.0/Dockerfile 2021-01-12 02:23:21.000000000 +0100 +++ new/helmfile-0.138.1/Dockerfile 2021-01-28 11:11:12.000000000 +0100 @@ -37,7 +37,7 @@ chmod +x kubectl && \ mv kubectl /usr/local/bin/kubectl -RUN ["helm", "init", "--client-only"] +RUN ["helm", "init", "--client-only", "--stable-repo-url", "https://charts.helm.sh/stable"] RUN helm plugin install https://github.com/databus23/helm-diff && \ helm plugin install https://github.com/futuresimple/helm-secrets && \ helm plugin install https://github.com/hypnoglow/helm-s3.git && \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.137.0/README.md new/helmfile-0.138.1/README.md --- old/helmfile-0.137.0/README.md 2021-01-12 02:23:21.000000000 +0100 +++ new/helmfile-0.138.1/README.md 2021-01-28 11:11:12.000000000 +0100 @@ -54,13 +54,14 @@ # helm-git powered repository: You can treat any Git repository as a charts repository - name: polaris url: git+https://github.com/reactiveops/polaris@deploy/helm?ref=master -# Advanced configuration: You can setup basic or tls auth +# Advanced configuration: You can setup basic or tls auth and optionally enable helm OCI integration - name: roboll url: http://roboll.io/charts certFile: optional_client_cert keyFile: optional_client_key username: optional_username password: optional_password + oci: true # Advanced configuration: You can use a ca bundle to use an https repo # with a self-signed certificate - name: insecure @@ -1308,6 +1309,37 @@ url: https://<MyRegistry>.azurecr.io/helm/v1/repo ``` +## OCI Registries + +In order to use OCI chart registries firstly they must be marked in the repository list as OCI enabled, e.g. + +```yaml +repositories: + - name: myOCIRegistry + url: myregistry.azurecr.io + oci: true +``` + +It is important not to include a scheme for the URL as helm requires that these are not present for OCI registries + +Secondly the credentials for the OCI registry can either be specified within `helmfile.yaml` similar to + +```yaml +repositories: + - name: myOCIRegistry + url: myregistry.azurecr.io + oci: true + username: spongebob + password: squarepants +``` + +or for CI scenarios these can be sourced from the environment with the format `<registryName>_USERNAME` and `<registryName_PASSWORD>`, e.g. + +```shell +export MYOCIREGISTRY_USERNAME=spongebob +export MYOCIREGISTRY_PASSWORD=squarepants +``` + ## Attribution We use: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.137.0/go.mod new/helmfile-0.138.1/go.mod --- old/helmfile-0.137.0/go.mod 2021-01-12 02:23:21.000000000 +0100 +++ new/helmfile-0.138.1/go.mod 2021-01-28 11:11:12.000000000 +0100 @@ -19,7 +19,6 @@ github.com/hashicorp/go-version v1.2.1 github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c // indirect github.com/imdario/mergo v0.3.11 - github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect github.com/pierrec/lz4 v2.3.0+incompatible // indirect github.com/r3labs/diff v1.1.0 github.com/spf13/cobra v1.1.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.137.0/go.sum new/helmfile-0.138.1/go.sum --- old/helmfile-0.137.0/go.sum 2021-01-12 02:23:21.000000000 +0100 +++ new/helmfile-0.138.1/go.sum 2021-01-28 11:11:12.000000000 +0100 @@ -429,8 +429,6 @@ github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -626,16 +624,10 @@ github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU= github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/variantdev/chartify v0.4.9 h1:06foIMnJj31q/l1JZ+54anDLwqtP8zAOv5qVEn2IQhM= -github.com/variantdev/chartify v0.4.9/go.mod h1:jqlUJIzcrIVSfg8FC4g+IoC5WB83TBl8rnVVEv6g8MQ= -github.com/variantdev/chartify v0.5.0 h1:I6T6oobjLfYmwZ4dUjRsO9AdGKPCMtfzt0CXR0ovl9k= -github.com/variantdev/chartify v0.5.0/go.mod h1:jqlUJIzcrIVSfg8FC4g+IoC5WB83TBl8rnVVEv6g8MQ= github.com/variantdev/chartify v0.6.0 h1:QQ00a8Vtuhk6F9jeTZJEXV2g0zRXhYG43xovWZrc3ac= github.com/variantdev/chartify v0.6.0/go.mod h1:qF4XzQlkfH/6k2jAi1hLas+lK4zSCa8kY+r5JdmLA68= github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363 h1:KrfQBEUn+wEOQ/6UIfoqRDvn+Q/wZridQ7t0G1vQqKE= github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363/go.mod h1:pH1TQsNSLj2uxMo9NNl9zdGy01Wtn+/2MT96BrKmVyE= -github.com/variantdev/vals v0.11.0 h1:818ztGk5yPTiixbUeE3LkkBGGATEAKtWq09n8q8PFqc= -github.com/variantdev/vals v0.11.0/go.mod h1:pZ0ZJZnOwB5aCJmXZgwrgMMMKMfIYMrhpsHllInRQ8c= github.com/variantdev/vals v0.12.0 h1:1fk2nlSzGkoY5/Ij7dyIB6r0eemFGWQMa5TD2ZhDSB8= github.com/variantdev/vals v0.12.0/go.mod h1:KHSazZ2M3pFiwu6mw4O56YdjNatCZpJZkk4s23rexW8= github.com/vektra/mockery v1.1.2/go.mod h1:VcfZjKaFOPO+MpN4ZvwPjs4c48lkq1o3Ym8yHZJu0jU= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.137.0/pkg/app/app_test.go new/helmfile-0.138.1/pkg/app/app_test.go --- old/helmfile-0.137.0/pkg/app/app_test.go 2021-01-12 02:23:21.000000000 +0100 +++ new/helmfile-0.138.1/pkg/app/app_test.go 2021-01-28 11:11:12.000000000 +0100 @@ -2404,6 +2404,10 @@ err error } +func (mock *mockRunner) ExecuteStdIn(cmd string, args []string, env map[string]string, stdin io.Reader) ([]byte, error) { + return []byte{}, nil +} + func (mock *mockRunner) Execute(cmd string, args []string, env map[string]string) ([]byte, error) { return []byte{}, nil } @@ -2441,6 +2445,14 @@ return nil } +func (helm *mockHelmExec) ChartPull(chart string, flags ...string) error { + return nil +} + +func (helm *mockHelmExec) ChartExport(chart string, path string, flags ...string) error { + return nil +} + func (helm *mockHelmExec) UpdateDeps(chart string) error { return nil } @@ -2462,6 +2474,9 @@ func (helm *mockHelmExec) UpdateRepo() error { return nil } +func (helm *mockHelmExec) RegistryLogin(name string, username string, password string) error { + return nil +} func (helm *mockHelmExec) SyncRelease(context helmexec.HelmContext, name, chart string, flags ...string) error { return nil } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.137.0/pkg/app/mocks_test.go new/helmfile-0.138.1/pkg/app/mocks_test.go --- old/helmfile-0.137.0/pkg/app/mocks_test.go 2021-01-12 02:23:21.000000000 +0100 +++ new/helmfile-0.138.1/pkg/app/mocks_test.go 2021-01-28 11:11:12.000000000 +0100 @@ -22,7 +22,14 @@ helm.doPanic() return nil } - +func (helm *noCallHelmExec) ChartPull(chart string, flags ...string) error { + helm.doPanic() + return nil +} +func (helm *noCallHelmExec) ChartExport(chart string, path string, flags ...string) error { + helm.doPanic() + return nil +} func (helm *noCallHelmExec) UpdateDeps(chart string) error { helm.doPanic() return nil @@ -49,6 +56,10 @@ helm.doPanic() return nil } +func (helm *noCallHelmExec) RegistryLogin(name string, username string, password string) error { + helm.doPanic() + return nil +} func (helm *noCallHelmExec) SyncRelease(context helmexec.HelmContext, name, chart string, flags ...string) error { helm.doPanic() return nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.137.0/pkg/event/bus_test.go new/helmfile-0.138.1/pkg/event/bus_test.go --- old/helmfile-0.137.0/pkg/event/bus_test.go 2021-01-12 02:23:21.000000000 +0100 +++ new/helmfile-0.138.1/pkg/event/bus_test.go 2021-01-28 11:11:12.000000000 +0100 @@ -2,6 +2,7 @@ import ( "fmt" + "io" "os" "testing" @@ -16,6 +17,10 @@ type runner struct { } +func (r *runner) ExecuteStdIn(cmd string, args []string, env map[string]string, stdin io.Reader) ([]byte, error) { + return []byte(""), nil +} + func (r *runner) Execute(cmd string, args []string, env map[string]string) ([]byte, error) { if cmd == "ng" { return nil, fmt.Errorf("cmd failed due to invalid cmd: %s", cmd) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.137.0/pkg/exectest/helm.go new/helmfile-0.138.1/pkg/exectest/helm.go --- old/helmfile-0.137.0/pkg/exectest/helm.go 2021-01-12 02:23:21.000000000 +0100 +++ new/helmfile-0.138.1/pkg/exectest/helm.go 2021-01-28 11:11:12.000000000 +0100 @@ -89,6 +89,9 @@ func (helm *Helm) UpdateRepo() error { return nil } +func (helm *Helm) RegistryLogin(name string, username string, password string) error { + return nil +} func (helm *Helm) SyncRelease(context helmexec.HelmContext, name, chart string, flags ...string) error { if strings.Contains(name, "error") { return errors.New("error") @@ -158,7 +161,12 @@ func (helm *Helm) TemplateRelease(name, chart string, flags ...string) error { return nil } - +func (helm *Helm) ChartPull(chart string, flags ...string) error { + return nil +} +func (helm *Helm) ChartExport(chart string, path string, flags ...string) error { + return nil +} func (helm *Helm) IsHelm3() bool { return false } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.137.0/pkg/helmexec/exec.go new/helmfile-0.138.1/pkg/helmexec/exec.go --- old/helmfile-0.137.0/pkg/helmexec/exec.go 2021-01-12 02:23:21.000000000 +0100 +++ new/helmfile-0.138.1/pkg/helmexec/exec.go 2021-01-28 11:11:12.000000000 +0100 @@ -1,6 +1,7 @@ package helmexec import ( + "bytes" "fmt" "io" "io/ioutil" @@ -72,13 +73,13 @@ func getHelmVersion(helmBinary string, runner Runner) (semver.Version, error) { - // Autodetect from `helm verison` - bytes, err := runner.Execute(helmBinary, []string{"version", "--client", "--short"}, nil) + // Autodetect from `helm version` + outBytes, err := runner.Execute(helmBinary, []string{"version", "--client", "--short"}, nil) if err != nil { return semver.Version{}, fmt.Errorf("error determining helm version: %w", err) } - return parseHelmVersion(string(bytes)) + return parseHelmVersion(string(outBytes)) } // New for running helm commands @@ -157,6 +158,24 @@ return err } +func (helm *execer) RegistryLogin(repository string, username string, password string) error { + helm.logger.Info("Logging in to registry") + args := []string{ + "registry", + "login", + repository, + "--username", + username, + "--password", + password, + } + buffer := bytes.Buffer{} + buffer.Write([]byte(fmt.Sprintf("%s\n", password))) + out, err := helm.execStdIn(args, map[string]string{"HELM_EXPERIMENTAL_OCI": "1"}, &buffer) + helm.info(out) + return err +} + func (helm *execer) BuildDeps(name, chart string) error { helm.logger.Infof("Building dependency release=%v, chart=%v", name, chart) out, err := helm.exec([]string{"dependency", "build", chart}, map[string]string{}) @@ -369,6 +388,20 @@ return err } +func (helm *execer) ChartPull(chart string, flags ...string) error { + helm.logger.Infof("Pulling %v", chart) + out, err := helm.exec(append([]string{"chart", "pull", chart}, flags...), map[string]string{"HELM_EXPERIMENTAL_OCI": "1"}) + helm.info(out) + return err +} + +func (helm *execer) ChartExport(chart string, path string, flags ...string) error { + helm.logger.Infof("Exporting %v", chart) + out, err := helm.exec(append([]string{"chart", "export", chart, "--destination", path}, flags...), map[string]string{"HELM_EXPERIMENTAL_OCI": "1"}) + helm.info(out) + return err +} + func (helm *execer) DeleteRelease(context HelmContext, name string, flags ...string) error { helm.logger.Infof("Deleting %v", name) preArgs := context.GetTillerlessArgs(helm) @@ -398,17 +431,31 @@ } cmd := fmt.Sprintf("exec: %s %s", helm.helmBinary, strings.Join(cmdargs, " ")) helm.logger.Debug(cmd) - bytes, err := helm.runner.Execute(helm.helmBinary, cmdargs, env) - return bytes, err + outBytes, err := helm.runner.Execute(helm.helmBinary, cmdargs, env) + return outBytes, err +} + +func (helm *execer) execStdIn(args []string, env map[string]string, stdin io.Reader) ([]byte, error) { + cmdargs := args + if len(helm.extra) > 0 { + cmdargs = append(cmdargs, helm.extra...) + } + if helm.kubeContext != "" { + cmdargs = append([]string{"--kube-context", helm.kubeContext}, cmdargs...) + } + cmd := fmt.Sprintf("exec: %s %s", helm.helmBinary, strings.Join(cmdargs, " ")) + helm.logger.Debug(cmd) + outBytes, err := helm.runner.ExecuteStdIn(helm.helmBinary, cmdargs, env, stdin) + return outBytes, err } func (helm *execer) azcli(name string) ([]byte, error) { cmdargs := append(strings.Split("acr helm repo add --name", " "), name) cmd := fmt.Sprintf("exec: az %s", strings.Join(cmdargs, " ")) helm.logger.Debug(cmd) - bytes, err := helm.runner.Execute("az", cmdargs, map[string]string{}) - helm.logger.Debugf("%s: %s", cmd, bytes) - return bytes, err + outBytes, err := helm.runner.Execute("az", cmdargs, map[string]string{}) + helm.logger.Debugf("%s: %s", cmd, outBytes) + return outBytes, err } func (helm *execer) info(out []byte) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.137.0/pkg/helmexec/exec_test.go new/helmfile-0.138.1/pkg/helmexec/exec_test.go --- old/helmfile-0.137.0/pkg/helmexec/exec_test.go 2021-01-12 02:23:21.000000000 +0100 +++ new/helmfile-0.138.1/pkg/helmexec/exec_test.go 2021-01-28 11:11:12.000000000 +0100 @@ -4,6 +4,7 @@ "bytes" "fmt" "github.com/google/go-cmp/cmp" + "io" "os" "path" "path/filepath" @@ -21,6 +22,10 @@ err error } +func (mock *mockRunner) ExecuteStdIn(cmd string, args []string, env map[string]string, stdin io.Reader) ([]byte, error) { + return mock.output, mock.err +} + func (mock *mockRunner) Execute(cmd string, args []string, env map[string]string) ([]byte, error) { return mock.output, mock.err } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.137.0/pkg/helmexec/helmexec.go new/helmfile-0.138.1/pkg/helmexec/helmexec.go --- old/helmfile-0.137.0/pkg/helmexec/helmexec.go 2021-01-12 02:23:21.000000000 +0100 +++ new/helmfile-0.138.1/pkg/helmexec/helmexec.go 2021-01-28 11:11:12.000000000 +0100 @@ -14,12 +14,15 @@ AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string) error UpdateRepo() error + RegistryLogin(name string, username string, password string) error BuildDeps(name, chart string) error UpdateDeps(chart string) error SyncRelease(context HelmContext, name, chart string, flags ...string) error DiffRelease(context HelmContext, name, chart string, suppressDiff bool, flags ...string) error TemplateRelease(name, chart string, flags ...string) error Fetch(chart string, flags ...string) error + ChartPull(chart string, flags ...string) error + ChartExport(chart string, path string, flags ...string) error Lint(name, chart string, flags ...string) error ReleaseStatus(context HelmContext, name string, flags ...string) error DeleteRelease(context HelmContext, name string, flags ...string) error diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.137.0/pkg/helmexec/runner.go new/helmfile-0.138.1/pkg/helmexec/runner.go --- old/helmfile-0.137.0/pkg/helmexec/runner.go 2021-01-12 02:23:21.000000000 +0100 +++ new/helmfile-0.138.1/pkg/helmexec/runner.go 2021-01-28 11:11:12.000000000 +0100 @@ -22,6 +22,7 @@ // Runner interface for shell commands type Runner interface { Execute(cmd string, args []string, env map[string]string) ([]byte, error) + ExecuteStdIn(cmd string, args []string, env map[string]string, stdin io.Reader) ([]byte, error) } // ShellRunner implemention for shell commands @@ -39,6 +40,17 @@ return Output(preparedCmd, &logWriterGenerator{ log: shell.Logger, }) +} + +// Execute a shell command +func (shell ShellRunner) ExecuteStdIn(cmd string, args []string, env map[string]string, stdin io.Reader) ([]byte, error) { + preparedCmd := exec.Command(cmd, args...) + preparedCmd.Dir = shell.Dir + preparedCmd.Env = mergeEnv(os.Environ(), env) + preparedCmd.Stdin = stdin + return Output(preparedCmd, &logWriterGenerator{ + log: shell.Logger, + }) } func Output(c *exec.Cmd, logWriterGenerators ...*logWriterGenerator) ([]byte, error) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.137.0/pkg/state/state.go new/helmfile-0.138.1/pkg/state/state.go --- old/helmfile-0.137.0/pkg/state/state.go 2021-01-12 02:23:21.000000000 +0100 +++ new/helmfile-0.138.1/pkg/state/state.go 2021-01-28 11:11:12.000000000 +0100 @@ -162,6 +162,7 @@ Username string `yaml:"username,omitempty"` Password string `yaml:"password,omitempty"` Managed string `yaml:"managed,omitempty"` + OCI bool `yaml:"oci,omitempty"` } // ReleaseSpec defines the structure of a helm release @@ -336,6 +337,7 @@ type RepoUpdater interface { AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string) error UpdateRepo() error + RegistryLogin(name string, username string, password string) error } // getRepositoriesToSync returns the names of repositories to be updated @@ -375,8 +377,18 @@ if shouldSkip[repo.Name] { continue } + var err error + if repo.OCI { + username, password := gatherOCIUsernamePassword(repo.Name, repo.Username, repo.Password) + if username == "" || password == "" { + return nil, fmt.Errorf("username and password are required fields for logging in to OCI registries with helm") + } + err = helm.RegistryLogin(repo.URL, username, password) + } else { + err = helm.AddRepo(repo.Name, repo.URL, repo.CaFile, repo.CertFile, repo.KeyFile, repo.Username, repo.Password, repo.Managed) + } - if err := helm.AddRepo(repo.Name, repo.URL, repo.CaFile, repo.CertFile, repo.KeyFile, repo.Username, repo.Password, repo.Managed); err != nil { + if err != nil { return nil, err } @@ -386,6 +398,24 @@ return updated, nil } +func gatherOCIUsernamePassword(repoName string, username string, password string) (string, string) { + var user, pass string + + if username != "" { + user = username + } else if u := os.Getenv(fmt.Sprintf("%s_USERNAME", strings.ToUpper(repoName))); u != "" { + user = u + } + + if password != "" { + pass = password + } else if p := os.Getenv(fmt.Sprintf("%s_PASSWORD", strings.ToUpper(repoName))); p != "" { + pass = p + } + + return user, pass +} + type syncResult struct { errors []*ReleaseError } @@ -857,6 +887,20 @@ chartFetchedByGoGetter bool } +func (st *HelmState) GetRepositoryAndNameFromChartName(chartName string) (*RepositorySpec, string) { + chart := strings.Split(chartName, "/") + if len(chart) == 1 { + return nil, chartName + } + repo := chart[0] + for _, r := range st.Repositories { + if r.Name == repo { + return &r, strings.Join(chart[1:], "/") + } + } + return nil, chartName +} + // PrepareCharts creates temporary directories of charts. // // Each resulting "chart" can be one of the followings: @@ -935,16 +979,21 @@ chartName := release.Chart - isLocal := st.directoryExistsAt(normalizeChart(st.basePath, chartName)) - chartPath, err := st.goGetterChart(chartName, release.Directory, release.ForceGoGetter) if err != nil { results <- &chartPrepareResult{err: fmt.Errorf("release %q: %w", release.Name, err)} return } - chartFetchedByGoGetter := chartPath != chartName + isOCI, chartPath, err := st.getOCIChart(release, dir, helm) + if err != nil { + results <- &chartPrepareResult{err: fmt.Errorf("release %q: %w", release.Name, err)} + return + } + + isLocal := st.directoryExistsAt(normalizeChart(st.basePath, chartName)) + chartification, clean, err := st.PrepareChartify(helm, release, chartPath, workerIndex) defer clean() if err != nil { @@ -957,7 +1006,7 @@ skipDepsGlobal := opts.SkipDeps skipDepsRelease := release.SkipDeps != nil && *release.SkipDeps skipDepsDefault := release.SkipDeps == nil && st.HelmDefaults.SkipDeps - skipDeps := !isLocal || skipDepsGlobal || skipDepsRelease || skipDepsDefault + skipDeps := !isLocal || skipDepsGlobal || skipDepsRelease || skipDepsDefault || !isOCI if chartification != nil { c := chartify.New( @@ -2928,3 +2977,58 @@ st.Helmfiles[i], st.Helmfiles[j] = st.Helmfiles[j], st.Helmfiles[i] } } + +func (st *HelmState) getOCIChart(release *ReleaseSpec, tempDir string, helm helmexec.Interface) (bool, string, error) { + + isOCI := false + + repo, name := st.GetRepositoryAndNameFromChartName(release.Chart) + if repo == nil { + return false, release.Chart, nil + } + + if repo.OCI { + isOCI = true + } + + if !isOCI { + return isOCI, release.Chart, nil + } + + chartVersion := "latest" + if release.Version != "" { + chartVersion = release.Version + } + + qualifiedChartName := fmt.Sprintf("%s/%s:%s", repo.URL, name, chartVersion) + + err := helm.ChartPull(qualifiedChartName) + if err != nil { + return isOCI, release.Chart, err + } + + pathElems := []string{ + tempDir, + } + + if release.Namespace != "" { + pathElems = append(pathElems, release.Namespace) + } + + if release.KubeContext != "" { + pathElems = append(pathElems, release.KubeContext) + } + + pathElems = append(pathElems, release.Name, name, chartVersion) + + chartPath := path.Join(pathElems...) + err = helm.ChartExport(qualifiedChartName, chartPath) + + fullChartPath, err := findChartDirectory(chartPath) + if err != nil { + return isOCI, release.Chart, err + } + + chartPath = filepath.Dir(fullChartPath) + return isOCI, chartPath, nil +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmfile-0.137.0/test/integration/run.sh new/helmfile-0.138.1/test/integration/run.sh --- old/helmfile-0.137.0/test/integration/run.sh 2021-01-12 02:23:21.000000000 +0100 +++ new/helmfile-0.138.1/test/integration/run.sh 2021-01-28 11:11:12.000000000 +0100 @@ -49,7 +49,7 @@ if helm version --client 2>/dev/null | grep '"v2\.'; then helm_major_version=2 info "Using Helm version: $(helm version --short --client | grep -o v.*$)" - ${helm} init --wait --override spec.template.spec.automountServiceAccountToken=true + ${helm} init --stable-repo-url https://charts.helm.sh/stable --wait --override spec.template.spec.automountServiceAccountToken=true # helm v3 else helm_major_version=3 ++++++ vendor.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/modules.txt new/vendor/modules.txt --- old/vendor/modules.txt 2021-01-13 15:38:48.000000000 +0100 +++ new/vendor/modules.txt 2021-01-30 11:01:41.000000000 +0100 @@ -224,8 +224,6 @@ github.com/jstemmer/go-junit-report github.com/jstemmer/go-junit-report/formatter github.com/jstemmer/go-junit-report/parser -# github.com/konsorten/go-windows-terminal-sequences v1.0.2 -## explicit # github.com/lestrrat-go/strftime v1.0.1 github.com/lestrrat-go/strftime # github.com/lib/pq v1.2.0
