Commit Graph

66 Commits

Author SHA1 Message Date
yxxhero 56dad58180
feat: add namespace info in syncRelease and diffRelease (#1609) 2024-07-16 09:47:00 +08:00
Tim Ramlot 5910ce0b99
Add `--kubeconfig` flag (#1381)
add kubeconfig flag

Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
2024-03-01 20:26:54 +08:00
yxxhero 008b2dd1d4
fix: issue with pre-release Helm version (#1293) 2024-01-18 09:21:15 +08:00
ennekein dabbe5e7d4
Bugfix: do not print registry password to stdout when running (#1275)
* Bugfix: do not print registry password to stdout when running
Resolves #1274

Signed-off-by: Pascal Rivard <privard@rbbn.com>

* Update exec.go

Signed-off-by: yxxhero <11087727+yxxhero@users.noreply.github.com>

* fix lint issues

Signed-off-by: yxxhero <aiopsclub@163.com>

* Add unit test

Signed-off-by: Pascal Rivard <privard@rbbn.com>

---------

Signed-off-by: Pascal Rivard <privard@rbbn.com>
Signed-off-by: yxxhero <11087727+yxxhero@users.noreply.github.com>
Signed-off-by: yxxhero <aiopsclub@163.com>
Co-authored-by: Pascal Rivard <privard@rbbn.com>
Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com>
Co-authored-by: yxxhero <aiopsclub@163.com>
2024-01-10 07:26:47 +08:00
yxxhero cfa89d4040
feat: add insecure support for oci repo (#921)
* feat: add insecure support for oci repo

Signed-off-by: yxxhero <aiopsclub@163.com>
2023-07-24 09:09:10 +08:00
yxxhero 12a984d70f
feat: set RepositorySpec.PassCredentials var type to bool (#878)
* feat: set RepositorySpec.PassCredentials var type to bool

Signed-off-by: yxxhero <aiopsclub@163.com>
2023-06-01 13:41:45 +08:00
yxxhero e8f9bbbf9d
feat: update repo Spec var type skipTLSVerify to bool (#877)
* feat: update repo Spec var type skipTLSVerify to bool

Signed-off-by: yxxhero <aiopsclub@163.com>
2023-06-01 12:05:53 +08:00
Dmitry Chepurovskiy aa5be82834
Make helmfile respect signals send by kill command (not only Ctrl+C in terminal) (#750)
Fixes #746 

Signed-off-by: Dmitry Chepurovskiy <me@dm3ch.net>
Signed-off-by: yxxhero <aiopsclub@163.com>
Co-authored-by: yxxhero <aiopsclub@163.com>
2023-04-29 15:25:29 +09:00
Hans Song 1d0ba72b47
feat: add/expose cli flags (#771)
* feat: add/expose cli flags

Signed-off-by: Hans Song <hans.m.song@gmail.com>

* fix tests

Signed-off-by: Hans Song <hans.m.song@gmail.com>

* remove skipdeps from subcommand options

Signed-off-by: Hans Song <hans.m.song@gmail.com>

* remove skip-deps from subcommand flags

Signed-off-by: Hans Song <hans.m.song@gmail.com>

* remove SkipDeps from subcommand implementations

Signed-off-by: Hans Song <hans.m.song@gmail.com>

* update doco with new flags

Signed-off-by: Hans Song <hans.m.song@gmail.com>

---------

Signed-off-by: Hans Song <hans.m.song@gmail.com>
2023-04-02 14:53:52 +08:00
yxxhero 5e8a502b41
feat: use new helm version parse function (#760)
* feat: use new helm version parse function

Signed-off-by: yxxhero <aiopsclub@163.com>
2023-03-23 08:46:11 +08:00
yxxhero 2d9f83c1de
clean: optimize postrenderer code (#738) 2023-03-14 06:18:20 +08:00
yxxhero 5cdec2dd51
clean: helm v2 logic code (#736)
Signed-off-by: yxxhero <aiopsclub@163.com>
2023-03-12 00:28:39 +08:00
xiaomudk c4eb62388b
Drop Helm v2 support (#613)
Resolves #589

Signed-off-by: xiaomudk <xiaomudk@gmail.com>
2023-01-17 09:24:47 +09:00
yxxhero 36c91c5427
optimize lint logic (#586)
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-12-18 08:39:45 +08:00
Indrek Juhkam 608bb0b525 Avoid --skip-refresh on local charts (#541)
All the dependencies get correctly installed when dealing with remote
charts.

If there's a local chart that depends on remote dependencies then those
don't get automatically installed. See #526. They end up with this
error:

```
Error: no cached repository for helm-manager-b6cf96b91af4f01317d185adfbe32610179e5246214be9646a52cb0b86032272 found. (try 'helm repo update'): open /root/.cache/helm/repository/helm-manager-b6cf96b91af4f01317d185adfbe32610179e5246214be9646a52cb0b86032272-index.yaml: no such file or directory
```

One workaround for that would be to add the repositories from the local
charts. Something like this:

```
cd local-chart/ && helm dependency list $dir 2> /dev/null | tail +2 | head -n -1 | awk '{ print "helm repo add " $1 " " $3 }' | while read cmd; do $cmd; done
```

This however is not trivial to parse and implement.

An easier fix which I did here is just to not allow doing
`--skip-refresh` for local repositories.

Fixes #526

Signed-off-by: Indrek Juhkam <indrek@urgas.eu>

Signed-off-by: Indrek Juhkam <indrek@urgas.eu>
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-12-13 13:12:07 +08:00
guofutan 0a953731b0 fix(#507): support assign --post-renderer within helmfile flags and helmdefault or release config
1. only implement post-renderer flags this patch
2. As mumoshu advise, add helmfile flags `--post-render` and add the
   postRenderer  config in helmDefaults and release. the priority is
   helmfile flags > release > helmDefaults.
3. fix the test case in state_test.go and some other tests.

Signed-off-by: guofutan <guofutan@tencent.com>
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-12-13 13:12:07 +08:00
guofutan 4cc07daced fix(#510): fix golangci-lint run error,add the unit test, add the compatibility when there is blank in the args values.
Signed-off-by: guofutan <guofutan@tencent.com>
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-12-13 13:12:07 +08:00
Indrek Juhkam a409b450cd
Add `--skip-refresh` flag to the build command (#444)
This improves the `helmfile sync` performance.

From the code: `BuildDeps` is used only by `runHelmDepBuilds`, which
only is used by `PrepareCharts` which is finally only used by
`withPreparedCharts`.

`withPreparedCharts` already does `SyncReposOnce` which means we do not
have to refresh the local repository cache on each chart build.

This is only supported in Helm v3.

This seems to be mostly affecting helmfiles which have a lot of releases
and those release charts use sub dependencies.

I saw significant performance improvements for a helmfile with 45
releases, 2 repositories, and most of the charts also had their own
dependencies. Results:

Before the patch:
* real  9m10.565s
* real  9m38.335s
* real  9m14.941s
* real  5m13.106s (with cache)

After the patch:
* real  6m51.965s
* real  6m36.605s
* real  6m31.685s
* real  3m0.271s (with cache)

These were tested with:
```
rm -rf ~/.cache/helmfile ~/.cache/helm ~/.config/helm/repositories.* && helmfile sync ...
```

The result with `(with cache)` was without deleting the caches first.

From these metrics it seems that the sync duration decreased 20-45%
depending on the run, release count, dependencies and if the cache was
used or not.

As far as I understand, this should be backward-compatible change.

Signed-off-by: Indrek Juhkam <indrek@urgas.eu>

Signed-off-by: Indrek Juhkam <indrek@urgas.eu>
2022-10-20 09:03:08 +09:00
Rui Chen ffce09a35f
deps: update dockerfile dependencies (#421)
* deps: helm 3.10.0

Signed-off-by: Rui Chen <rui@chenrui.dev>
2022-10-12 20:41:26 +08:00
yxxhero 21c28ca6d0
feat: add reuse-values args for diff apply and sync (#411)
Signed-off-by: yxxhero <aiopsclub@163.com>

Signed-off-by: yxxhero <aiopsclub@163.com>
2022-10-08 14:27:39 +09:00
Felipe Santos f15bdbbb0c Use helm show chart to identify chart version
Signed-off-by: Felipe Santos <felipecassiors@gmail.com>
2022-10-03 22:04:08 -03:00
Tsubasa Nagasawa 7b40cefdda
fix: add missing untar flag to pull chart from oci registry
Signed-off-by: Tsubasa Nagasawa <toversus2357@gmail.com>
2022-09-18 19:11:34 +09:00
Jean-Yves CAMIER b8cf0f156e
fix(oci): clean dead code (#290)
fix(oci): remove dead code

Signed-off-by: Jean-Yves CAMIER <jycamier@gmail.com>
Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Co-authored-by: Yusuke Kuoka <ykuoka@gmail.com>
2022-09-18 16:34:16 +09:00
Rodrigo Fior Kuntzer 8408b021f0
feat: show live output from the Helm binary (#286)
* feat: show live output from the Helm binary

Signed-off-by: Rodrigo Fior Kuntzer <rodrigo@miro.com>

* fixup! Merge branch 'main' into enable-live-output

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
2022-09-18 14:24:35 +09:00
KqLLL 0fbcb07bad
Support helm-secrets v4.0.0 (#360)
Support helm-secret v4.0.0

Signed-off-by: KqLLL <lllkq546449541@gmail.com>
2022-09-17 19:54:28 +09:00
yxxhero 8690d63401 fix lint error
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-08-13 07:40:32 +08:00
yxxhero 4e9b99d10e
Merge pull request #258 from xiaomudk/patch-4
fix: OCI Url and Version parse error
2022-07-23 21:14:04 +08:00
xiaomudk 59ffa687df fix: OCI Url and Version parse error
Signed-off-by: xiaomudk <xiaomudk@gmail.com>
2022-07-23 20:52:32 +08:00
xiaomudk cf62499d4a test: Add unit tests for ChartPull
Signed-off-by: xiaomudk <xiaomudk@gmail.com>
2022-07-23 18:41:59 +08:00
xiaomudk 70fd920384 test: Add unit tests for ChartExport
Signed-off-by: xiaomudk <xiaomudk@gmail.com>
2022-07-23 16:32:09 +08:00
yxxhero ac23def893 add Go lint
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-07-16 20:21:11 +08:00
Yusuke Kuoka cc13492623
Merge pull request #201 from magicmemories/fix/helm-secrets-view
fix: use helm secrets view rather than helm secrets dec to decrypt
2022-07-16 21:04:48 +09:00
Adam Gardner a93661d382 chore: remove obsolete exemption of os.PathError in test case
Signed-off-by: Adam Gardner <adam.gardner@magicmemories.com>
2022-07-10 09:15:18 -10:00
Radon Rosborough de6a9aeebf Fix Test_DecryptSecretWithGotmpl
Signed-off-by: Radon Rosborough <rrosborough@plaid.com>
2022-07-07 16:26:33 -10:00
Radon Rosborough c1eb7f0623 Fix Test_DecryptSecret
Signed-off-by: Radon Rosborough <rrosborough@plaid.com>
2022-07-07 16:26:33 -10:00
Adam Gardner 74c1f9e9a0 fix: use helm secrets view rather than helm secrets dec to decrypt
Signed-off-by: Adam Gardner <adam.gardner@magicmemories.com>

chore: fix test case broken by change of helm subcommand

Signed-off-by: Adam Gardner <adam.gardner@magicmemories.com>
2022-07-07 16:26:12 -10:00
Eng Zer Jun ce3b81e2a1
test: use `T.Setenv` to set env vars in tests (#189)
This commit replaces `os.Setenv` with `t.Setenv` in tests. The
environment variable is automatically restored to its original value
when the test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.Setenv
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-06-30 09:15:34 +09:00
Quan TRAN 577f54af7a
Introduce DISABLE_INSECURE_FEATURES to disable insecure command executions (#1)
* introduce DISABLE_INSECURE_FEATURES to disable insecure executions

Signed-off-by: Quan TRAN <account@itscaro.me>

* disable remote sources when DISABLE_INSECURE_FEATURES is set to "true"

Signed-off-by: Quan TRAN <account@itscaro.me>

* refactor envvar package

Signed-off-by: Quan TRAN <account@itscaro.me>

* (test) fix test fixtures

Signed-off-by: Quan TRAN <account@itscaro.me>

* use absolute path to avoid unit test failure

Signed-off-by: Quan TRAN <account@itscaro.me>

* Fix conflicts

Co-authored-by: Yusuke Kuoka <ykuoka@gmail.com>
2022-06-05 15:15:06 +09:00
Lüchinger Dominic f89234e5dc
Redact sensitive informations like password in chart url
Signed-off-by: Lüchinger Dominic <dev@snowgarden.ch>
2022-04-13 00:47:32 +02:00
Anton Bretting 2f04831817
Fix various golangci-lint errors (#2059) 2022-02-12 20:28:08 +09:00
Babis K d34dc7bb64
Add support for --insecure-skip-tls-verify flag on helm repo add command (#1990)
Parses a new field in repositories named `skipTLSVerify` and if set to `true`, it appends `--insecure-skip-tls-verify` in `helm repo add` command.

This should be useful with internal self-signed repos, mitm proxies etc.

Resolves #1871
2021-12-21 09:18:57 +09:00
Alex Meddin 46b17e2cdb
feat: pass-credentials to repo (#1899)
This adds the ability to include the --pass-credentials flag to the helm add repo command by:

- Adding repo.passCredentials to the helmfile yaml
- Changing state, helmexec, and app to include RepositorySpec.PassCredentials

Resolves #1898

Co-authored-by: almed4 <alexandre.meddin@ingka.ikea.com>
2021-07-02 07:31:16 +09:00
Philipp Hossner 85accf7330
Add helm-secrets-encrypted values template file (#1701)
Secret files ending with .gotmpl are now also rendered as a gotemplate.

```
releases:
- name: myapp
  secrets:
  - secrets.yaml.gotmpl
```

Note that currently, .gotmpl files must be valid YAML files as well.

The expected use-case of this feature is to compose a YAML array from values and encrypted secrets.

Without this feature, you would have tried to do something like the below, which didn't work.

**Example (doesn't work!)**

`values.yaml.gotmpl`:

```
environment:
  -   name: MY_EXTERNAL_IP
      value: |
          {{ exec "./get-external-ip.sh" (list "") }}
```

`secrets.yaml`:
```
_sops:
  #...
environment:
  - name: MY_SECRET_VALUE
    value: (encrypted by sops)
```

`helmfile.yaml`:

```
releases:
- name: foo
  values:
  - values.yaml
  secrets:
  - secrets.yaml
```

This doesn't work because `values.yaml` and the decrypted `secrets.yaml` are passed to `helm` to be merged, and helm overrides the array instead of merging or concatenating the arrays.

**Example (works!)**

Instead of `values.yaml` and `secrets.yaml`, you provide a single `secrets.yaml.gotmpl` that is a valid YAML and encrypted by sops:

```
_sops:
  #...
environment:
  -   name: MY_EXTERNAL_IP
      value: |
          {{ exec "./get-external-ip.sh" (list "") }}
  - name: MY_SECRET_VALUE
    value: (encrypted by sops)
```

`helmfile.yaml`:

```
releases:
- name: foo
  secrets:
  - secrets.yaml.gotmpl
```

Helmfile decrypts the gotmpl by handing it over to helm-secrets and then renders the result as a gotmpl file. The end result is that you have a two-element array `environments` that can be just passed to helm.

Resolves #1700

Co-authored-by: Yusuke Kuoka <ykuoka@gmail.com>
2021-04-06 14:20:42 +09:00
Andrey Tuzhilin db9d31ac06 test: fix DecryptSecret output 2021-03-23 17:19:40 +09:00
Jason Witkowski 2618cfb38b
Enable --wait-for-jobs flag introduced in helm 3.5 (#1715)
Fixes #1650
Fixes #785

This change introduces:

- `--wait-for-jobs` CLI override option to helmfile binary
- `waitForJobs` helmDefaults parameter (default `false`)
- `waitForJobs` release parameter (default `false`)

Note that `--wait-for-jobs` was introduced in Helm 3.5 (https://github.com/helm/helm/pull/8363)
2021-03-23 16:53:57 +09:00
Chris Mellard 2a71640095
feat: added in oci repository flag and added helm methods to pull and export charts (#1629) 2021-01-28 09:02:00 +09:00
Yusuke Kuoka 88884b68dc
feat: `helmfile template --skip-cleanup` (#1570)
* feat: `helmfile template --skip-cleanup`

Resolves #1517
2020-11-06 09:23:49 +09:00
Wi1dcard cd4afc3269
Remove duplicated logs from helm.exec. (#1538)
While using the `--debug` option, the output of helm seems to be printed triple times:

```
Templating release=test, chart=charts/test
exec: helm template test charts/test --namespace staging --values /tmp/values266548685 --output-dir outputs//helmfile-test-staging-ed5e3c94-test --debug
helm:MRAjW> install.go:172: [debug] Original chart version: ""
helm:MRAjW> install.go:189: [debug] CHART PATH: /app/charts/test
helm:MRAjW> wrote outputs//helmfile-test-staging-ed5e3c94-test/test/templates/secret.yaml
helm:MRAjW> wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/configmap.yaml
helm:MRAjW> wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/health-configmap.yaml
helm:MRAjW> wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/headless-svc.yaml
helm:MRAjW> wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/metrics-svc.yaml
helm:MRAjW> wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/redis-master-svc.yaml
helm:MRAjW> wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/redis-master-statefulset.yaml
helm:MRAjW> wrote outputs//helmfile-test-staging-ed5e3c94-test/test/templates/ingress.yaml
helm:MRAjW> wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/metrics-prometheus.yaml
helm:MRAjW>
exec: helm template test charts/test --namespace staging --values /tmp/values266548685 --output-dir outputs//helmfile-test-staging-ed5e3c94-test --debug: wrote outputs//helmfile-test-staging-ed5e3c94-test/test/templates/secret.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/configmap.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/health-configmap.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/headless-svc.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/metrics-svc.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/redis-master-svc.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/redis-master-statefulset.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/templates/ingress.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/metrics-prometheus.yaml


wrote outputs//helmfile-test-staging-ed5e3c94-test/test/templates/secret.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/configmap.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/health-configmap.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/headless-svc.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/metrics-svc.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/redis-master-svc.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/redis-master-statefulset.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/templates/ingress.yaml
wrote outputs//helmfile-test-staging-ed5e3c94-test/test/charts/redis/templates/metrics-prometheus.yaml
```

- The first with the prefixes `helm:MRAjW>` comes from <563fce4adf/pkg/helmexec/runner.go (L59-L65)>

- The second one with the format `exec: helm ... --debug: ...` comes from <563fce4adf/pkg/helmexec/exec.go (L369)>

- And the last are the logs of non-debug mode.

It sometimes makes the log a bit confusing, while I first time read the log, I thought helmfile executed helm command multiple times 😅.

Since we already piped helm outputs to stdout (the first), we remove the second logs.
2020-10-15 08:50:56 +09:00
Javier Palacios 8f8669778c
Support for azure acr helm repositories (#1526)
Adds a basic support for Helm repositories hosted on Azure Container Registry (not OCI but classic ones). Add a new field to RepositorySpec to state that is externally managed and runs the `az-cli` command instead of the helm one to manage the repository.
2020-10-15 08:45:45 +09:00
Wi1dcard 5d8eba9b29
Append --force-update for specific helm versions. (#1494)
* Parse and process helm version using github.com/Masterminds/semver/v3.

* Add --force-update only when Helm version >= 3.3.2, < 3.3.4.

See: https://github.com/helm/helm/pull/8777.

* Add test cases.
2020-10-12 09:20:55 +09:00