Skip to content

Commit 7ce5f40

Browse files
author
balasoiu-adobe-com
committed
SKYOPS-121706: Add schema for Keda ScaledObject
1 parent 83c0c7b commit 7ce5f40

File tree

6 files changed

+71
-0
lines changed

6 files changed

+71
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ CRD's currently supported:
1717
- contour (adobe fork)
1818
- helm-operator
1919
- istio
20+
- keda
2021
- prometheus-operator
2122
- ack dynamodb- and elasticache controllers
2223
- elasticsearch opertator

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,4 @@ crd_to_json_schema eck-operator https://raw.githubusercontent.com/elastic/cloud-
8787
crd_to_json_schema vault-secrets-operator https://raw.githubusercontent.com/ricoberger/vault-secrets-operator/master/charts/vault-secrets-operator/crds/ricoberger.de_vaultsecrets.yaml
8888
crd_to_json_schema vpa https://raw.githubusercontent.com/kubernetes/autoscaler/master/vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml
8989
crd_to_json_schema external-secrets-operator https://raw.githubusercontent.com/external-secrets/external-secrets/main/deploy/crds/bundle.yaml
90+
crd_to_json_schema keda https://raw.githubusercontent.com/kedacore/keda/main/config/crd/bases/keda.sh_scaledobjects.yaml

test/keda/scaledobject.bats

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bats
2+
3+
load ../test_helper
4+
5+
@test "valid ScaledObject" {
6+
run kubeval "${FIXTURES}/valid.yaml"
7+
[[ $status -eq 0 ]]
8+
[[ $output = "PASS - ${FIXTURES}/valid.yaml contains a valid ScaledObject (test)" ]]
9+
}
10+
11+
@test "invalid ScaledObject" {
12+
run kubeval "${FIXTURES}/invalid.yaml"
13+
[[ $status -eq 1 ]]
14+
[[ $output = "WARN - ${FIXTURES}/invalid.yaml contains an invalid ScaledObject (test) - scaleTargetRef: scaleTargetRef is required" ]]
15+
}
16+
17+
@test "invalid ScaledObject in strict mode" {
18+
run kubeval --strict "${FIXTURES}/strict.yaml"
19+
[[ $status -eq 1 ]]
20+
[[ $output = "WARN - ${FIXTURES}/strict.yaml contains an invalid ScaledObject (test) - unknownProperty: Additional property unknownProperty is not allowed" ]]
21+
}
22+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
apiVersion: keda.sh/v1alpha1
3+
kind: ScaledObject
4+
metadata:
5+
name: test
6+
namespace: default
7+
spec:
8+
minReplicaCount: 1
9+
maxReplicaCount: 10
10+
triggers:
11+
- type: cpu
12+
metadata:
13+
type: Utilization
14+
value: "80"

test/keda/scaledobject/strict.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
apiVersion: keda.sh/v1alpha1
3+
kind: ScaledObject
4+
metadata:
5+
name: test
6+
namespace: default
7+
spec:
8+
scaleTargetRef:
9+
name: test-deployment
10+
minReplicaCount: 1
11+
maxReplicaCount: 10
12+
triggers:
13+
- type: cpu
14+
metadata:
15+
type: Utilization
16+
value: "80"
17+
unknownProperty: invalid

test/keda/scaledobject/valid.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
apiVersion: keda.sh/v1alpha1
3+
kind: ScaledObject
4+
metadata:
5+
name: test
6+
namespace: default
7+
spec:
8+
scaleTargetRef:
9+
name: test-deployment
10+
minReplicaCount: 1
11+
maxReplicaCount: 10
12+
triggers:
13+
- type: cpu
14+
metadata:
15+
type: Utilization
16+
value: "80"

0 commit comments

Comments
 (0)