From 19b436c9116d7411bf7a1b717c46f803975c6596 Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Sun, 7 Mar 2021 18:16:36 +0100 Subject: [PATCH 01/12] Improve annotation test. Make sure existing annotations are preserved --- cmd/khelm/fn_test.go | 1 + example/empty-annotations/templates/template.yaml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/cmd/khelm/fn_test.go b/cmd/khelm/fn_test.go index 5dfe210..894785f 100644 --- a/cmd/khelm/fn_test.go +++ b/cmd/khelm/fn_test.go @@ -246,6 +246,7 @@ func TestKptFnCommand(t *testing.T) { "\n config.kubernetes.io/path: my/output/path/kustomization.yaml\n", "\n config.kubernetes.io/path: my/output/path/serviceaccount_sa1.yaml\n", "\n config.kubernetes.io/path: my/output/path/serviceaccount_sa2.yaml\n", + " myannotation: should-be-preserved\n", }, }, { diff --git a/example/empty-annotations/templates/template.yaml b/example/empty-annotations/templates/template.yaml index bc7c216..f27a21f 100644 --- a/example/empty-annotations/templates/template.yaml +++ b/example/empty-annotations/templates/template.yaml @@ -2,6 +2,8 @@ apiVersion: v1 kind: ServiceAccount metadata: name: sa1 + annotations: + myannotation: should-be-preserved --- apiVersion: v1 kind: ServiceAccount From 56269865d59a8ff373ee23275516e85f53466856 Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Sun, 7 Mar 2021 19:26:27 +0100 Subject: [PATCH 02/12] Create CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..7ceb17e --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at max.goltzsche@gmail.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq From 7ee3237428a135d3986d59e8869fd25eccda5b41 Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Sun, 7 Mar 2021 19:51:24 +0100 Subject: [PATCH 03/12] Create CONTRIBUTING.md --- CONTRIBUTING.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..7a9b511 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,21 @@ +# How to contribute + +Contributions, questions and feedback to this project are welcome. +There are just a few small guidelines you need to follow. + +## Community guidelines + +This project follows the [Contributor Covenant Code of Conduct](./CODE_OF_CONDUCT.md). + +## Providing pull requests (PRs) + +* Create one PR per feature. +* Provide one commit per PR. +* Provide a description with each PR and commit that describes the problem, how it was solved, how that changes the behaviour for the user (if any) and links an issue (if any). +* All submissions require a review. +* All commits should be signed using PGP and a [DCO](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin). This can be done using `git commit -s -S`. +* When providing a bug fix or feature PR please also provide tests. + +## Building and testing the source + +See [here](./README.md#build-and-test). From 48f018752d2e238cce10c3b568b0bfca62f40df3 Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Sun, 7 Mar 2021 20:20:48 +0100 Subject: [PATCH 04/12] Update CONTRIBUTING.md --- CONTRIBUTING.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7a9b511..374e126 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,11 +7,31 @@ There are just a few small guidelines you need to follow. This project follows the [Contributor Covenant Code of Conduct](./CODE_OF_CONDUCT.md). +## Creating issues + +Feedback, questions, bug reports and feature requests are welcome in form of issues. +Though before creating an issue please have a look [here](https://github.com/mgoltzsche/khelm/issues) if the issue doesn't exist already in order to avoid duplicates. +When you cannot find a corresponding issue please create a [new one](https://github.com/mgoltzsche/khelm/issues/new). + +### Bug reports + +When reporting a bug please answer the following questions within the issue description: +* Which environment and version did you use? Does it happen with the latest version as well? +* What did you do and what happened? (in a reproducible way ideally) +* What do you expect instead? + +### Feature requests + +When creating a feature request please explain the feature within the issue description, how you want it to behave and why you need it this way. + ## Providing pull requests (PRs) +While there is no need to create an issue before creating a PR please consider discussing large changes within an issue first. + +When creating a PR the following rules apply: * Create one PR per feature. * Provide one commit per PR. -* Provide a description with each PR and commit that describes the problem, how it was solved, how that changes the behaviour for the user (if any) and links an issue (if any). +* Provide a description with each PR and commit that links an issue (if any), describes the problem, how it was solved and how the solution changes the user-facing behaviour. * All submissions require a review. * All commits should be signed using PGP and a [DCO](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin). This can be done using `git commit -s -S`. * When providing a bug fix or feature PR please also provide tests. From 985cd0bee55ef3270ab21d7f41a273f47c355615 Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Sun, 7 Mar 2021 20:28:37 +0100 Subject: [PATCH 05/12] Update CONTRIBUTING.md --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 374e126..2b8b93f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,11 +24,11 @@ When reporting a bug please answer the following questions within the issue desc When creating a feature request please explain the feature within the issue description, how you want it to behave and why you need it this way. -## Providing pull requests (PRs) +## Creating pull requests (PRs) While there is no need to create an issue before creating a PR please consider discussing large changes within an issue first. -When creating a PR the following rules apply: +When creating a PR please follow these rules: * Create one PR per feature. * Provide one commit per PR. * Provide a description with each PR and commit that links an issue (if any), describes the problem, how it was solved and how the solution changes the user-facing behaviour. From 711ec5d759ff6ceb38d0fa1cdfcdcd3bb9ff01e8 Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Sun, 7 Mar 2021 20:56:41 +0100 Subject: [PATCH 06/12] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 30 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 +++++++++++++++ .github/ISSUE_TEMPLATE/question.md | 10 ++++++++ 3 files changed, 60 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/question.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..47aab09 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,30 @@ +--- +name: Bug report +about: Create a report to help us improve +title: "[BUG]" +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Call '....' (make it reproducable by eventually providing the chart the problem occured with) +3. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**khelm version:*** +The khelm version you used. +Please copy the first line of the khelm log when templating or the output of `khelm version` (make sure you use the binary the problem occured with) here. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..a5b62af --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "[FEAT]" +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000..fa05338 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,10 @@ +--- +name: Question +about: Raise a question. +title: "[QUESTION]" +labels: '' +assignees: '' + +--- + +Please provide details and relevant context to your question here. From d98e9a6a091d433a1ea8068dd0063304991b187b Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Sun, 7 Mar 2021 21:03:59 +0100 Subject: [PATCH 07/12] Update CONTRIBUTING.md --- CONTRIBUTING.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2b8b93f..492faf9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # How to contribute -Contributions, questions and feedback to this project are welcome. +Contributions, questions and feedback are welcome. There are just a few small guidelines you need to follow. ## Community guidelines @@ -11,18 +11,23 @@ This project follows the [Contributor Covenant Code of Conduct](./CODE_OF_CONDUC Feedback, questions, bug reports and feature requests are welcome in form of issues. Though before creating an issue please have a look [here](https://github.com/mgoltzsche/khelm/issues) if the issue doesn't exist already in order to avoid duplicates. -When you cannot find a corresponding issue please create a [new one](https://github.com/mgoltzsche/khelm/issues/new). +When you cannot find a corresponding issue please create a [new one](https://github.com/mgoltzsche/khelm/issues/new/choose). ### Bug reports -When reporting a bug please answer the following questions within the issue description: -* Which environment and version did you use? Does it happen with the latest version as well? +When reporting a bug please answer the following questions: +* Which environment and version do you use? Does it happen with the latest version as well? * What did you do and what happened? (in a reproducible way ideally) * What do you expect instead? ### Feature requests -When creating a feature request please explain the feature within the issue description, how you want it to behave and why you need it this way. +When creating a feature request please answer the following questions: +* What is the problem? +* What do you want to change? +* How do you want it to behave? +* Why do you need it? +* Which alternatives did you consider? ## Creating pull requests (PRs) From 94858074338d0ba7a7416c90216040c9dcb978e0 Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Sun, 7 Mar 2021 21:07:00 +0100 Subject: [PATCH 08/12] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/question.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 47aab09..1a65423 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -19,7 +19,7 @@ Steps to reproduce the behavior: **Expected behavior** A clear and concise description of what you expected to happen. -**khelm version:*** +**khelm version:** The khelm version you used. Please copy the first line of the khelm log when templating or the output of `khelm version` (make sure you use the binary the problem occured with) here. diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index fa05338..a1927ac 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -1,6 +1,6 @@ --- name: Question -about: Raise a question. +about: Raise a question title: "[QUESTION]" labels: '' assignees: '' From 8b6b1f66b33494d074f03db764212adb6d052e67 Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Sun, 7 Mar 2021 21:21:21 +0100 Subject: [PATCH 09/12] Update CONTRIBUTING.md --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 492faf9..f7e165c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,7 +39,8 @@ When creating a PR please follow these rules: * Provide a description with each PR and commit that links an issue (if any), describes the problem, how it was solved and how the solution changes the user-facing behaviour. * All submissions require a review. * All commits should be signed using PGP and a [DCO](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin). This can be done using `git commit -s -S`. -* When providing a bug fix or feature PR please also provide tests. +* When submitting a bug fix or feature PR please also provide tests. +* When submitting a new feature please document it. ## Building and testing the source From 52c4bd5e85204a30f765d7a3a4c0ac937d0baa39 Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Tue, 16 Mar 2021 20:47:13 +0100 Subject: [PATCH 10/12] fix: dependency resolution, add kpt cache test. * Fixes a bug where a build of a single local chart with a remote dependency failed when repositories.yaml was not provided. * Adds a kpt example and e2e test to verify that caching works - the test also covers the bug fix. --- .gitignore | 1 + Makefile | 1 + e2e/kpt-cache-test.sh | 23 ++++++++++++ example/kpt/cache-dependencies/Kptfile | 6 ++++ example/kpt/cache-dependencies/Makefile | 11 ++++++ example/kpt/cache-dependencies/README.md | 5 +++ .../kpt/cache-dependencies/chart/Chart.yaml | 4 +++ .../chart/requirements.yaml | 4 +++ .../functions-local-chart-dependencies.yaml | 31 ++++++++++++++++ .../functions-remote-chart.yaml | 35 +++++++++++++++++++ pkg/helm/locate.go | 4 +++ pkg/helm/repositories.go | 2 +- 12 files changed, 126 insertions(+), 1 deletion(-) create mode 100755 e2e/kpt-cache-test.sh create mode 100644 example/kpt/cache-dependencies/Kptfile create mode 100644 example/kpt/cache-dependencies/Makefile create mode 100644 example/kpt/cache-dependencies/README.md create mode 100644 example/kpt/cache-dependencies/chart/Chart.yaml create mode 100644 example/kpt/cache-dependencies/chart/requirements.yaml create mode 100644 example/kpt/cache-dependencies/functions-local-chart-dependencies.yaml create mode 100644 example/kpt/cache-dependencies/functions-remote-chart.yaml diff --git a/.gitignore b/.gitignore index d7678af..013bbec 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ /example/kpt/**/requirements.lock /example/**/generated-manifest-without-secrets.yaml /example/kpt/linkerd/dep +/example/kpt/cache-dependencies/chart/charts diff --git a/Makefile b/Makefile index 0c8aa15..dc1837b 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,7 @@ e2e-test: image khelm-static kpt kustomize ./e2e/kustomize-plugin-test.sh; \ IMAGE=$(IMAGE) ./e2e/image-cli-test.sh; \ ./e2e/kpt-function-test.sh; \ + ./e2e/kpt-cache-test.sh; \ ./e2e/kpt-cert-manager-test.sh; \ ./e2e/kpt-linkerd-test.sh; \ } diff --git a/e2e/kpt-cache-test.sh b/e2e/kpt-cache-test.sh new file mode 100755 index 0000000..4685dbd --- /dev/null +++ b/e2e/kpt-cache-test.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +cd "$(dirname "$0")/../example" + +echo +echo " TEST $0: Run kpt functions of example/kpt/cache-dependencies" +echo + +set -e + +cd kpt/cache-dependencies +make clean + +( + set -ex + make manifest + [ -f generated-manifests/manifest1.yaml ] + [ -f generated-manifests/manifest1-from-cache.yaml ] + [ -f generated-manifests/manifest2.yaml ] + [ -f generated-manifests/manifest2-from-cache.yaml ] +) + +echo SUCCESS diff --git a/example/kpt/cache-dependencies/Kptfile b/example/kpt/cache-dependencies/Kptfile new file mode 100644 index 0000000..215a715 --- /dev/null +++ b/example/kpt/cache-dependencies/Kptfile @@ -0,0 +1,6 @@ +apiVersion: kpt.dev/v1alpha1 +kind: Kptfile +metadata: + name: cache-dependencies +packageMetadata: + shortDescription: An caching example diff --git a/example/kpt/cache-dependencies/Makefile b/example/kpt/cache-dependencies/Makefile new file mode 100644 index 0000000..7a0a45e --- /dev/null +++ b/example/kpt/cache-dependencies/Makefile @@ -0,0 +1,11 @@ +all: manifest + +manifest: + mkdir -p $$HOME/.helm + kpt fn run --as-current-user --network \ + --mount "type=bind,src=$$HOME/.helm,dst=/helm,rw=true" \ + --mount "type=bind,src=`pwd`,dst=/source,rw=true" \ + . + +clean: + rm -rf chart/charts chart/requirements.lock generated-manifests diff --git a/example/kpt/cache-dependencies/README.md b/example/kpt/cache-dependencies/README.md new file mode 100644 index 0000000..e1dd78b --- /dev/null +++ b/example/kpt/cache-dependencies/README.md @@ -0,0 +1,5 @@ +# kpt function example with caching + +This example is used as e2e test and shows that Helm dependencies can be cached. + +Caching can be enabled by mounting a host directory to `/helm` within the container (see `Makefile`). diff --git a/example/kpt/cache-dependencies/chart/Chart.yaml b/example/kpt/cache-dependencies/chart/Chart.yaml new file mode 100644 index 0000000..b50465d --- /dev/null +++ b/example/kpt/cache-dependencies/chart/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: example chart +name: example +version: 0.0.1 diff --git a/example/kpt/cache-dependencies/chart/requirements.yaml b/example/kpt/cache-dependencies/chart/requirements.yaml new file mode 100644 index 0000000..f9c91e0 --- /dev/null +++ b/example/kpt/cache-dependencies/chart/requirements.yaml @@ -0,0 +1,4 @@ +dependencies: +- name: cert-manager + version: 1.0.2 + repository: https://charts.jetstack.io diff --git a/example/kpt/cache-dependencies/functions-local-chart-dependencies.yaml b/example/kpt/cache-dependencies/functions-local-chart-dependencies.yaml new file mode 100644 index 0000000..a2e5c94 --- /dev/null +++ b/example/kpt/cache-dependencies/functions-local-chart-dependencies.yaml @@ -0,0 +1,31 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: local-chart-deps-uncached + annotations: + config.kubernetes.io/function: | + container: + image: mgoltzsche/khelm:latest + network: true + config.kubernetes.io/local-config: "true" +data: + chart: ./source/chart + name: cert-manager + namespace: cert-manager + outputPath: generated-manifests/manifest2.yaml +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: local-chart-deps-cached + annotations: + config.kubernetes.io/function: | + container: + image: mgoltzsche/khelm:latest + network: false + config.kubernetes.io/local-config: "true" +data: + chart: ./source/chart + name: cert-manager + namespace: cert-manager + outputPath: generated-manifests/manifest2-from-cache.yaml diff --git a/example/kpt/cache-dependencies/functions-remote-chart.yaml b/example/kpt/cache-dependencies/functions-remote-chart.yaml new file mode 100644 index 0000000..723a973 --- /dev/null +++ b/example/kpt/cache-dependencies/functions-remote-chart.yaml @@ -0,0 +1,35 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: remote-chart-uncached + annotations: + config.kubernetes.io/function: | + container: + image: mgoltzsche/khelm:latest + network: true + config.kubernetes.io/local-config: "true" +data: + repository: https://charts.jetstack.io + chart: cert-manager + version: 1.1.0 + name: cert-manager + namespace: cert-manager + outputPath: generated-manifests/manifest1.yaml +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: remote-chart-cached + annotations: + config.kubernetes.io/function: | + container: + image: mgoltzsche/khelm:latest + network: false + config.kubernetes.io/local-config: "true" +data: + repository: https://charts.jetstack.io + chart: cert-manager + version: 1.1.0 + name: cert-manager + namespace: cert-manager + outputPath: generated-manifests/manifest1-from-cache.yaml diff --git a/pkg/helm/locate.go b/pkg/helm/locate.go index a1177b1..67f5185 100644 --- a/pkg/helm/locate.go +++ b/pkg/helm/locate.go @@ -54,6 +54,10 @@ func locateChart(ctx context.Context, cfg *config.LoaderConfig, repos repository } if _, err = os.Stat(cacheFile); err == nil { + cacheFile, err = filepath.EvalSymlinks(cacheFile) + if err != nil { + return "", errors.Wrap(err, "normalize cached file path") + } if cfg.Verify { if _, err := downloader.VerifyChart(cacheFile, cfg.Keyring); err != nil { return "", err diff --git a/pkg/helm/repositories.go b/pkg/helm/repositories.go index dabe1d3..215f9dc 100644 --- a/pkg/helm/repositories.go +++ b/pkg/helm/repositories.go @@ -90,7 +90,7 @@ type repositories struct { } func (f *repositories) RequireTempHelmHome(createTemp bool) { - f.entriesAdded = createTemp + f.entriesAdded = f.entriesAdded || createTemp } func newRepositories(settings *cli.EnvSettings, getters getter.Providers) (r *repositories, err error) { From 3eb087d0062fc6abf1f42524534f3b623e530e71 Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Tue, 16 Mar 2021 21:14:20 +0100 Subject: [PATCH 11/12] docs: document caching for kpt users. Relates to #15. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 7031ee7..9908b79 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,10 @@ If necessary the chart output can be transformed using kustomize. This can be done by declaring the khelm and a kustomize function orderly within a file and specifying the chart output kustomization as input for the kustomize function as shown in the [cert-manager example](example/kpt/cert-manager). A more complex example that also manages a Helm chart from another git repository locally as kpt dependency can be found [here](example/kpt/linkerd). +#### Caching Helm repo indexes and dependencies + +When external Helm Charts are used the download of their repositories' index files and of the charts itself can take a significant amount of time that adds up when running multiple functions or calling a function frequently during development. +To speed up these cases you can enable caching by mounting a host directory to `/helm` within the function container as shown [here](example/kpt/cache-dependencies). ### kustomize exec plugin From 7336484dbe0875de37edbdd6cd4ec8bcc576e274 Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Tue, 16 Mar 2021 21:31:33 +0100 Subject: [PATCH 12/12] docs: repository configuration --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9908b79..c0f4c6a 100644 --- a/README.md +++ b/README.md @@ -87,10 +87,10 @@ If necessary the chart output can be transformed using kustomize. This can be done by declaring the khelm and a kustomize function orderly within a file and specifying the chart output kustomization as input for the kustomize function as shown in the [cert-manager example](example/kpt/cert-manager). A more complex example that also manages a Helm chart from another git repository locally as kpt dependency can be found [here](example/kpt/linkerd). -#### Caching Helm repo indexes and dependencies +#### Caching Helm Charts and repository index files When external Helm Charts are used the download of their repositories' index files and of the charts itself can take a significant amount of time that adds up when running multiple functions or calling a function frequently during development. -To speed up these cases you can enable caching by mounting a host directory to `/helm` within the function container as shown [here](example/kpt/cache-dependencies). +To speed this up caching can be enabled by mounting a host directory to `/helm` within the function container as shown [here](example/kpt/cache-dependencies). ### kustomize exec plugin @@ -203,7 +203,9 @@ It exposes a `Helm` struct that provides a `Render()` function that returns the ### Repository configuration -Repository credentials can be configured using helm's `repositories.yaml` which can be passed through as `Secret` to generic build jobs. khelm downloads repo index files when needed. +Repository credentials can be configured using Helm's `repositories.yaml` which can be passed through as `Secret` to generic build jobs. khelm downloads the corresponding repo index files when needed. + +When running khelm as kpt function or within a container the `repositories.yaml` should be mounted to `/helm/repository/repositories.yaml`. Unlike Helm khelm allows usage of any repository when `repositories.yaml` is not present or `--trust-any-repo` is enabled.