{{- /*
# Copyright 2022 Google LLC
#
# 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
#
#     https://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.
*/}}
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
  name: gmp-operator.gmp-system.monitoring.googleapis.com
  {{- if .Values.commonLabels }}
  labels:
    {{- include "prometheus-engine.labels" . | nindent 4 }}
  {{- end }}
webhooks:
- name: validate.rules.gmp-operator.gmp-system.monitoring.googleapis.com
  admissionReviewVersions:
  - v1
  clientConfig:
    # caBundle populated by operator.
    service:
      name: gmp-operator
      namespace: {{.Values.namespace.system}}
      port: 443
      path: /validate/monitoring.googleapis.com/v1/rules
  failurePolicy: Fail
  rules:
  - resources:
    - rules
    apiGroups:
    - monitoring.googleapis.com
    apiVersions:
    - v1
    operations:
    - CREATE
    - UPDATE
  sideEffects: None
- name: validate.clusterrules.gmp-operator.gmp-system.monitoring.googleapis.com
  admissionReviewVersions:
  - v1
  clientConfig:
    # caBundle populated by operator.
    service:
      name: gmp-operator
      namespace: {{.Values.namespace.system}}
      port: 443
      path: /validate/monitoring.googleapis.com/v1/clusterrules
  failurePolicy: Fail
  rules:
  - resources:
    - clusterrules
    apiGroups:
    - monitoring.googleapis.com
    apiVersions:
    - v1
    operations:
    - CREATE
    - UPDATE
  sideEffects: None
- name: validate.globalrules.gmp-operator.gmp-system.monitoring.googleapis.com
  admissionReviewVersions:
  - v1
  clientConfig:
    # caBundle populated by operator.
    service:
      name: gmp-operator
      namespace: {{.Values.namespace.system}}
      port: 443
      path: /validate/monitoring.googleapis.com/v1/globalrules
  failurePolicy: Fail
  rules:
  - resources:
    - globalrules
    apiGroups:
    - monitoring.googleapis.com
    apiVersions:
    - v1
    operations:
    - CREATE
    - UPDATE
  sideEffects: None
- name: validate.operatorconfigs.gmp-operator.gmp-system.monitoring.googleapis.com
  admissionReviewVersions:
  - v1
  clientConfig:
    # caBundle populated by operator.
    service:
      name: gmp-operator
      namespace: {{.Values.namespace.system}}
      port: 443
      path: /validate/monitoring.googleapis.com/v1/operatorconfigs
  failurePolicy: Fail
  rules:
  - resources:
    - operatorconfigs
    apiGroups:
    - monitoring.googleapis.com
    apiVersions:
    - v1
    operations:
    - CREATE
    - UPDATE
  sideEffects: None
