-
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
add a secretref for webhook secrets #17314
add a secretref for webhook secrets #17314
Conversation
@openshift/api-review this is ready for api review. WIP refers to need for new tests. |
eb90080
to
b137af1
Compare
pkg/build/apis/build/types.go
Outdated
@@ -1054,11 +1054,16 @@ type BuildConfigStatus struct { | |||
// WebHookTrigger is a trigger that gets invoked using a webhook type of post | |||
type WebHookTrigger struct { | |||
// Secret used to validate requests. | |||
// Deprecated: use Secret instead. |
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 fixing this (should say SecretRef)
2e8cca6
to
4f57bd4
Compare
pkg/build/apis/build/types.go
Outdated
|
||
// SecretRef is a reference to a secret containing the value to be validated | ||
// when the webhook is invoked. Takes precedence over Secret. | ||
SecretRef *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.
Upstream we've started defining specific types for each kind of reference. The idea being that this isn't a generic reference, this is a reference to a secret and even more specifically, a reference to a particular kind of secret. Basically, every reference started looking a little different and chasing them all around is impractical.
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 defined a new type for the reference. I did not add (and don't plan to add?) a new type of secret.
@@ -607,8 +607,8 @@ func validateTrigger(trigger *buildapi.BuildTriggerPolicy, buildFrom *kapi.Objec | |||
|
|||
func validateWebHook(webHook *buildapi.WebHookTrigger, fldPath *field.Path, isGeneric bool) field.ErrorList { | |||
allErrs := field.ErrorList{} | |||
if len(webHook.Secret) == 0 { | |||
allErrs = append(allErrs, field.Required(fldPath.Child("secret"), "")) | |||
if len(webHook.Secret) == 0 && webHook.SecretRef == 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.
Are you planning to provide an oadm migrate
command to help people transition?
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.
return nil, err | ||
} | ||
for _, v := range s.Data { | ||
decoded, err := base64.StdEncoding.DecodeString(string(v)) |
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.
This is unexpected. You're storing base64 encoded bytes instead of the actual bytes?
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.
you might be looking at this PR by commit? this is changed in a later commit in the PR (though i see there's a log.info i inadvertently left in)
@deads2k reftype added and logic updated to only look for a specific key in the secret. |
ffad56a
to
50b53ea
Compare
I plan to come back and take another pass. But before I forget /hold API changes are being held until we make openshift/api authoritative post 1.8 rebase. |
0a29334
to
8b92e6a
Compare
/retest |
1 similar comment
/retest |
pkg/build/apis/build/types.go
Outdated
Secret string | ||
|
||
// AllowEnv determines whether the webhook can set environment variables; can only | ||
// be set to true for GenericWebHook | ||
AllowEnv bool | ||
|
||
// SecretRef is a reference to a secret containing the value to be validated |
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.
reference to a secret in the same namespace
if !hmac.Equal([]byte(trigger.GitLabWebHook.Secret), []byte(secret)) { | ||
continue | ||
} | ||
if secretRef != 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.
didn't the API comment say this took precedence?
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.
it does, but that comment should be removed. There's no concept of precedence, if you have both, we will accept a match on either one.
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.
it does, but that comment should be removed. There's no concept of precedence, if you have both, we will accept a match on either one.
Ok. Update the comment.
General thoughts:
This looks like a good starting point to me. |
8b92e6a
to
6590aa2
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bparees The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
@jwforres @benjaminapetersen fyi this is back on the merge queue now. |
/retest Please review the full test history for this PR and help us cut down flakes. |
2 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
5e13f2e
to
fb868db
Compare
fb868db
to
3771f2b
Compare
/retest Please review the full test history for this PR and help us cut down flakes. |
2 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest |
3771f2b
to
f98a624
Compare
/retest |
@bparees: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/retest |
Automatic merge from submit-queue. |
Automatic merge from submit-queue. Handle new build webhooks that use secretRefs instead of inline secrets Adding functionality to handle the new build webhooks that use secretRefs instead of inline secrets. Now when user will want to add webhook to build config he will have to choose from available secrets that contain the `WebHookSecretKey` key. Screen:  To be consistent with changes in CLI (introduced in openshift/origin#17314) I've updated the `webhookURL` so it will show webhook urls as: `https://localhost:9000/namespaces/myproject/buildconfigs/test-build/webhooks/<secret>/github` Wasn't really sure if part of this [card](https://trello.com/c/lo6HwQgu/1106-2-build-webhooks-with-secretrefs) is also update the create-secret page to be able to create secrets that user could add to the webhook in the BC editor. @spadgett PTAL
fixes bug https://bugzilla.redhat.com/show_bug.cgi?id=1504819
api changes are now here: openshift/api#10