Commit Graph

136 Commits

Author SHA1 Message Date
Indrek Juhkam bdc6982172
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>
2022-12-12 16:43:10 +09:00
Yusuke Kuoka 8d2aec249d Use the new log capturing helper in all tests
Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
2022-11-13 08:53:53 +00:00
yxxhero 143f85b4f1 fix: helmfile template fails when selector matches a chart fetched with go-getter
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-11-13 15:10:57 +08:00
yxxhero bc255f3e51 fix: fix need logic in chart stage
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-10-24 09:51:04 +08:00
yxxhero 61233badd5 fix: issue path in test on windows
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-10-19 08:46:43 +08:00
Yusuke Kuoka b7da0965f1 fixup! Address a lint error
Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
2022-10-11 08:20:51 +08:00
Yusuke Kuoka ef115ba653 Address a lint error
Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
2022-10-11 08:20:51 +08:00
Yusuke Kuoka e001f6f05d Address golangci-lint finding
Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
2022-10-11 06:19:32 +09:00
Yusuke Kuoka 31cd729fd4 Prevent excessive log in tests
I had been unhappy with the fact that our go-test output had a lot of debug log messages which obfuscated test results.

I'm finally removeing all those by directing the test log output to io.Discard.

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
2022-10-11 06:19:32 +09: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
yxxhero bffa048dc6
Merge pull request #396 from helmfile/bump_yaml_v3
bump: upgrade gopkg.in/yaml.v2 to gopkg.in/yaml.v3
2022-10-05 10:12:25 +08: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
yxxhero 14ba7cd156 bump: upgrade gopkg.in/yaml.v2 to gopkg.in/yaml.v3
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-10-03 05:24:51 +08:00
Arpan e1ca846772
added option for --no-hooks for helm diff and apply (#279)
* added option for --no-hooks for helm diff and apply

Signed-off-by: Arpan Adhikari <kcarpan5@gmail.com>

* test case for --no-hooks

Signed-off-by: Arpan Adhikari <kcarpan5@gmail.com>

* fix test fails

Signed-off-by: Arpan Adhikari <kcarpan5@gmail.com>

* Resolve conflict with main

Signed-off-by: Arpan Adhikari <kcarpan5@gmail.com>

* fixup! Resolve conflict with main

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Add no-hooks case for diff test

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* fixup! Add no-hooks case for diff test

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

Signed-off-by: Arpan Adhikari <kcarpan5@gmail.com>
Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
Co-authored-by: Arpan Adhikari <arpan@thephotostudio.com.au>
Co-authored-by: Yusuke Kuoka <ykuoka@gmail.com>
2022-09-18 18:41:27 +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
Viktor Oreshkin af52c960f4 chore: list: withPreparedCharts -> skipCharts
Signed-off-by: Viktor Oreshkin <imselfish@stek29.rocks>
2022-09-06 09:54:51 +03:00
Viktor Oreshkin 4dd73d4efb test: move TestListWithJSONOutput to app_list_test
Signed-off-by: Viktor Oreshkin <imselfish@stek29.rocks>
2022-09-06 09:48:47 +03:00
Viktor Oreshkin f3788249e4 feat: add flag to list to skip prepare
Signed-off-by: Viktor Oreshkin <imselfish@stek29.rocks>
2022-09-05 18:12:17 +03:00
Viktor Oreshkin 822b7b2a9b feat: honor concurrency in withPreparedCharts
Signed-off-by: Viktor Oreshkin <imselfish@stek29.rocks>
2022-09-01 02:08:54 +03:00
Arkaitz Jimenez cc33e7b7d8
Introduce Helmfile's own filesystem abstraction to correctly unit test some components (#307)
Use abstracted FS

Signed-off-by: Arkaitz Jimenez <arkaitzj@gmail.com>

Signed-off-by: Arkaitz Jimenez <arkaitzj@gmail.com>
2022-08-24 12:58:43 +09:00
Yusuke Kuoka 89950f3794
Merge branch 'main' into update_golang_lint 2022-08-14 12:21:10 +09:00
David Ackroyd cf94a4edb3
Fix Inclusion of Releases for Other Environments (#276)
Fixing releases being included which do not match the environment
 requested, which is a regression introduced by #234. The issue remains
 when Helmfile state values are supplied, which is not a regression and
 will be addressed separately.

Partial resolution for #271

Signed-off-by: David Ackroyd <dackroyd@fairfaxmedia.com.au>

Signed-off-by: David Ackroyd <dackroyd@fairfaxmedia.com.au>
2022-08-14 10:47:47 +09:00
yxxhero 8690d63401 fix lint error
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-08-13 07:40:32 +08:00
yxxhero ac23def893 add Go lint
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-07-16 20:21:11 +08:00
yxxhero ae5e93d71d
Merge pull request #200 from magicmemories/fix/invalid-path-on-windows
Fix/invalid path on windows
2022-06-30 14:00:07 +08:00
Adam Gardner e106d105ce Don't make unnecessary whitespace changes
Signed-off-by: Adam Gardner <adam.gardner@magicmemories.com>
2022-06-29 15:06:40 -10:00
Adam Gardner a81c8fa4e1 chore: rename test so that snapshot data lives at valid path on all filesystems
Signed-off-by: Adam Gardner <adam.gardner@magicmemories.com>
2022-06-29 15:06:40 -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
Yusuke Kuoka fc306ec3d1
Make a few helmfile sub-commands consistently support needs-related flags (#78)
* Make a few helmfile sub-commands to consistently support needs-related flags

* helmfile-diff adds support for --include-transitive-needs
* helmfile-template adds support for --skip-needs
* helmfile-lint adds support for --skip-needs, --include-needs, and --include-transitive-needs

Ref https://github.com/roboll/helmfile/issues/2055

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Fix a few helmfile-lint needs related bugs and add tests

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Is include-transitive-needs realy working as intended? 🤔

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Confirm that it does fail on unselected need by default

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Add missing testdata

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Test helmfile-template for include/skip needs support

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Fix a few terms

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Add more tests to better know the current helmfile-diff behavior around needs

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Fix failing tests

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Fix helmfile-diff to consistently handle skip/include-needs

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Extract testhelper.RequireLog for reusing

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Fix all bugs and test cases for TestDiff and TestDiff_2

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Fix TestDiff_2

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Fix TestDiff

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Fix TestDiffWithNeeds

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Unify behavior on including disabled releases as needs for lint and template

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Fix bug that --include-transitive-needs does not imply include-needs

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
2022-06-20 07:19:39 +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
austin ce eb3484d4a8
Rename module to github.com/helmfile/helmfile
Also updates a few more references to the roboll/helmfile repository,
where possible.

Signed-off-by: austin ce <austin.cawley@gmail.com>
2022-05-18 10:05:07 -04:00
yxxhero 04d364a467 add unittest for ValidateConfig
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-04-27 07:38:22 +08:00
yxxhero 8b15272cbc fix go lint warn
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-04-20 15:59:12 +08:00
yxxhero a0d4047cc7 remove gotest deps
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-04-19 08:02:21 +08:00
Yusuke Kuoka 97e0ca73ca feat: Auto-detect term for coloring helm-diff output
Since helm-diff has added an ability to auto-detect the term to decide if it should output with color or not, helmfile had been defaulted to no-color.
This resoloves that, by adding a term-detection logic that is same as helm-diff.

As a part of this work, I have also implemented a new global flag `--color`, which is used for forcing color without relying on the term-detection logic implemented in helmfile or explicitly setting the HELM_DIFF_COLOR envvar. I hope it is useful for folks.

Ref https://github.com/roboll/helmfile/issues/2043

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
2022-04-06 02:38:36 +00:00
yxxhero e0244bc341 mv captureStdout as public func
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-04-03 22:24:38 +08:00
Anton Bretting 2f04831817
Fix various golangci-lint errors (#2059) 2022-02-12 20:28:08 +09:00
Sören Jentzsch 19927fc147
feat: Add --suppress option for diff and apply commands (#2077) 2022-02-03 08:46:39 +09:00
drivelikebrazil debd3c0eea
Add `--skip-tests` to helmfile template command (#2057)
* Add skip-tests to helmfile template command

* Fix formatting
2022-01-22 15:26:17 +09:00
Christoph Petrausch 346e318fd0
Correct enabled property in helmfile list (#1921)
Use the value of the `condition` field instead of the `installed` field of a release in the `enabled` column of helmfile list.
The value of the `installed` field is shown in a new `installed` column.

Fixes #1920

Co-authored-by: Yusuke Kuoka <ykuoka@gmail.com>
2022-01-10 17:24:07 +09:00
Mårten Svantesson fe8a176db5
feat: Option to pass kubeVersion to helm template (#2002) 2022-01-07 09:05:03 +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
Yusuke Kuoka 9efb7afb47
Do fail on a possible typo in `needs` entries (#2026)
* Do fail on a possible typo in `needs` entries

Helmfile kindly fails with a friendly error when you made a typo in a `needs` entry, i.e. a `needs` entry included a reference to a release that is not defined in the helmfile config.

Example Output:

```
in ./helmfile.needs.yaml: release(s) "app" depend(s) on an undefined release "infrastructure/cert-manager2". Perhaps you made a typo in `needs` or forgot defining a release named "cert-manager2" with appropriate `namespace` and `kubeContext`?
```

This prevents issues like #1959

* Fix regression in helmfile-diff (This may break when you had two or more duplicated releases that are intended to be de-duplicated before DAG calculation using selectors

* Fix regression when you used selector to deduplicate releases before DAG calculation

* Comments

* Fix regressions in helmfile-apply and helmfile-sync

* Fix regression in duplicate release detection
2021-12-18 17:44:55 +09:00
pjotre86 77e6268bcb
Add support for transitive dependencies. (#1983)
Co-authored-by: Peter Aichinger <petera@topdesk.com>
2021-10-20 17:55:08 +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
Quan TRAN ded0f1049a
Fix filepath handling on Windows (#1754) 2021-05-02 09:22:25 +09:00
Yusuke Kuoka 08db073958
Fix broken selector and DAG calculation logic after --{include,skip}-needs addition with correct Release IDs (#1823)
#1772 broke `--selector` with `needs` in many ways.

The two biggest problems I've encountered were:

- duplicate releases even if you've provided a proper `selector` to deduplicate
- sync/deletion ordering broken when you have `needs`

For the first issue, we had to update `getSelectedReleases` function to also calculate the "selected releases and releases needed by the selected releases", and use that to calculate the DAG. That should have been done in #1772.

The latter started happening after I've fixed the first issue. The source of the issue was that `needs` turned out to be ambiguous in a few cases.

Previously, `needs: ["foo/bar"]` had two meanings. One for "needs release bar in kubecontext foo", another for "needs release bar in namespace foo".

Moreover, `needs: ["foo/bar/baz"]` had three meanings.

- `needs release baz in tiller namespace foo and namespace baz`
- `needs release baz in namespace bar in kubecontext foo`
- `needs release baz in tiller namespace bar in kubecontext foo`.

Especially, the first meaning doesn't make sense at all. Helm 2 solely use tillerNamespace for namespacing the release and Helm 3 uses namespace for that.

This fix sorts all the bugs and issues I've found so far around that, by changing the meanings of the above two examples as follows:

- `foo/bar` means `namespace=foo,name=bar` for Helm 3 and `tillerNamespace=foo,name=bar` for Helm 2
  - `needs release bar in kubecontext foo` is now `foo//bar`. Notice the extra `/` between `foo` and `bar`.
- `foo/bar/baz` means `kubecontext=foo,namespace=bar,name=baz` for Helm 3 and `kubecontext=foo,tillerNamespace=bar,name=baz` in Helm 2

Fixes #1818
2021-05-01 21:59:25 +09:00
Yusuke Kuoka de8644a504
Fix --selector results to correctly deduplicate releases (#1822)
Fixes #1818
2021-05-01 15:06:07 +09:00
katsew f28ad5af23
Fix defaulting and overriding kubeContext (#1814)
Ref #1810

* fix defaulting and overriding kubeContext

* make defaulting kubeContext side-effect free

* checkDuplicates should check releases with overriden values
2021-05-01 12:42:29 +09:00