apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
  name: metrics-keda
spec:
  steps:
    - name: step-00
      try:
        - script:
            content: |
              kubectl apply --server-side -f https://github.com/kedacore/keda/releases/download/v2.13.1/keda-2.13.1.yaml
        - wait:
            timeout: 3m
            apiVersion: v1
            kind: Pod
            namespace: keda
            selector: name=keda-operator
            for:
              condition:
                name: ready
        - apply:
            file: 00-install.yaml
        - apply:
            file: mock-server.yaml
        - apply:
            file: metric.yaml
            template: true
        - apply:
            file: scaledobject.yaml
            template: true
        - assert:
            file: deployment.yaml
      catch:
        - podLogs:
            selector: app=podtato-head
        - describe:
            apiVersion: v1
            kind: Pod
            selector: app=podtato-head
        - podLogs:
            namespace: keda
            selector: name=keda-operator
        - describe:
            apiVersion: v1
            kind: Pod
            namespace: keda
            selector: name=keda-operator
        - podLogs:
            namespace: keptn-system
            selector: app=metrics-operator
        - describe:
            apiVersion: metrics.keptn.sh/v1
            kind: KeptnMetric
            name: test
        - describe:
            apiVersion: metrics.keptn.sh/v1
            kind: KeptnMetricsProvider
            name: my-provider
        - describe:
            apiVersion: keda.k8s.io/v1alpha1
            kind: ScaledObject
            name: test-scaledobject
