Skip to content

Commit

Permalink
Revert "Remove webhook validation."
Browse files Browse the repository at this point in the history
This reverts commit f82975d.
  • Loading branch information
Jayendra Parsai committed Oct 18, 2023
1 parent f82975d commit bff1d1c
Show file tree
Hide file tree
Showing 5 changed files with 772 additions and 3 deletions.
89 changes: 89 additions & 0 deletions appstudio-controller/config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
creationTimestamp: null
name: validating-webhook-configuration
annotations:
service.beta.openshift.io/inject-cabundle: "true"
webhooks:
- admissionReviewVersions:
- v1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-appstudio-redhat-com-v1alpha1-snapshot
failurePolicy: Fail
name: vsnapshot.kb.io
rules:
- apiGroups:
- appstudio.redhat.com
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- snapshots
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-appstudio-redhat-com-v1alpha1-snapshotenvironmentbinding
failurePolicy: Fail
name: vsnapshotenvironmentbinding.kb.io
rules:
- apiGroups:
- appstudio.redhat.com
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- snapshotenvironmentbindings
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-appstudio-redhat-com-v1alpha1-promotionrun
failurePolicy: Fail
name: vpromotionrun.kb.io
rules:
- apiGroups:
- appstudio.redhat.com
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- promotionruns
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-appstudio-redhat-com-v1alpha1-environment
failurePolicy: Fail
name: venvironment.kb.io
rules:
- apiGroups:
- appstudio.redhat.com
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- environments
sideEffects: None
1 change: 0 additions & 1 deletion appstudio-controller/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ require (
)

replace (
github.com/redhat-appstudio/application-api => github.com/jparsai/application-api v0.0.0-20231018111833-7ae6ab0aa2fe
github.com/redhat-appstudio/managed-gitops/backend => ../backend
github.com/redhat-appstudio/managed-gitops/backend-shared => ../backend-shared
github.com/redhat-appstudio/managed-gitops/utilities/db-migration => ../utilities/db-migration
Expand Down
4 changes: 2 additions & 2 deletions appstudio-controller/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/jparsai/application-api v0.0.0-20231018111833-7ae6ab0aa2fe h1:6zjX2yj3k5QAOlkKfqgigyDGYiDIp8tK6xd/OUicbNY=
github.com/jparsai/application-api v0.0.0-20231018111833-7ae6ab0aa2fe/go.mod h1:OvmeiVOItG2OSX/QE+vQwzOYfbOMBhBy43ZFxkWZJyc=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
Expand Down Expand Up @@ -345,6 +343,8 @@ github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
github.com/redhat-appstudio/application-api v0.0.0-20230906075853-8d1126322971 h1:5fZaG1iVebcLWeJsVpWxSNmd0qhH1x9rLXWP+jVOSZo=
github.com/redhat-appstudio/application-api v0.0.0-20230906075853-8d1126322971/go.mod h1:E277KEEjL6rEXUHIhc0FQd6jyf3CzCQ7MOkauqF3gt4=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
Expand Down
26 changes: 26 additions & 0 deletions appstudio-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"flag"
"os"
"strings"

codereadytoolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
"go.uber.org/zap"
Expand Down Expand Up @@ -147,6 +148,31 @@ func main() {
os.Exit(1)
}

// If the webhook is not disabled, start listening on the webhook URL
if !strings.EqualFold(os.Getenv("DISABLE_APPSTUDIO_WEBHOOK"), "true") {

setupLog.Info("setting up webhooks")
if err = (&applicationv1alpha1.Snapshot{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Snapshot")
os.Exit(1)
}

if err = (&applicationv1alpha1.SnapshotEnvironmentBinding{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "SnapshotEnvironmentBinding")
os.Exit(1)
}

if err = (&applicationv1alpha1.PromotionRun{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "PromotionRun")
os.Exit(1)
}

if err = (&applicationv1alpha1.Environment{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Environment")
os.Exit(1)
}
}

if err = (&appstudioredhatcomcontrollers.DeploymentTargetClaimReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Expand Down
Loading

0 comments on commit bff1d1c

Please sign in to comment.