New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing values of the subchart with dash in the name #2192

Closed
lwolf opened this Issue Mar 26, 2017 · 24 comments

Comments

Projects
None yet
@lwolf

lwolf commented Mar 26, 2017

Based on the docs, there is a convention to name charts with dashes.
But at the same time based on this doc, you should never have values with dashes.

So, let's say I have 2 dependent charts: gitlab and gitlab-runner.
How can I configure and access values for the subchart?

@thomastaylor312

This comment has been minimized.

Collaborator

thomastaylor312 commented Mar 28, 2017

This is a good question. I haven't had a problem doing this, but it is an inconsistency. @technosophos Should we change one of these to match the other?

@lwolf

This comment has been minimized.

lwolf commented Mar 28, 2017

I'm currently experiencing the problem accessing values for such subchart.

Next block gives me an error.

{{ if .Values.gitlab-runner.enabled }}

Error: UPGRADE FAILED: parse error in "gitlab/templates/deployment.yaml": template: gitlab/templates/deployment.yaml:217: bad character U+002D '-'

@technosophos technosophos added this to the 2.4.0 - Features milestone Apr 12, 2017

@technosophos technosophos self-assigned this Apr 12, 2017

@technosophos

This comment has been minimized.

Member

technosophos commented Apr 12, 2017

Use the index template function to access a value with a '-' in the name: {{ index .Values "gitlab-runner" }}.

And we should probably change the convention. That makes it a pain to deal with things like this. I assigned the issue to myself to go change the convention.

@lwolf

This comment has been minimized.

lwolf commented Apr 13, 2017

thanks, it works this way.

@technosophos

This comment has been minimized.

Member

technosophos commented Apr 13, 2017

@prydonius Do you remember the reason why we initially decided that charts should be named with dashes? I was looking through older documentation and this has been a precedent we set since the beginning. I am thinking that maybe it's not such a good idea to change it.

@omegarus

This comment has been minimized.

omegarus commented Jun 4, 2017

I'am trying to understand how index works.
How can i access servicename value from:

mysub-chart:
  servicename: mysubchart-service

?
Found solution: {{ index .Values "mysub-chart" "servicename" }}

@spearsem

This comment has been minimized.

spearsem commented Oct 13, 2017

How would you use dash names in a control structure, such as a with or range block?

{{- range $key, $value := .Values.my-service-name.deployment.annotations }}
@bacongobbler

This comment has been minimized.

Member

bacongobbler commented Oct 13, 2017

@spearsem I think the above comment has got the right workaround for that problem. I think this should work:

{{- range $key, $value := index .Values "my-service-name" "deployment" "annotations" }}

Otherwise I think you can instantiate a variable that points to the annotations and use that within the range or with blocks. For example

{{ $annotations := index .Values "my-service-name" "deployment" "annotations" }}
{{- range $key, $value := $annotations }}
@spearsem

This comment has been minimized.

spearsem commented Oct 13, 2017

@bacongobbler Does this also work for with? I am not familiar with the implementation of with to know if it can utilize the result of another function evaluation as "the context".

@bacongobbler

This comment has been minimized.

Member

bacongobbler commented Oct 13, 2017

text/template appears to say that it should work with any structure, so I would assume yes.

If the value of the pipeline is empty, no output is generated; otherwise, dot is set to the value of the pipeline and T1 is executed.

@josdotso

This comment has been minimized.

josdotso commented Oct 24, 2017

The variable method doesn't seem to work for me. . The error just happens a line later.

@sslavic

This comment has been minimized.

Contributor

sslavic commented Dec 17, 2017

Istio port naming convention also requires dashes (see Pod Spec Requirements).

@tetafro

This comment has been minimized.

tetafro commented Dec 25, 2017

Is there any workaround for setting vars in cli?

helm install --set one-two.three=10 releasename ./chartname
@sgandon

This comment has been minimized.

sgandon commented Feb 2, 2018

this is a real inconsistency and I have the problem too.
One solution is to use an alias in the requirements.yaml so that your subchart name is changed to something without the -, but this is indeed a pain.

@sirn

This comment has been minimized.

sirn commented Feb 2, 2018

I'm having this problem as well.

I think it would be nice if Helm will pass values from parent chart to subchart-name using camelcase-ify name instead, e.g. subchartName. It would make chart name convention and variables name convention to be compatible with each other, as well as side-stepping the syntax issues from above.

@svidrascu

This comment has been minimized.

svidrascu commented Feb 13, 2018

This does not work at all in templates, this example code:
{{ index .Values "first-key" "secondkey" }}
works in NOTES.txt but in _helpers.tpl when issuing an upgrade command:
_helpers.tpl:24:3: executing "test.template" at <index .Values "first-key...>: error calling index: index of untyped nil

Client: &version.Version{SemVer:"v2.6.2", GitCommit:"be3ae4ea91b2960be98c07e8f73754e67e87963c", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.7.0", GitCommit:"08c1144f5eb3e3b636d9775617287cc26e53dba4", GitTreeState:"clean"}

Same thing with both versions the same:
Client: &version.Version{SemVer:"v2.6.2", GitCommit:"be3ae4ea91b2960be98c07e8f73754e67e87963c", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.6.2", GitCommit:"be3ae4ea91b2960be98c07e8f73754e67e87963c", GitTreeState:"clean"}

kubectl is :
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.2", GitCommit:"5fa2db2bd46ac79e5e00a4e6ed24191080aa463b", GitTreeState:"clean", BuildDate:"2018-01-18T10:09:24Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.4", GitCommit:"9befc2b8928a9426501d3bf62f72849d5cbcd5a3", GitTreeState:"clean", BuildDate:"2017-11-20T05:17:43Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

@cristifalcas

This comment has been minimized.

cristifalcas commented Feb 19, 2018

@svidrascu , check that you have the values defined in the Chart.yaml file for that specific subchart. It looks like the templating engine can't find your variable

@fejta-bot

This comment has been minimized.

fejta-bot commented May 20, 2018

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@fejta-bot

This comment has been minimized.

fejta-bot commented Jun 19, 2018

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@bacongobbler

This comment has been minimized.

Member

bacongobbler commented Jul 25, 2018

closed via #4379

@bacongobbler

This comment has been minimized.

Member

bacongobbler commented Jul 30, 2018

FYI, an amendment to #4379 was done in #4400.

@ksemaev

This comment has been minimized.

ksemaev commented Aug 20, 2018

This is so rubbish - no dashes, no underscores, no capital letters. How should one define compicate chart name for two (or more) simular components? Changing one simple . to " " is just awful :(

@bacongobbler

This comment has been minimized.

Member

bacongobbler commented Aug 20, 2018

@ksemaev please see #4400. As mentioned previously, we still want users to use dashes in their package names, but they should be aware of the "gotchas" around certain limitations with the template system.

@bacongobbler

This comment has been minimized.

Member

bacongobbler commented Aug 20, 2018

Whoops, fat-fingered the close button 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment