Repository navigation
Lookup template function - #6752
Conversation
401c5e7 to
2583fd6
Compare
|
@raffaelespazzoli Thanks for taking this on! Please let us know if you have any questions or need any feedback. Also, just as an FYI, because this is a new feature, we will probably not get around to a full review until after 3.0 is released |
|
@thomastaylor312 if you could help with two things:
|
|
@raffaelespazzoli You should be able to rebase your branch off of master and it should take care of it. As for the command line flag, let me dig into it some more. I haven't touched the engine package in a while and there might be an easier way |
|
Ok, so after digging around in the dynamic client docs I'm thinking the best way around this is to add a new top level Render method (probably something like Any way you do it, I would recommend against trying to regenerate the config separately like you are doing it currently |
03e498e to
acbda61
Compare
|
@thomastaylor312 I fixed the rebase issue, thanks for the suggestion. I also took a look at how the kube client config is generated/managed. |
|
The |
|
@thomastaylor312 you say I can pass the |
a5109ca to
d36f67b
Compare
|
@thomastaylor312 re-based and added the fix about getting the rest client from the action configuration. |
thomastaylor312
left a comment
There was a problem hiding this comment.
Hey @raffaelespazzoli! Finally back from vacation and looking through this again. This looks really concise and straightforward. I have a handful of requested changes and a few nits (that I'll leave up to you to decide if you want to fix). I'll start pinging some of the other maintainers to take a look at this. Although I don't see any problems security-wise as I look at this now, I want to make sure that we've made sure we understand any security implications of adding this feature
| if c.RESTClientGetter != nil { | ||
| rest, err := c.RESTClientGetter.ToRESTConfig() | ||
| if err != nil { | ||
| files, err2 = engine.Render(ch, values) |
There was a problem hiding this comment.
Shouldn't this just return the error? If the RESTClientGetter is not nil, then this shouldn't be failing
There was a problem hiding this comment.
I was trying to maintain the previous behavior as much as possible. I don't have a specific opinion either way, so let me know how you prefer to handle this. It's been a while but some of the unit tests run without the client initialized. I don't remember exactly in which of the ifs they were failing.
There was a problem hiding this comment.
I think it would be best to return an error if ToRESTConfig errors. It shouldn't cause any failures with unit tests because most of them don't have RESTClientGetter set. If it does cause failures, let's review the list of those failures and see what the best solution would be
There was a problem hiding this comment.
changed to return an error
b4540ce to
50f638e
Compare
|
How will these values be rendered on |
|
@jdolitsky I'm working with @raffaelespazzoli a bit on this, doing some use case testing. Currently I personally don't see any issue with that as its reasonable to expect a running cluster if you are going to use the lookup function. |
|
@etsauer Helm template should run successfully without needing a connection to a Kubernetes, otherwise it would be a backwards incompatible change. If |
|
@jdolitsky @etsauer @thomastaylor312 in the current implementation there is some logic (see the pkg/action/install.go file) to decide whether to inject or no the lookup function. The lookup function is injected if the restclient is initialized. |
Signed-off-by: raffaelespazzoli <[email protected]>
Signed-off-by: raffaelespazzoli <[email protected]>
Signed-off-by: raffaelespazzoli <[email protected]>
Signed-off-by: raffaelespazzoli <[email protected]>
Signed-off-by: raffaelespazzoli <[email protected]>
Signed-off-by: raffaelespazzoli <[email protected]>
Signed-off-by: raffaelespazzoli <[email protected]>
Signed-off-by: raffaelespazzoli <[email protected]>
50f638e to
a62ba04
Compare
|
@thomastaylor312 all you comment should be addressed |
Signed-off-by: raffaelespazzoli <[email protected]>
|
@thomastaylor312 ping... |
1 similar comment
|
@thomastaylor312 ping... |
|
@raffaelespazzoli Sorry. All back from the holidays and finally digging myself out of the last of the backlog. Re-reviewing now and bringing it back up in the dev call this week |
thomastaylor312
left a comment
There was a problem hiding this comment.
This is looking good. Holding off on final approval until we can talk about what the behavior should be with helm template in the dev call
|
I am the one who rejected a similar proposal a few years ago. I am in favor of going forward with this PR. But I will call out one of the reasons I rejected a similar proposal in 2016: One of the ideas behind This feature will definitely put rollbacks at risk. But my feeling is that over time we now have a lot of external dependencies anyway. (CRDs are an example) So I think that while we should be aware of this and educate users about this, we should go ahead with this PR. |
thomastaylor312
left a comment
There was a problem hiding this comment.
Also approving as is. After a good discussion in the dev call, we were in agreement that your logic is correct. If there are lookups in a chart, it should fail if used with helm template (without the --validate flag). So this LGTM. We will need a follow up doc PR in the docs repo to document all the things here
|
@raffaelespazzoli If you are feeling good with merging this, please remove the "WIP" and we'll go ahead and merge |
|
@thomastaylor312 WIP removed, please merge. |
|
Just in case anyone else is wondering... the original proposed example only works for When using a
|
|
is this working in a post-install,post-upgrade method ? if i don't do the if i get if i just do i get the value map[] which means it's empty so I4m wondering if the lookup is not immediately done instead if being done as part of the post hook thanks |
|
I wanted to do the same thing as huineng however it appears the |
I created a lookup template function to address #949 .
The lookup up function takes for string parameters:
and returns a
map[string]interface{}if namespace is missing the lookup function assumes we are looking up a cluster resource.
if name is missing the lookup function assumes we are looking up an list of resources.
for example the expression to lookup the value of a loadbalancer service would be:
{{ (index (lookup "v1" "Service" "mynamespace" "myservice").status.loadBalancer.ingress 0).ip }}The way the lookup function works is the following:
This is a work in progress and I being a new contributor request some assistance (and patience) while I comply with all the rules.