-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add webhookconfiguration options to tektonConfig additional options
- Loading branch information
Showing
14 changed files
with
348 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
pkg/apis/operator/v1alpha1/additional_options_validation.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright 2024 The Tekton Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"k8s.io/apimachinery/pkg/util/sets" | ||
"knative.dev/pkg/apis" | ||
) | ||
|
||
var ( | ||
validatePipelineWebhookConfigurationFailurePolicy = sets.NewString("Ignore", "Fail") | ||
validatePipelineWebhookConfigurationSideEffects = sets.NewString("NoneOnDryRun", "None", "Unknown", "Some") | ||
) | ||
|
||
func (w *WebhookConfigurationOptions) validate(path string) (errs *apis.FieldError) { | ||
if w.FailurePolicy != nil && !validatePipelineWebhookConfigurationFailurePolicy.Has(string(*w.FailurePolicy)) { | ||
errs = errs.Also(apis.ErrInvalidValue(*w.FailurePolicy, fmt.Sprintf("%s.webhookconfigurationoptions.failurePolicy", path))) | ||
} | ||
if w.SideEffects != nil && !validatePipelineWebhookConfigurationSideEffects.Has(string(*w.SideEffects)) { | ||
errs = errs.Also(apis.ErrInvalidValue(*w.SideEffects, fmt.Sprintf("%s.webhookconfigurationoptions.sideEffects", path))) | ||
} | ||
return errs | ||
} | ||
|
||
func (op *AdditionalOptions) validate(path string) (errs *apis.FieldError) { | ||
if op.WebhookConfigurationOptions != nil { | ||
for _, webhookConfig := range op.WebhookConfigurationOptions { | ||
return webhookConfig.validate(path) | ||
} | ||
} | ||
return errs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
pkg/reconciler/common/testdata/test-additional-options-base-webhook.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
apiVersion: admissionregistration.k8s.io/v1 | ||
kind: ValidatingWebhookConfiguration | ||
metadata: | ||
name: validation.webhook.pipeline.tekton.dev | ||
labels: | ||
app.kubernetes.io/component: webhook | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipelines | ||
pipeline.tekton.dev/release: "v0.58.0" | ||
webhooks: | ||
- admissionReviewVersions: ["v1"] | ||
clientConfig: | ||
service: | ||
name: tekton-pipelines-webhook | ||
namespace: tekton-pipelines | ||
failurePolicy: Fail | ||
sideEffects: None | ||
name: validation.webhook.pipeline.tekton.dev | ||
|
||
--- | ||
apiVersion: admissionregistration.k8s.io/v1 | ||
kind: MutatingWebhookConfiguration | ||
metadata: | ||
name: webhook.pipeline.tekton.dev | ||
labels: | ||
app.kubernetes.io/component: webhook | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipelines | ||
pipeline.tekton.dev/release: "v0.58.0" | ||
webhooks: | ||
- admissionReviewVersions: ["v1"] | ||
clientConfig: | ||
service: | ||
name: tekton-pipelines-webhook | ||
namespace: tekton-pipelines | ||
failurePolicy: Fail | ||
sideEffects: None | ||
name: webhook.pipeline.tekton.dev |
43 changes: 43 additions & 0 deletions
43
pkg/reconciler/common/testdata/test-additional-options-test-webhook.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
apiVersion: admissionregistration.k8s.io/v1 | ||
kind: ValidatingWebhookConfiguration | ||
metadata: | ||
creationTimestamp: null | ||
name: validation.webhook.pipeline.tekton.dev | ||
labels: | ||
app.kubernetes.io/component: webhook | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipelines | ||
pipeline.tekton.dev/release: "v0.58.0" | ||
webhooks: | ||
- admissionReviewVersions: ["v1"] | ||
clientConfig: | ||
service: | ||
name: tekton-pipelines-webhook | ||
namespace: tekton-pipelines | ||
failurePolicy: Ignore | ||
timeoutSeconds: 10 | ||
sideEffects: Unknown | ||
name: validation.webhook.pipeline.tekton.dev | ||
|
||
--- | ||
apiVersion: admissionregistration.k8s.io/v1 | ||
kind: MutatingWebhookConfiguration | ||
metadata: | ||
creationTimestamp: null | ||
name: webhook.pipeline.tekton.dev | ||
labels: | ||
app.kubernetes.io/component: webhook | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipelines | ||
pipeline.tekton.dev/release: "v0.58.0" | ||
webhooks: | ||
- admissionReviewVersions: ["v1"] | ||
clientConfig: | ||
service: | ||
name: tekton-pipelines-webhook | ||
namespace: tekton-pipelines | ||
failurePolicy: Fail | ||
timeoutSeconds: 10 | ||
sideEffects: None | ||
name: webhook.pipeline.tekton.dev |
Oops, something went wrong.