Backport of https://github.com/helm/helm/pull/6010 to dev-v3 (the
description below is a copy-paste from the original v2 branch PR).
As https://github.com/helm/helm/pull/6016 is now merged to dev-v3, the
change is reasonably trivial.
This change is an attempt to address the common problem of json number
unmarshalling where any number is converted into a float64 and
represented in a scientific notation on a marshall call. This behavior
breaks things like: chart versions and image tags if not converted to
yaml strings explicitly.
An example of this behavior: k8s failure to fetch an image tagged with a
big number like: $IMAGE:20190612073634 after a few steps of yaml
re-rendering turns into: $IMAGE:2.0190612073634e+13.
Example issue: #1707
This commit forces yaml parser to use JSON modifiers and explicitly
enables interface{} unmarshalling instead of float64. The change
introduced might be breaking so should be processed with an extra care.
Due to the fact helm mostly dals with human-produced data (charts), we
have a decent level of confidence this change looses no functionality
helm users rely upon (the scientific notation).
Relevant doc: https://golang.org/pkg/encoding/json/#Decoder.UseNumber
Signed-off-by: Oleg Sidorov <oleg.sidorov@booking.com>
Signed-off-by: Oleg Sidorov <me@whitebox.io>
This commit replaces usage of github.com/ghodss/yaml with it's forked
version maintained by SIG community. The replaced library has
low-to-none support activity unlike the latter. We believe the new
Helm branch could benefit from using the community-supported version on
a long-term run as yaml parser is a key component of Helm chart rendering
engine.
This commit locks sigs.k8s.io/yaml dependency version on 1.1.0 which
is backwards compatible with ghodss/yaml 1.0.0.
This change also resolves the outdated dependency version lock for
ghodss/yaml (currently 1.0.0) and makes it possible to port changes from
https://github.com/helm/helm/pull/6010 to dev-v3.
Signed-off-by: Oleg Sidorov <oleg.sidorov@booking.com>
The 'app.kubernetes.io/version' label was not being rendered as
expected. It was appending onto the label before it and also
the next label label was appending onto it on the same line.
Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
Want to avoid moving tags like using 'stable'. Therefore,
specify the specifc nginx version/tag.
Update from comment review:
- https://github.com/helm/helm/pull/5662#discussion_r280122531
Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
* Add the Schema type and a function to read it
* Added a function to read a schema from a file
* Check that values.yaml matches schema
This commit uses the gojsonschema package to validate a values.yaml file
against a corresponding values.schema.yaml file.
* Add functionality to generate a schema from a values.yaml
* Add Schema to Chart and loader
* Clean up implementation in chartutil
* Add tests for helm install with schema
* Add schema validation to helm lint
* Clean up "matchSchema"
* Modify error output
* Add documentation
* Fix a linter issue
* Fix a test that broke during a rebase
* Clean up documentation
* Specify JSONSchema spec
Since JSONSchema is still in a draft state as of this commit, we need to
specify a particular version of the JSONSchema spec
* Switch to using builtin functionality for file extensions
* Switch to using a third-party library for JSON conversion
* Use the constants from the gojsonschema package
* Updates to unit tests
* Minor change to avoid string cast
* Remove JSON Schema generation
* Change Schema type from map[string]interface{} to []byte
* Convert all Schema YAML to JSON
* Fix some tests that were broken by a rebase
* Fix up YAML/JSON conversions
* This checks subcharts for schema validation
The final coalesced values for a given chart will be validated against
that chart's schema, as well as any dependent subchart's schema
* Add unit tests for ValidateAgainstSchema
* Remove nonessential test files
* Remove a misleading unit test
The TestReadSchema unit test was simply testing the ReadValues function,
which is already being validated in the TestReadValues unit test
* Update documentation to reflect changes to subchart schemas
When creating a Helm chart for the first time, the assumption should be that the app version is also 0.1.0, implying this is for a new application.
Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
Make template specific functions private to ensure they not misused and
make unit tests simpler. We may export the template helpers later if
needed.
This lays the foundation for the new chart pipeline.
Signed-off-by: Adam Reese <adam@reese.io>
* Remove helmVersion constraint from charts
* Guard compile time set variables behind `internal/`
* Allow configuration of UserAgent for HTTPGetter
Signed-off-by: Adam Reese <adam@reese.io>
This fixes a dozen or so style errors, almost all of which were just missing comments.
I left several which are fixed in other outstanding PRs, or which belong to code that is about to be removed.
Signed-off-by: Matt Butcher <matt.butcher@microsoft.com>
Enable to use charts with dependencies that have conditions (e.g. in
umbrella charts). Allow aliases for dependencies that have dependencies
with conditions.
Closes#3734
Signed-off-by: Christian Koeberl <christian.koeberl@gmail.com>
`toYaml` utilized by `.Files` was introducing a new line. It is an issue since the new line is part of a functions output, it can't be whitespace chomped away so it would require a `trimSuffix "\n"` pipe. This commit trims one trailing `\n` from the toYaml output.
* fix(helm): fix golint warning due to ApiVersionV1 constant name
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
* fix(helm): fix golint warning due to ResolveChartVersionAndGetRepo comment
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
* fix(helm): fix golint warnings on HttpGetter type and SetCredentials method missing a comment
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
* fix(helm):fix golint warning due to comment on FindChartInAuthRepoURL function
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
* fix(helm): fix golint warning due to RepoFile type name
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
* fix(helm): fix golint warning due to ParseString comment
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
Prior to this, using the semver template functions with the full
version, which is represented in the GitVersion, was not possible
for helm template and lint commands because the property was not
populated by default. This update adds default handling.
Closes#3349
* Add template for chart name
* Use named ports and simplify service configuration
* Add affinity
* Add tolerations
* Use 'with' statements where possible
* Enhance ingress
* Add fullnameOverride to fullname template
This commit adds --kube-version flag to helm template. It allows you to
override the Kubernetes version used as Capabilities.KubeVersion.Major/Minor (e.g. 1.7).
The alias functionality only works when a hardcoded version
is used. Any use of semver logic causes unexpected behavior.
I use version.IsCompatibleRange to check the dependency version.
Closes#2794
- Note that this covers all YAML null syntax options:
ref: http://yaml.org/type/null.html
- Note that we do a nil comparison because the encoding/yaml package parses
YAML properly and any variation of null, Null, NULL, or ~ is converted to nil
by the time we get here.
Added more tests to test following comibnations of subcharts and requirements.yaml
- [ ] subcharts not specified in requirements.yaml
- [ ] some subcharts specified in requirements.yaml while others should be picked directly from "charts\"
- [ ] all subcharts specified in requirements.yaml without alias
- [ ] subcharts specified in requirements.yaml with alias is already tested
This fixes a TOML panic by replacing one parser library with another.
The older library did not gracefully handle reflection issues, and so
was prone to panic. The new one is not great, but it doesn't seem to
panic.
Closes#2271
In third-party libraries, charts can be embedded in memory rather than in files, directories or
tarballs. Exposing LoadFiles allows a third-party library the ability to load static templates
in and spit out a *chart.Chart.
This feature adds the ability to selectively control the loading of charts using entries in top chart's values.
When 'helm install --set tags.mytag=true', charts with that tag will be enabled unless disabled in parent by condition.
When 'helm install --set mychart.enabled=true', charts with that yaml path specified will be enabled.
Closes#1837
since kubernetes 1.4, the upper limit for resource name is 63 characters,
so it is better to change the template when running `helm create` accordingly.
This adds the {{.Capabilities}} object to the template variables so that
chart authors can write charts that are aware of teh Kubernetes
capabilities of the current cluster.
Closes#1608
For archived files the Chart.yaml file should be contained in a base
directory. This commit adds an error when the Chart.yaml file is found
in the root directory.
Fixes#1171
This causes 'helm dep [up|install]' to ignore files in charts/ that
start with either a dot or an underscore. It also changes the
chartloader to ignore those files.
Also, if a 'helm dep up' does not find a charts/ directory, it creates
one.
Closes#1342
When `helm install -f foo.yaml bar` is called, and then the release is
upgraded with `helm upgrade happy-panda bar`, this will now re-use the
values that were submitted with `-f foo.yaml`. The same is true for
values specified with `--set`.
Closes#1227
Some fields were introduced to Chart metadata after Alpha.4, but are not
going to be used ever. So we made the decision to remove them before we
get stuck with ugliness.
This should not break compatibility, since these fields were not used.
This also refactors significant portions of the CLI, moving much of the
shared code into a library.
Also in this release, a testing repository server has been added.
This adds a few extra settings to the default .helmignore file. In
doing this, I found a bug that some directory patterns are not
evaluated correctly. Fixed that and added tests.
Closes#989Closes#1027
This changes "pkg/chartutil".Files.Get to return a string, removes
"pkg/chartutil".Files.GetString, and adds
"pkg/chartutil".Files.GetBytes.
Closes#1020
This fixes a bug in which passed-in values files were not correctly
merged into the chart's default values YAML data. I believe it also
fixes some other prioritization bugs in values merging.
The existing unit test was wrong (see TestCoalesceValues). It is
fixed now. Also added more tests to simulate issue #971.
In the course of writing this, I removed some vestigial code as
mentioned in #920.
Closes#971Closes#920
Handle a previously unhandled error in the linter. This simply bails out
if a chart's values files do not parse.
Also, changed the implementation of CoalesceValues to return a map even
on error.
This allows templates to access information about the template file.
Right now, the template can only access the .Template.Name, which is the
chart-relative path to the current template.
Closes#894
This makes the Table() method more flexible than the original version.
It allows either a map[string]interface{} or a chartutil.Values to be
treated as a table.
Template rules
Adding chart errors
Added function that checks the existence of all the values in the templates
Adding chartfile unit tests
Testing runLinterRule
Fixing out of range
Fixing out of range
Improving quote detector
This adds support for .helmignore files. These files roughly follow
the conventions established for .gitignore files:
https://git-scm.com/docs/gitignoreCloses#748
This provides support for "global" variables. It does this by
declaring "global" to be a special namespace. It then copies this
namespace into every subchart, coalescing it into any "global"
namespace found there.
The net result is that if "global.foo" is set in the YAML file, it
will be available to every chart/subchart as ".global.foo" regardless of
where that chart is in the subchart tree.
This is a refactor of the loader to use in-memory buffers instead of
trying to optimize for memory usage by delaying reads until the last
possible moment. Since charts tend to stay well below 1M in size, this
makes more sense, and is easier to work with.