-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
score: allow ignore/allow annotations on child template resources
- Loading branch information
Showing
8 changed files
with
241 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: trivy | ||
namespace: trivy-staging | ||
spec: | ||
podManagementPolicy: Parallel | ||
replicas: 3 | ||
revisionHistoryLimit: 10 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/instance: trivy | ||
app.kubernetes.io/name: trivy | ||
serviceName: trivy | ||
template: | ||
metadata: | ||
annotations: | ||
kube-score/ignore: container-image-tag,pod-probes | ||
labels: | ||
app.kubernetes.io/instance: trivy | ||
app.kubernetes.io/name: trivy | ||
spec: | ||
automountServiceAccountToken: false | ||
containers: | ||
- args: | ||
- server | ||
envFrom: | ||
- configMapRef: | ||
name: trivy | ||
- secretRef: | ||
name: trivy | ||
image: aquasec/trivy:latest | ||
imagePullPolicy: Always | ||
livenessProbe: | ||
failureThreshold: 10 | ||
httpGet: | ||
path: /healthz | ||
port: trivy-http | ||
scheme: HTTP | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 1 | ||
name: main | ||
ports: | ||
- containerPort: 4954 | ||
name: trivy-http | ||
protocol: TCP | ||
readinessProbe: | ||
failureThreshold: 3 | ||
httpGet: | ||
path: /healthz | ||
port: trivy-http | ||
scheme: HTTP | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 1 | ||
resources: | ||
limits: | ||
cpu: "1" | ||
ephemeral-storage: 128Mi | ||
memory: 1Gi | ||
requests: | ||
cpu: 200m | ||
memory: 512Mi | ||
securityContext: | ||
privileged: false | ||
readOnlyRootFilesystem: true | ||
runAsGroup: 65534 | ||
terminationMessagePath: /dev/termination-log | ||
terminationMessagePolicy: File | ||
volumeMounts: | ||
- mountPath: /tmp | ||
name: tmp-data | ||
- mountPath: /home/scanner/.cache | ||
name: data | ||
dnsPolicy: ClusterFirst | ||
restartPolicy: Always | ||
schedulerName: default-scheduler | ||
securityContext: | ||
fsGroup: 65534 | ||
runAsNonRoot: true | ||
runAsUser: 65534 | ||
serviceAccount: trivy | ||
serviceAccountName: trivy | ||
terminationGracePeriodSeconds: 30 | ||
volumes: | ||
- emptyDir: {} | ||
name: tmp-data | ||
updateStrategy: | ||
rollingUpdate: | ||
partition: 0 | ||
type: RollingUpdate | ||
volumeClaimTemplates: | ||
- apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
creationTimestamp: null | ||
name: data | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 5Gi | ||
volumeMode: Filesystem | ||
status: | ||
phase: Pending |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package scorecard | ||
|
||
import ( | ||
"strings" | ||
|
||
ks "github.com/zegl/kube-score/domain" | ||
) | ||
|
||
func (so *ScoredObject) isEnabled(check ks.Check, annotations, childAnnotations map[string]string) bool { | ||
isIn := func(csv string, key string) bool { | ||
for _, v := range strings.Split(csv, ",") { | ||
if v == key { | ||
return true | ||
} | ||
if _, ok := impliedIgnoreAnnotations[v]; ok { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
if childAnnotations != nil && so.useIgnoreChecksAnnotation && isIn(childAnnotations[ignoredChecksAnnotation], check.ID) { | ||
return false | ||
} | ||
if childAnnotations != nil && so.useOptionalChecksAnnotation && isIn(childAnnotations[optionalChecksAnnotation], check.ID) { | ||
return true | ||
} | ||
if so.useIgnoreChecksAnnotation && isIn(annotations[ignoredChecksAnnotation], check.ID) { | ||
return false | ||
} | ||
if so.useOptionalChecksAnnotation && isIn(annotations[optionalChecksAnnotation], check.ID) { | ||
return true | ||
} | ||
|
||
// Optional checks are disabled unless explicitly allowed above | ||
if check.Optional { | ||
return false | ||
} | ||
|
||
// Enabled by default | ||
return true | ||
} |
Oops, something went wrong.