Commit Graph

68 Commits

Author SHA1 Message Date
anessi acf7158565
feat(helm): add --skip-schema-validation flag to helm 'install', 'upgrade' and 'lint'
When --skip-schema-validation is set, any schema contain in the helm chart is ignored. Defaults to 'false'.

Closes #10398

Signed-off-by: anessi <16045045+anessi@users.noreply.github.com>
2024-06-25 16:43:48 +02:00
Matt Farina 4e7e939f19
Updating the Go version in go.mod
At this time both Go 1.19 and 1.20 are supported. The version
specified in the go.mod file is the minimum version we expect Helm
to be compiled against. This is the oldest supported version to
support environments where others compile Helm. The Helm project
is using Go 1.20 to build Helm itself.

Updating to Go 1.19 also includes dealing with io/ioutil
deprecation and some additional linting issues around staticcheck.
All the staticcheck issues were in test files so linting was
skipped for those.

Signed-off-by: Matt Farina <matt.farina@suse.com>
2023-03-22 11:52:30 -04:00
yxxhero 39b0a82365 bump Go 1.18
Signed-off-by: yxxhero <aiopsclub@163.com>
2022-07-03 10:19:15 +08:00
Oleg Sidorov 44a81f63f7 Revert "chartutil.ReadValues is forced to unmarshal numbers into json.Number refs #1707 [dev-v3]"
This reverts commit f94bac0643.

Due to a major numeric regression detected in dev-v2 reported in #6708,
we believe the master branch (former dev-v3) is also impacted by this
change and will expose the same set of problems. In order to not
jeopardize the stability of helm3 this commit is reverted in favor of a
better fix in the future.

Signed-off-by: Oleg Sidorov <me@whitebox.io>
2019-10-23 09:27:51 +02:00
Matthew Fisher 402fce389a
fix(chartutil): restore .Release.Revision
Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
2019-10-17 11:04:45 -07:00
Ken Perkins 060def3b88 Fix chartutils/errors.go stack overflow
- Changes to use a struct with string property
- Changes references in chartutil/values.go

Signed-off-by: Ken Perkins <ken.perkins@rackspace.com>
2019-10-15 15:03:36 -07:00
Matt Farina 9bc7934f35
Updating the module for v3 as the major version
Signed-off-by: Matt Farina <matt@mattfarina.com>
2019-10-03 14:27:05 -04:00
Oleg Sidorov f94bac0643 chartutil.ReadValues is forced to unmarshal numbers into json.Number refs #1707 [dev-v3]
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>
2019-07-17 10:30:51 +02:00
Oleg Sidorov ec440d446d Replaced ghodss/yaml with sigs.k8s.io/yaml
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>
2019-07-12 16:52:15 +02:00
Adam Reese b49db9e6e6
ref(pkg/chartutil): break up chartutil into logical files
Signed-off-by: Adam Reese <adam@reese.io>
2019-05-22 19:38:11 +02:00
Adam Reese 590bf10ab5
fix(pkg/action): add namespace to release options
ref: https://github.com/helm/helm/issues/5732

Signed-off-by: Adam Reese <adam@reese.io>
2019-05-15 14:08:51 -07:00
Adam Reese 097834de0a
ref(pkg/chartutil): remove k8s version object dependency
Flattens the `.Capabilities` built-in and removes useless kubernetes
runtime metadata.

