2222# examples: checks/cloud/google/gke/node_pool_uses_cos.yaml
2323package builtin.google.gke.google0054
2424
25+ import data.lib.cloud.value
2526import rego.v1
2627
2728deny contains res if {
2829 some cluster in input.google.gke.clusters
2930 isManaged (cluster)
31+ autopilot_disabled (cluster)
3032 image_type := cluster.nodeconfig.imagetype
31- not lower (image_type.value) in {" cos" , " cos_containerd" , " " }
33+ image_type_is_not_cos (image_type, {" cos" , " cos_containerd" , " " })
3234 res := result.new (
3335 " Cluster is not configuring node pools to use the COS containerd image type by default." ,
3436 image_type,
@@ -38,11 +40,35 @@ deny contains res if {
3840deny contains res if {
3941 some cluster in input.google.gke.clusters
4042 isManaged (cluster)
43+ autopilot_disabled (cluster)
4144 some pool in cluster.nodepools
4245 image_type := pool.nodeconfig.imagetype
43- not lower (image_type.value) in {" cos" , " cos_containerd" }
46+ image_type_is_not_cos (image_type, {" cos" , " cos_containerd" })
4447 res := result.new (
4548 " Node pool is not using the COS containerd image type." ,
4649 image_type,
4750 )
4851}
52+
53+ autopilot_disabled (cluster) if value.is_false (cluster.enableautpilot)
54+
55+ autopilot_disabled (cluster) if not cluster.enableautpilot
56+
57+ deny contains res if {
58+ some cluster in input.google.gke.clusters
59+ isManaged (cluster)
60+ cluster.enableautpilot.value
61+ image_type := cluster.autoscaling.autoprovisioningdefaults.imagetype
62+ image_type_is_not_cos (image_type, {" cos" , " cos_containerd" })
63+ res := result.new (
64+ " Node pool is not using the COS containerd image type." ,
65+ image_type,
66+ )
67+ }
68+
69+ image_type_is_not_cos (image_type, _) if value.is_empty (image_type)
70+
71+ image_type_is_not_cos (image_type, allowed) if {
72+ value.is_not_empty (image_type)
73+ not lower (image_type.value) in allowed
74+ }
0 commit comments