Skip to content

Commit 9f43b9f

Browse files
committed
test: add tests for service account name
Signed-off-by: Jiaxiao (mossaka) Zhou <[email protected]>
1 parent e18f250 commit 9f43b9f

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

pkg/cmd/scaffold.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ spec:
7272
{{- if .AzureWorkloadIdentity }}
7373
podLabels:
7474
azure.workload.identity/use: "true"
75+
{{- end }}
7576
{{- if .ServiceAccountName }}
7677
serviceAccountName: {{ .ServiceAccountName }}
7778
{{- end }}

pkg/cmd/scaffold_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,32 @@ func TestScaffoldOutput(t *testing.T) {
6565
},
6666
expected: "multiple_image_secrets.yml",
6767
},
68+
{
69+
name: "service account name is provided",
70+
opts: ScaffoldOptions{
71+
from: "ghcr.io/foo/example-app:v0.1.0",
72+
replicas: 2,
73+
executor: "containerd-shim-spin",
74+
serviceAccountName: "my-service-account",
75+
},
76+
expected: "service_account_name.yml",
77+
},
78+
{
79+
name: "service account with HPA autoscaler",
80+
opts: ScaffoldOptions{
81+
from: "ghcr.io/foo/example-app:v0.1.0",
82+
executor: "containerd-shim-spin",
83+
autoscaler: "hpa",
84+
cpuLimit: "100m",
85+
memoryLimit: "128Mi",
86+
replicas: 2,
87+
maxReplicas: 3,
88+
targetCPUUtilizationPercentage: 60,
89+
targetMemoryUtilizationPercentage: 60,
90+
serviceAccountName: "my-service-account",
91+
},
92+
expected: "hpa_service_account.yml",
93+
},
6894
{
6995
name: "HPA autoscaler support",
7096
opts: ScaffoldOptions{
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: core.spinkube.dev/v1alpha1
2+
kind: SpinApp
3+
metadata:
4+
name: example-app
5+
spec:
6+
image: "ghcr.io/foo/example-app:v0.1.0"
7+
executor: containerd-shim-spin
8+
enableAutoscaling: true
9+
serviceAccountName: my-service-account
10+
resources:
11+
limits:
12+
cpu: 100m
13+
memory: 128Mi
14+
---
15+
apiVersion: autoscaling/v2
16+
kind: HorizontalPodAutoscaler
17+
metadata:
18+
name: example-app-autoscaler
19+
spec:
20+
scaleTargetRef:
21+
apiVersion: apps/v1
22+
kind: Deployment
23+
name: example-app
24+
minReplicas: 2
25+
maxReplicas: 3
26+
metrics:
27+
- type: Resource
28+
resource:
29+
name: cpu
30+
target:
31+
type: Utilization
32+
averageUtilization: 60
33+
- type: Resource
34+
resource:
35+
name: memory
36+
target:
37+
type: Utilization
38+
averageUtilization: 60
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: core.spinkube.dev/v1alpha1
2+
kind: SpinApp
3+
metadata:
4+
name: example-app
5+
spec:
6+
image: "ghcr.io/foo/example-app:v0.1.0"
7+
executor: containerd-shim-spin
8+
replicas: 2
9+
serviceAccountName: my-service-account

0 commit comments

Comments
 (0)