Joe Julian
ec1d0d8671
Merge pull request #11456 from greed42/tpl-tests
...
Backfill tests for the `tpl` function
2023-07-12 17:21:07 -07:00
Graham Reed
f235f0f285
Check that missing keys are still handled in tpl
...
Signed-off-by: Graham Reed <greed@7deadly.org>
2023-05-11 22:16:30 +01:00
Matt Farina
863bc74e5a
Update to func handling
...
Signed-off-by: Matt Farina <matt@mattfarina.com>
2023-02-03 15:36:32 -05:00
Graham Reed
9fe912f3c5
Check redefinition of define and include in tpl
...
Signed-off-by: Graham Reed <greed@7deadly.org>
2022-10-20 16:25:36 +01:00
Graham Reed
ebf5e1e2af
Check that `.Template` is passed through `tpl`
...
Signed-off-by: Graham Reed <greed@7deadly.org>
2022-10-20 16:25:36 +01:00
Graham Reed
0a6e7d95ab
Make sure empty `tpl` values render empty.
...
Signed-off-by: Graham Reed <greed@7deadly.org>
2022-10-20 16:25:36 +01:00
Graham Reed
d1e9a242a7
Pick the test improvement out of PR#8371
...
<https://github.com/helm/helm/pull/8371 >
This covers:
- `tpl` text can `include` a `define` provided in a partial file
- `tpl` text can `include` a `define` provided in its text
- `tpl` text can be loaded via `.Files.Get`
Signed-off-by: Graham Reed <greed@7deadly.org>
2022-10-20 16:25:09 +01:00
Matt Farina
ac80a5eec9
Merge branch 'main' into feat/subcharts-scope
2021-08-25 10:18:31 -04:00
Matt Farina
2de6f9d424
Merge pull request #9993 from Ka0o0/make-isroot-available-to-template
...
Make Chart's IsRoot available to templates
2021-08-25 10:14:05 -04:00
Kai Takac
8fcaf7b85c
Add Chart IsRoot test
...
Signed-off-by: Kai Takac <kai.takac@gmail.com>
2021-08-23 20:10:37 +02:00
Cory Snider
79df3926f6
fix(engine): parse fail messages with newlines
...
The templating engine handles errors originating from the `required` and
`fail` template functions specially, cleaning up the error messages to
be more presentable to users. Go's text/template package unfortunately
does not make this straightforward to implement. Despite
template.ExecError implementing Unwrap, the error value returned from
the template function cannot be retrieved using errors.As. The wrapped
error in ExecError is a pre-formatted error string with the template
function's error string interpolated in with the original error value
erased. Helm works around this limitation by delimiting the
template-supplied message and extracting the message out of the
ExecError string with a regex.
Fix the parsing of `required` and `fail` error messages containing
newlines by setting the regex flag to make `.` match newline characters.
Signed-off-by: Cory Snider <csnider@mirantis.com>
2021-08-10 12:38:43 -04:00
Valentin Flaux
3daaea0a1c
feat(pkg/engine): expose subcharts scope in parent
...
Expose the scope (.Values, .Charts, .Releases etc.) of subcharts to the parent scope.
Signed-off-by: Valentin Flaux <vflaux@oui.sncf>
2021-07-20 12:24:27 +02:00
Martin Hickey
dffc2a30c7
Merge pull request #9035 from wizbit/fail-message
...
Fail message is now the same as the required message.
2021-06-02 12:26:39 +01:00
Josh Soref
2bf8fdf45d
chore: Spelling ( #9410 )
...
* spelling: annotate
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: asserts
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: behavior
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: binary
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: contain
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: copied
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: dependency
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: depending
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: deprecated
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: doesn't
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: donot
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: github
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: inputting
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: iteration
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: jabberwocky
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: kubernetes
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: length
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: mismatch
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: multiple
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: nonexistent
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: outputs
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: panicking
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: plugins
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: parsing
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: porthos
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: regular
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: resource
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: repositories
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: something
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: strict
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: string
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
* spelling: unknown
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2021-03-15 21:11:57 -04:00
Marcus Speight
7a663a56c2
Fixed Test
...
Signed-off-by: Marcus Speight <marcus.speight@hotmail.co.uk>
Signed-off-by: Marcus Speight <marcus@pmconnect.co.uk>
2020-12-07 14:58:40 +00:00
Marcus Speight
8aa42824f9
Added test for lint mode
...
Signed-off-by: Marcus Speight <marcus.speight@hotmail.co.uk>
2020-12-02 18:24:00 +00:00
Marcus Speight
7a0739a863
Fail message is now the same as the required message.
...
Fixed #8973 Helm function 'fail' should not fail when doing 'helm lint'
Signed-off-by: Marcus Speight <marcus.speight@hotmail.co.uk>
2020-11-19 08:10:38 +00:00
Matt Butcher
bb47286f09
fix linting error with lookup function ( #7969 )
...
Signed-off-by: Matt Butcher <matt.butcher@microsoft.com>
2020-04-22 10:09:34 -06:00
Andre Sencioles
d0726e07ab
Parse reference templates in predictable order ( #7702 )
...
* Parse reference templates in predictable order
Fix issue #7701
Signed-off-by: Andre Sencioles <asenci@gmail.com>
* Add test case for issue #7701 regression
Signed-off-by: Andre Sencioles <asenci@gmail.com>
* gofmt
Signed-off-by: Andre Sencioles <asenci@gmail.com>
2020-04-21 13:16:55 -06:00
Daniel Cheng
206d4a9053
add test for template recursion
...
Signed-off-by: Daniel Cheng <dcheng@us.ibm.com>
2020-02-10 12:25:41 -05:00
海的澜色
750b870aed
fix stack overflow error ( #7114 )
...
* fixed #7111
Signed-off-by: zwwhdls <zwwhdls@hotmail.com>
* update error message
Signed-off-by: zwwhdls <zwwhdls@hotmail.com>
* add test case
Signed-off-by: zwwhdls <zwwhdls@hotmail.com>
* fix lint error
Signed-off-by: zwwhdls <zwwhdls@hotmail.com>
2019-12-02 14:57:51 +00: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
Ian Howell
31b940a61d
fix(engine): Fix eating too many colons during template execution
...
This fixes #6044 , in which error parsing is greedily eating too many
colons, preventing users from using colons in their warning messages to
the `required` function
Signed-off-by: Ian Howell <ian.howell0@gmail.com>
2019-07-23 11:33:03 -05:00
Thomas O'Donnell
213f714604
Stop Lint from breaking when using required
...
Have updated the required filter so that it doesn't break when linting a
chart. This work is based off #4221 and #4748 which didn't make it into
the v3 branch.
Signed-off-by: Thomas O'Donnell <andy.tom@gmail.com>
2019-06-13 20:32:37 +02:00
Ian Howell
278594fb0f
fix(pkg/engine): Style changes on template errors
...
Signed-off-by: Ian Howell <ian.howell0@gmail.com>
2019-04-09 12:34:13 -05:00
Ian Howell
33b1ede570
fix(pkg/engine): Clean up template error messages
...
Signed-off-by: Ian Howell <ian.howell0@gmail.com>
2019-04-08 16:48:21 -05: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
Adam Reese
d841a1b1d9
fix(engine): make template rendering thread safe
...
See https://github.com/helm/helm/pull/4828
Signed-off-by: Adam Reese <adam@reese.io>
2019-03-05 12:56:39 -08: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
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
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
6345f04190
ref(hapi): convert protobuf to go types
2018-04-18 14:53:38 -07:00
Lukas Eichler
8bc7dede18
fix(helm): Apply PR comments for tpl template name fix
...
Modified existing unit test to verify the changed behavior.
Removed debug print.
2017-12-03 17:39:51 +01:00
Lukas Eichler
39db9ec6e8
Merge branch 'master' into master
2017-06-08 18:40:34 +02:00
Lukas Eichler
439f1b31d1
Added unit test for include in tpl function
2017-05-28 10:55:15 +02:00
Matt Butcher
8937c775a9
fix(2452): sort templates before parse
...
This sorts templates by depth before sending them to the template
parser. Deepest templates are parsed first, with umbrella templates
parsed last. Since template definition names are LIFO, that means that
the highest level templates will claim the namespace.
Or, to put it simply, you can predictably override a child's defined
template by re-defining it in a parent chart.
Closes #2452
2017-05-26 18:01:49 -06:00
Lukas Eichler
2521c526d9
- Changed error behaviour to returning an error instead of writing the error in the template
...
- Added tests for using a function inside a template that is evaluated using the "tpl" function
2017-05-02 09:44:26 +02:00
Lukas Eichler
d01f7978d2
Added implementation for a tpl function that evaluates a string as a template.
...
Implementation for #1978
2017-05-02 09:44:26 +02:00
Steve Wilkerson
79a3db0a63
feat(helm): add support for required properties
...
Adds the `required` function in enginge.go to support required
properties in values.yml. When a chart developer wishes to specify
intent in requiring a value, they can use this function to declare
an error message that gets returned when chart rendering fails
when a required value is not present in values.yml.
Closes #1580
2017-03-08 12:49:23 -06:00
Jack Zampolin
fc60d51be9
Add toToml function
2017-03-01 10:19:21 -08:00
Matt Butcher
d8540d78f1
feat(tiller): add fromYaml to template functions
...
This adds a fromYaml template function.
Closes #1604
2016-12-14 16:47:25 -07:00
Andrew Stuart
9771973888
Add AsSecrets, AsConfig methods for Files object. Move ToYaml to chartutil
2016-12-09 12:53:53 -07:00
Adnan Abdulhussein
f97dbe33da
fix(tests): prefix template names with "templates/"
2016-10-21 16:12:41 -07:00
Matt Butcher
36f7eb0b2a
fix(linter): add engine.FuncMap so linter can use real function list
...
This adds a function engine.FuncMap that returns a function mapping that
better represents the functions passed to a template. The linting logic
is reconfigured to use this function instead of the sprig.FuncMap
function.
Closes #1366
2016-10-14 16:28:43 -06:00
Matt Butcher
431cc46cad
feat(tiller): add toYaml template function
...
This adds the function toYaml to the Engine template functions.
Closes #1225
2016-09-26 14:33:54 -06:00
joe2far
72e7b22999
minor engine unit test fix
2016-08-30 17:13:34 +01:00