Skip to content

Commit

Permalink
fixed validation for vmrule + updated operator-sdk project format
Browse files Browse the repository at this point in the history
  • Loading branch information
Amper committed Aug 23, 2023
1 parent 23a4dcc commit 5a857d5
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 15 deletions.
86 changes: 71 additions & 15 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,104 @@ layout: go.kubebuilder.io/v2
projectName: victoriametrics-operator
repo: github.com/VictoriaMetrics/operator
resources:
- group: operator
-
controller: true
domain: victoriametrics.com
group: operator
kind: VMAgent
path: github.com/VictoriaMetrics/operator/api/v1beta1
version: v1beta1
- group: operator
-
controller: true
domain: victoriametrics.com
group: operator
kind: VMAlert
path: github.com/VictoriaMetrics/operator/api/v1beta1
version: v1beta1
- group: operator
-
controller: true
domain: victoriametrics.com
group: operator
kind: VMAlertmanager
path: github.com/VictoriaMetrics/operator/api/v1beta1
version: v1beta1
- group: operator
-
controller: true
domain: victoriametrics.com
group: operator
kind: VMAlertmanagerConfig
path: github.com/VictoriaMetrics/operator/api/v1beta1
version: v1beta1
- group: operator
-
controller: true
domain: victoriametrics.com
group: operator
kind: VMPodScrape
path: github.com/VictoriaMetrics/operator/api/v1beta1
version: v1beta1
- group: operator
-
controller: true
domain: victoriametrics.com
group: operator
kind: VMRule
path: github.com/VictoriaMetrics/operator/api/v1beta1
version: v1beta1
- group: operator
-
controller: true
domain: victoriametrics.com
group: operator
kind: VMServiceScrape
path: github.com/VictoriaMetrics/operator/api/v1beta1
version: v1beta1
- group: operator
-
controller: true
domain: victoriametrics.com
group: operator
kind: VMSingle
path: github.com/VictoriaMetrics/operator/api/v1beta1
version: v1beta1
- group: operator
-
controller: true
domain: victoriametrics.com
group: operator
kind: VMCluster
path: github.com/VictoriaMetrics/operator/api/v1beta1
version: v1beta1
- group: operator
-
controller: true
domain: victoriametrics.com
group: operator
kind: VMProbe
path: github.com/VictoriaMetrics/operator/api/v1beta1
version: v1beta1
- group: operator
-
controller: true
domain: victoriametrics.com
group: operator
kind: VMNodeScrape
path: github.com/VictoriaMetrics/operator/api/v1beta1
version: v1beta1
- group: operator
-
controller: true
domain: victoriametrics.com
group: operator
kind: VMStaticScrape
path: github.com/VictoriaMetrics/operator/api/v1beta1
version: v1beta1
- group: operator
-
controller: true
domain: victoriametrics.com
group: operator
kind: VMUser
path: github.com/VictoriaMetrics/operator/api/v1beta1
version: v1beta1
- group: operator
-
controller: true
domain: victoriametrics.com
group: operator
kind: VMAuth
path: github.com/VictoriaMetrics/operator/api/v1beta1
version: v1beta1
version: 3-alpha
version: "3"
plugins:
go.operator-sdk.io/v2-alpha: {}
1 change: 1 addition & 0 deletions api/v1beta1/vmrule_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func (r *VMRule) SetupWebhookWithManager(mgr ctrl.Manager) error {
}

// +kubebuilder:webhook:verbs=create;update,admissionReviewVersions=v1,sideEffects=none,path=/validate-operator-victoriametrics-com-v1beta1-vmrule,mutating=false,failurePolicy=fail,groups=operator.victoriametrics.com,resources=vmrules,versions=v1beta1,name=vvmrule.kb.io

var _ webhook.Validator = &VMRule{}

func (r *VMRule) sanityCheck() error {
Expand Down
21 changes: 21 additions & 0 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
creationTimestamp: null
name: validating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down Expand Up @@ -124,6 +125,26 @@ webhooks:
resources:
- vmclusters
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-operator-victoriametrics-com-v1beta1-vmrule
failurePolicy: Fail
name: vvmrule.kb.io
rules:
- apiGroups:
- operator.victoriametrics.com
apiVersions:
- v1beta1
operations:
- CREATE
- UPDATE
resources:
- vmrules
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
Expand Down

0 comments on commit 5a857d5

Please sign in to comment.