@@ -429,8 +429,8 @@ func (c *Controller) recordContainer(ctx context.Context, pod *corev1.Pod, conta
429429 // Gather aggregate metadata for adds/updates
430430 var runtimeRisks []deploymentrecord.RuntimeRisk
431431 if status != deploymentrecord .StatusDecommissioned {
432- metadata := c .aggregateMetadata (ctx , podToPartialMetadata (pod ))
433- for risk := range metadata .RuntimeRisks {
432+ aggMetadata := c .aggregateMetadata (ctx , podToPartialMetadata (pod ))
433+ for risk := range aggMetadata .RuntimeRisks {
434434 runtimeRisks = append (runtimeRisks , risk )
435435 }
436436 }
@@ -496,9 +496,9 @@ func (c *Controller) recordContainer(ctx context.Context, pod *corev1.Pod, conta
496496 return nil
497497}
498498
499- // aggregateRuntimeRisks aggregates metadata for a pod and its owners.
499+ // aggregateMetadata returns aggregated metadata for a pod and its owners.
500500func (c * Controller ) aggregateMetadata (ctx context.Context , obj * metav1.PartialObjectMetadata ) AggregatePodMetadata {
501- metadata := AggregatePodMetadata {
501+ aggMetadata := AggregatePodMetadata {
502502 RuntimeRisks : make (map [deploymentrecord.RuntimeRisk ]bool ),
503503 }
504504 queue := []* metav1.PartialObjectMetadata {obj }
@@ -517,14 +517,14 @@ func (c *Controller) aggregateMetadata(ctx context.Context, obj *metav1.PartialO
517517 }
518518 visited [current .GetUID ()] = true
519519
520- getMetadataFromObject (current , metadata )
520+ getMetadataFromObject (current , aggMetadata )
521521 c .addOwnersToQueue (ctx , current , & queue )
522522 }
523523
524- return metadata
524+ return aggMetadata
525525}
526526
527- // collectRuntimeRisksFromOwners takes a current object and looks up its owners, adding them to the queue for processing
527+ // addOwnersToQueue takes a current object and looks up its owners, adding them to the queue for processing
528528// to collect their metadata.
529529func (c * Controller ) addOwnersToQueue (ctx context.Context , current * metav1.PartialObjectMetadata , queue * []* metav1.PartialObjectMetadata ) {
530530 ownerRefs := current .GetOwnerReferences ()
@@ -551,21 +551,16 @@ func (c *Controller) addOwnersToQueue(ctx context.Context, current *metav1.Parti
551551
552552// getOwnerMetadata retrieves partial object metadata for an owner ref.
553553func (c * Controller ) getOwnerMetadata (ctx context.Context , namespace string , owner metav1.OwnerReference ) (* metav1.PartialObjectMetadata , error ) {
554- var gvr schema.GroupVersionResource
554+ gvr := schema.GroupVersionResource {
555+ Group : "apps" ,
556+ Version : "v1" ,
557+ }
555558
556559 switch owner .Kind {
557560 case "ReplicaSet" :
558- gvr = schema.GroupVersionResource {
559- Group : "apps" ,
560- Version : "v1" ,
561- Resource : "replicasets" ,
562- }
561+ gvr .Resource = "replicasets"
563562 case "Deployment" :
564- gvr = schema.GroupVersionResource {
565- Group : "apps" ,
566- Version : "v1" ,
567- Resource : "deployments" ,
568- }
563+ gvr .Resource = "deployments"
569564 default :
570565 slog .Debug ("Unsupported owner kind for runtime risk collection" ,
571566 "kind" , owner .Kind ,
0 commit comments