-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
make templateinstance secret optional #14848
Conversation
8d0a629
to
753bbcc
Compare
[test] |
[testextended][extended:core(templates)] |
@jim-minter ptal i debated doing the same w/ brokertemplateinstance but there were more changes involved and it seemed more reasonable to assume there would be parameters always coming on a provision call, so for now at least i left that alone. |
7e9884e
to
8439ca8
Compare
@@ -61,7 +61,7 @@ func ValidateTemplateInstance(templateInstance *api.TemplateInstance) (allErrs f | |||
err.Field = "spec.template." + err.Field | |||
allErrs = append(allErrs, err) | |||
} | |||
if templateInstance.Spec.Secret.Name != "" { | |||
if templateInstance.Spec.Secret != nil && templateInstance.Spec.Secret.Name != "" { |
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.
think you need to return a field.Required if Spec.Secret != nil && Spec.Secret.Name == ""
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.
oh wow, this logic was completely broken before, I'm glad you submitted this PR
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.
will update, please check my work.
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 think I was thinking:
if templateInstance.Spec.Secret != nil {
if templateInstance.Spec.Secret.Name == "" {
allErrs = append(allErrs, field.Required(field.NewPath("spec.secret.name"), ""))
} else {
for _, msg := range oapi.GetNameValidationFunc(validation.ValidateSecretName)(templateInstance.Spec.Secret.Name, false) {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec.secret.name"), templateInstance.Spec.Secret.Name, msg))
}
}
}
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.
please ignore comment above, was looking at old version of the PR - all fine
@@ -367,7 +367,7 @@ func TestValidateTemplateInstanceUpdate(t *testing.T) { | |||
}, | |||
}, | |||
}, | |||
Secret: kapi.LocalObjectReference{ | |||
Secret: &kapi.LocalObjectReference{ |
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.
might as well add one more TC that proves validation passes when Secret is nil
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 could have sworn i did, not sure what happened to it. will add it again :)
secret, err := c.kc.Core().Secrets(templateInstance.Namespace).Get(templateInstance.Spec.Secret.Name, metav1.GetOptions{}) | ||
if err != nil { | ||
return err | ||
s, err := c.kc.Core().Secrets(templateInstance.Namespace).Get(templateInstance.Spec.Secret.Name, metav1.GetOptions{}) |
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.
just condenses down to secret, err = c.kc...?
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.
no, because that shadows the secret var defined above (which must be defined above because it needs to exist outside this scope). and i can't use "=" because err is actually a new variable.
unless i'm missing a trick, this is the joys of golang combining implicit variable declaration, multivariable returns, and zero shadowing protection.
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.
oh, ok - missed that the err := above was in an if scope.
Bar nits looks good, many thanks!
Agreed. Can I ask one more favour as part of this PR - can you remove lines 70-78 of templateinstance_impersonation.go ( |
@jim-minter comments addressed in new commit, other than the shadowing bit. if i've missed a trick there, let me know. |
Status: kapi.ConditionTrue, | ||
}, | ||
}, | ||
}, |
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.
@jim-minter please confirm this is the bit you wanted removed.
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.
yes, thanks
lgtm, thanks! |
@openshift/api-review can we get a quick sign off on this (changing secretref field to a pointer to make it optional) |
approved |
[merge] |
re[test] |
873d3c1
to
6a8081d
Compare
Evaluated for origin test up to 073e82c |
Evaluated for origin testextended up to 073e82c |
continuous-integration/openshift-jenkins/testextended SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_extended/755/) (Base Commit: 247631a) (PR Branch Commit: 073e82c) (Extended Tests: core(templates)) |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/2675/) (Base Commit: 247631a) (PR Branch Commit: 073e82c) |
[merge] |
[merge]
Ben Parees | OpenShift
…On Jun 29, 2017 03:23, "OpenShift Bot" ***@***.***> wrote:
continuous-integration/openshift-jenkins/merge FAILURE (
https://ci.openshift.redhat.com/jenkins/job/merge_pull_
request_origin/1170/) (Base Commit: 327a76d
<327a76d>)
(PR Branch Commit: 073e82c
<073e82c>
)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#14848 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEvl3sNV_PZnR53VHb6u0BHmkvCwGl1vks5sI1D3gaJpZM4ODEF8>
.
|
Evaluated for origin merge up to 073e82c |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/1174/) (Base Commit: 73cdfc3) (PR Branch Commit: 073e82c) (Image: devenv-rhel7_6411) |
fixes #14837