Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/hiveadmission/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
admissionCmd "github.com/openshift/generic-admission-server/pkg/cmd"
log "github.com/sirupsen/logrus"

admissionv1 "k8s.io/api/admission/v1"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

"github.com/openshift/hive/pkg/util/scheme"
Expand Down Expand Up @@ -36,5 +37,7 @@ func main() {
func createDecoder() admission.Decoder {
scheme := scheme.GetScheme()
decoder := admission.NewDecoder(scheme)
// HACK: Prevent pruning of admissionv1, resulting in conversion errors
var _ admissionv1.AdmissionReview = admissionv1.AdmissionReview{}
return decoder
}
1 change: 1 addition & 0 deletions config/hiveadmission/clusterdeployment-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
webhooks:
- name: clusterdeploymentvalidators.admission.hive.openshift.io
admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
Expand Down
1 change: 1 addition & 0 deletions config/hiveadmission/clusterimageset-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
webhooks:
- name: clusterimagesetvalidators.admission.hive.openshift.io
admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
Expand Down
29 changes: 29 additions & 0 deletions config/hiveadmission/clusterpool-webhook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: clusterpoolvalidators.admission.hive.openshift.io
webhooks:
- name: clusterpoolvalidators.admission.hive.openshift.io
admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
# reach the webhook via the registered aggregated API
namespace: default
name: kubernetes
path: /apis/admission.hive.openshift.io/v1/clusterpoolvalidators
rules:
- operations:
- CREATE
- UPDATE
- DELETE
apiGroups:
- hive.openshift.io
apiVersions:
- v1
resources:
- clusterpools
failurePolicy: Fail
sideEffects: None
1 change: 1 addition & 0 deletions config/hiveadmission/clusterprovision-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
webhooks:
- name: clusterprovisionvalidators.admission.hive.openshift.io
admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
Expand Down
1 change: 1 addition & 0 deletions config/hiveadmission/dnszones-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ metadata:
webhooks:
- name: dnszonevalidators.admission.hive.openshift.io
admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
Expand Down
1 change: 1 addition & 0 deletions config/hiveadmission/machinepool-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
webhooks:
- name: machinepoolvalidators.admission.hive.openshift.io
admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
Expand Down
1 change: 1 addition & 0 deletions config/hiveadmission/selectorsyncset-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
webhooks:
- name: selectorsyncsetvalidators.admission.hive.openshift.io
admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
Expand Down
1 change: 1 addition & 0 deletions config/hiveadmission/syncset-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
webhooks:
- name: syncsetvalidators.admission.hive.openshift.io
admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
Expand Down
56 changes: 56 additions & 0 deletions pkg/operator/assets/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/operator/hive/hiveadmission.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const (
var webhookAssets = []string{
"config/hiveadmission/clusterdeployment-webhook.yaml",
"config/hiveadmission/clusterimageset-webhook.yaml",
"config/hiveadmission/clusterpool-webhook.yaml",
"config/hiveadmission/clusterprovision-webhook.yaml",
"config/hiveadmission/dnszones-webhook.yaml",
"config/hiveadmission/machinepool-webhook.yaml",
Expand Down
2 changes: 2 additions & 0 deletions pkg/util/scheme/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
autoscalingv1beta1 "github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1beta1"
"github.com/openshift/hive/apis"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
admissionv1 "k8s.io/api/admission/v1"
admissionv1beta1 "k8s.io/api/admission/v1beta1"
rbacv1 "k8s.io/api/rbac/v1"
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
Expand All @@ -43,6 +44,7 @@ var hive_scheme *runtime.Scheme
func init() {
hive_scheme = runtime.NewScheme()
admissionregistrationv1.AddToScheme(hive_scheme)
admissionv1.AddToScheme(hive_scheme)
admissionv1beta1.AddToScheme(hive_scheme)
apis.AddToScheme(hive_scheme)
apiextv1.AddToScheme(hive_scheme)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/postdeploy/admission/admission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
"time"

admissionv1beta1 "k8s.io/api/admission/v1beta1"
admissionv1 "k8s.io/api/admission/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

Expand Down Expand Up @@ -90,7 +90,7 @@ func TestAdmission(t *testing.T) {
if err != nil {
t.Fatalf("Unexpected create error: %v", err)
}
reviewResult := &admissionv1beta1.AdmissionReview{}
reviewResult := &admissionv1.AdmissionReview{}
scheme := scheme.GetScheme()
err = scheme.Convert(result, reviewResult, nil)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apiVersion": "admission.k8s.io/v1beta1",
"apiVersion": "admission.k8s.io/v1",
"kind": "AdmissionReview",
"request": {
"kind": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apiVersion": "admission.k8s.io/v1beta1",
"apiVersion": "admission.k8s.io/v1",
"kind": "AdmissionReview",
"request": {
"kind": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apiVersion": "admission.k8s.io/v1beta1",
"apiVersion": "admission.k8s.io/v1",
"kind": "AdmissionReview",
"request": {
"kind": {
Expand Down