@@ -284,17 +284,17 @@ func runGenerate(cmd *cobra.Command, args []string) error {
284284 return nil
285285}
286286
287- // mapCCWorkloads applies the given function to all workloads with the 'contrast-cc' runtime class.
287+ // mapContrastWorkloads applies the given function to all workloads with a Contrast runtime class.
288288// The callback receives an apply configuration together with the file path and index the unstructured object has in the file map.
289289// Changes to the apply configuration are not applied to the original unstructured object.
290- func mapCCWorkloads (fileMap map [string ][]* unstructured.Unstructured , f func (res any , path string , idx int ) (any , error )) error {
290+ func mapContrastWorkloads (fileMap map [string ][]* unstructured.Unstructured , f func (res any , path string , idx int ) (any , error )) error {
291291 for path , resources := range fileMap {
292292 for idx , r := range resources {
293293 applyConfig , err := kuberesource .UnstructuredToApplyConfiguration (r )
294294 if err != nil {
295295 continue
296296 }
297- if ! isCCWorkload (applyConfig ) {
297+ if ! isContrastWorkload (applyConfig ) {
298298 continue
299299 }
300300 changed , err := f (applyConfig , path , idx )
@@ -313,11 +313,9 @@ func mapCCWorkloads(fileMap map[string][]*unstructured.Unstructured, f func(res
313313 return nil
314314}
315315
316- func isCCWorkload (resource any ) (ret bool ) {
316+ func isContrastWorkload (resource any ) (ret bool ) {
317317 kuberesource .MapPodSpec (resource , func (spec * applycorev1.PodSpecApplyConfiguration ) * applycorev1.PodSpecApplyConfiguration {
318- if spec != nil && spec .RuntimeClassName != nil && strings .HasPrefix (* spec .RuntimeClassName , "contrast-cc" ) {
319- ret = true
320- }
318+ ret = kuberesource .IsContrastPod (spec )
321319 return spec
322320 })
323321 return ret
@@ -339,7 +337,7 @@ func isCoordinator(resource any) bool {
339337func runVerifiers (fileMap map [string ][]* unstructured.Unstructured , verifiers []verifier.Verifier ) error {
340338 var findings error
341339 for _ , v := range verifiers {
342- _ = mapCCWorkloads (fileMap , func (res any , path string , idx int ) (any , error ) {
340+ _ = mapContrastWorkloads (fileMap , func (res any , path string , idx int ) (any , error ) {
343341 if err := v .Verify (res ); err != nil {
344342 findings = errors .Join (findings , fmt .Errorf ("failed to verify resource %q in file %q: %w" , fileMap [path ][idx ].GetName (), path , err ))
345343 }
@@ -406,7 +404,7 @@ func extractTargets(paths []string, configFile io.Writer, logger *slog.Logger) (
406404 applyConfig , err := kuberesource .UnstructuredToApplyConfiguration (object )
407405 if err != nil {
408406 logger .Warn ("Could not convert resource into ApplyConfiguration" , "path" , path , "err" , err )
409- } else if isCCWorkload (applyConfig ) {
407+ } else if isContrastWorkload (applyConfig ) {
410408 containsCC = true
411409 if isCoordinator (applyConfig ) {
412410 r , ok := applyConfig .(* applyappsv1.StatefulSetApplyConfiguration )
@@ -454,7 +452,7 @@ func generatePolicies(ctx context.Context, flags *generateFlags, fileMap map[str
454452 }
455453 }()
456454
457- return mapCCWorkloads (fileMap , func (res any , path string , idx int ) (any , error ) {
455+ return mapContrastWorkloads (fileMap , func (res any , path string , idx int ) (any , error ) {
458456 initdataAnno , err := runner .Run (ctx , res , extraPath , logger )
459457 if err != nil {
460458 return nil , fmt .Errorf ("failed to generate policy for %q in %q: %w" , fileMap [path ][idx ].GetName (), path , err )
@@ -496,7 +494,7 @@ func patchTargets(fileMap map[string][]*unstructured.Unstructured, imageReplacem
496494 return fmt .Errorf ("parsing release image definitions %s: %w" , ReleaseImageReplacements , err )
497495 }
498496 }
499- return mapCCWorkloads (fileMap , func (res any , _ string , _ int ) (any , error ) {
497+ return mapContrastWorkloads (fileMap , func (res any , _ string , _ int ) (any , error ) {
500498 if flags .insecureEnableDebugShell {
501499 if _ , err := kuberesource .AddDebugShell (res , kuberesource .DebugShell ()); err != nil {
502500 return nil , fmt .Errorf ("injecting debug shell container: %w" , err )
0 commit comments