-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Allow env to be updated via specific key in resource #60040
Conversation
/ok-to-test |
ee1734f
to
0a38254
Compare
0a38254
to
71f477f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also missing a test case for the new functionality.
pkg/kubectl/cmd/set/set_env.go
Outdated
if o.List && len(o.Output) > 0 { | ||
return cmdutil.UsageErrorf(o.Cmd, "--list and --output may not be specified together") | ||
} | ||
|
||
if len(o.Keys) > 0 && len(o.From) < 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len(o.From) == 0
is the preferred approach.
pkg/kubectl/cmd/set/set_env.go
Outdated
@@ -278,7 +293,15 @@ func (o *EnvOptions) RunEnv(f cmdutil.Factory) error { | |||
}, | |||
}, | |||
} | |||
env = append(env, envVar) | |||
if len(o.Keys) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make a helper out of it, instead of copy&pasting it for secret here and config map below.
71f477f
to
2a5a40b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/retest |
2a5a40b
to
de5f330
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/assign @deads2k |
de5f330
to
9a7bf3b
Compare
9a7bf3b
to
8dfe21d
Compare
pkg/kubectl/cmd/set/set_env.go
Outdated
if len(o.Filenames) == 0 && len(resources) < 1 { | ||
return cmdutil.UsageErrorf(cmd, "one or more resources must be specified as <resource> <name> or <resource>/<name>") | ||
func (o *EnvOptions) addEnvVarToList(key string, env []v1.EnvVar, envVar v1.EnvVar) []v1.EnvVar { | ||
if len(o.Keys) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems weird to have the skip here. Why not skip down in the method iterating over keys? This feels like a function that sometimes disobeys me.
A contains(needle string, haystack []string)
could hold this logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally had the code where we iterate over the keys, but was asked to move it to a helper since it was repeated for both configmap and secret
8dfe21d
to
905a069
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, PhilipGough, soltysh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
The following test case can easily flakes, I am not clear about neither the root cause nor if this PR breaks it. Just FYI.
|
@m1093782566 thanks will take a look asap |
I just hit this locally. Seems consistent for me. |
opened #60302 |
The fix is in #60303 |
What this PR does / why we need it:
This change allows users of the
oc
client to specify a list of comma-separated keys when runningoc set env
which should be imported from a resource i.e configmap or secretThis can be useful when a number of applications want to share a configuration object but don't want to pollute a resource with unused environment
Release note: