Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions score/probe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ func TestProbesPodAllMissing(t *testing.T) {
assert.Equal(t, "Container is missing a readinessProbe", comments[0].Summary)
}

func TestProbesServiceAccountName(t *testing.T) {
t.Parallel()
comments := testExpectedScore(t, "pod-probes-service-account-name.yaml", "Pod Probes", scorecard.GradeCritical)
assert.Len(t, comments, 1)
assert.Equal(t, "Container is missing a readinessProbe", comments[0].Summary)
}

func TestProbesPodMissingReady(t *testing.T) {
t.Parallel()
comments := testExpectedScore(t, "pod-probes-missing-ready.yaml", "Pod Probes", scorecard.GradeCritical)
Expand Down
4 changes: 4 additions & 0 deletions score/probes/probes.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func containerProbes(allServices []ks.Service) func(ks.PodSpecer) (scorecard.Tes
}
}

if podTemplate.Spec.ServiceAccountName != "" {
isTargetedByService = true
}

for _, container := range allContainers {
if container.ReadinessProbe != nil {
hasReadinessProbe = true
Expand Down
11 changes: 11 additions & 0 deletions score/testdata/pod-probes-service-account-name.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Pod
metadata:
name: pod-test-1
labels:
app: test
spec:
serviceAccountName: foobar
containers:
- name: foobar
image: foo/bar:latest