Signed-off-by: Adam Reese <adam@reese.io>
2019-05-07 13:49:05 -07:00
Ian Howell ffff0e8c33 Feat/schema validation (#5350)
* 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
2019-04-26 08:45:03 -07:00
Adam Reese 295092cd7d
ref(pkg/action): refactoring dup code and linter fixes
Signed-off-by: Adam Reese <adam@reese.io>
2019-03-26 11:11:27 -07:00
Adam Reese 895e9192d4
feat(*): use vanity import helm.sh/helm
Signed-off-by: Adam Reese <adam@reese.io>
2019-03-13 13:43:47 -07:00
Adam Reese 849f27d11f
ref(pkg/engine): make template specific functions private
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>
2019-03-06 15:45:52 -08:00
Matt Butcher f3bfae5ea7
fix: fix a number of style errors (#5136)
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>
2019-01-07 21:40:24 -07:00
Adam Reese 2b81eea1e2
ref(*): replace byte array with map for Release config
Signed-off-by: Adam Reese <adam@reese.io>
2018-12-04 15:57:24 -08:00
Adam Reese 6fc8c9e079
ref(pkg/chartutil): simplify chart dependency unit tests
- simplify unit tests
- refactor typed errors
- unexport internal functions

Signed-off-by: Adam Reese <adam@reese.io>
2018-11-29 10:30:52 -08:00
Adam Reese 9e1e26f01e
ref(pkg/chartutil): attempt to make requirements processing readable
Signed-off-by: Adam Reese <adam@reese.io>
2018-11-14 12:41:14 -08:00
Adam Reese f7a7a157ce
ref(*): merge requirement.yaml into Chart.yaml
Signed-off-by: Adam Reese <adam@reese.io>
2018-08-29 14:05:37 -07:00
Adam Reese 516c53dae6
ref(chart): use map for chart.Values
Signed-off-by: Adam Reese <adam@reese.io>
2018-08-29 09:56:19 -07:00
Adam Reese 4f26b658d8
change copyright to "Copyright The Helm Authors" 2018-08-24 12:03:55 -07:00
Adam Reese f012940d9c
ref(*): refactor chart/chartutil
ref(chartutil): move chart loading out of chartutil into new package
    add chart loader interface to allow lazy loading
feat(chart): create chart accessors
ref(*): cleanup requirements
ref(tiller): remove optional template engines
ref(tiller): simplify sorting releases and hooks
ref(*): code simplification
ref(hapi): move chart package out of hapi
ref(chart): add requirements and lock to Chart struct
2018-08-24 11:28:29 -07:00
Adam Reese aa859e3f88
feat(*): remove Time, Namespace, and Revision from template functions
Removes Time, Namespace, and Revision from being exposed to templates to
make template rendering discrete and repeatable.
2018-05-18 12:09:54 -07:00
Adam Reese b1128abf4f
ref(*): s/tiller/helm/ 2018-05-10 09:41:31 -07:00
Adam Reese 726e3c41be
feat(*): print stacktrace on error with debug enabled 2018-05-10 09:34:41 -07:00
Adam Reese 4c95185164
ref(*): replace chart.config with []byte 2018-04-20 00:13:19 -07:00
Adam Reese 36536d77ba
ref(*): remove protobuf any type 2018-04-18 16:28:50 -07:00
Adam Reese 91a6ebfed5
ref(*): remove protobuf timestamps 2018-04-18 15:35:37 -07:00
Adam Reese 6345f04190
ref(hapi): convert protobuf to go types 2018-04-18 14:53:38 -07:00
Steven E. Harris e8d80729ac Merge pull request #2703 from rbwsam/ref/simplify_error
ref(pkg/chartutil): replace use of 'fmt.Efforf'
2017-07-25 10:14:32 -04:00
Sam Leavens 098df8b186 ref(pkg/chartutil): improve comment spacing
Reduce comment spacing to single tab.
2017-07-20 14:21:40 -07:00
Sam Leavens f7ca52dfc8 ref(pkg/chartutil): improve comment for PathValue
Make comment for PathValue more explanatory.
2017-07-20 13:59:28 -07:00
Sam Leavens 8df52b6501 ref(pkg/chartutil): move comment
Move comment out of test. Move ref location in test.
2017-07-20 13:10:59 -07:00
Sam Leavens 3ee70291c8 ref(pkg/chartutil): Capitalize YAML
Capitalize "yaml" in error message. Remove empty var from test error message.
2017-07-20 11:52:49 -07:00
Sam Leavens 51b59497ee ref(pkg/chartutil): decrease map lookups
Decrease map lookups in `chartutil.coalesceValues` and move comment to unit
test.

Closes #2663
2017-07-19 17:55:11 -07:00
Sam Leavens 9b8928edf4 ref(pkg/chartutil): replace use of 'fmt.Efforf'
'fmt.Errorf' is unnecessary when checking for 0 length path in Values.PathValue
due to the lack of formatting. Add test covering changes.
2017-07-19 15:53:12 -07:00
Scott Rigby 645f01eb22 New Helm functionality to delete a coalesced YAML key when the value is nil.
- 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.
2017-07-07 14:32:56 -04:00
Justin Scott 58c8aca1cc feat(helm): fixup if/ele,remove extra string casts, add comments 2017-02-11 12:56:43 -08:00
Justin Scott faae1f68b6 feat(helm): Check len of correct slice 2017-02-11 12:56:43 -08:00
Justin Scott 8ef733ca7d feat(helm): add conditions and tags
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
2017-02-11 12:56:43 -08:00
Matt Butcher cb0a6c7e07
feat(tiller): add {{.Capabilities}} object
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
2017-01-09 18:09:20 -07:00
Matt Butcher b3d812b346 Merge pull request #1692 from technosophos/fix/allow-global-map-merges
fix(tller): allow deep merge of global maps
2016-12-16 16:29:13 -07:00
Matt Butcher 6faf4675ac
fix(tller): allow deep merge of global maps
This reverts a previous decision to only do shallow merges of globals.
It allows globals to be nested maps.
2016-12-15 17:06:30 -07:00
Matt Butcher b2d762af48
feat(tiller): add .Release.IsInstall 2016-12-15 15:04:36 -07:00
Matt Butcher de7c5e5a38
feat(tiller): Add .Release.Revision and .IsUpgrade
New properties are available to template developers.

Closes #1554
2016-12-14 18:06:34 -07:00
Adam Reese e2ab407209 fix(tiller): return yaml parsing errors
closes: #1519
2016-11-14 14:30:33 -08:00
Matt Butcher 033dbfe75e feat(tiller): add Files map to templates
Templates can now access the non-template files in a chart by using
the '{{.Files}}' map inside of a template.

Relates to #950
2016-07-29 16:04:48 -06:00
Matt Butcher 95eeba3805 fix(tiller): merge -f values correctly
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 #971
Closes #920
2016-07-21 16:00:57 -06:00