@@ -536,8 +536,10 @@ class EdgesContext(list):
536536 containers = query_path (self .resource , path )
537537 if containers is None :
538538 return
539+
539540 target_resources = set ()
540541 def process_optional_resource (
542+ path ,
541543 context ,
542544 kind ,
543545 name_path ,
@@ -549,45 +551,50 @@ class EdgesContext(list):
549551 if query_path (context , optional_path ) is True :
550552 if resource_id not in resources :
551553 self .info (
552- path ,
554+ f" { path } . { name_path } " ,
553555 f"{ kind } '{ resource_name } ' undefined but optional"
554556 )
555557 return
556558 target_resources .add (
557559 resource_id
558560 )
559561
560- for container in containers :
562+ for cidx , container in enumerate ( containers ) :
561563 container_env = query_path (container , "env" )
562564 if isinstance (container_env , list ):
563- for env in container_env :
565+ for eidx , env in enumerate ( container_env ) :
564566 process_optional_resource (
567+ f"{ path } [{ cidx } ].env[{ eidx } ]" ,
565568 env ,
566569 "ConfigMap" ,
567570 "valueFrom.configMapKeyRef.name" ,
568571 "valueFrom.configMapKeyRef.optional"
569572 )
570573 process_optional_resource (
574+ f"{ path } [{ cidx } ].env[{ eidx } ]" ,
571575 env ,
572576 "Secret" ,
573577 "valueFrom.secretKeyRef.name" ,
574578 "valueFrom.secretKeyRef.optional"
575579 )
576580 container_env_from = query_path (container , "envFrom" )
577581 if isinstance (container_env_from , list ):
578- for env_from in container_env_from :
582+ for eidx , env_from in enumerate ( container_env_from ) :
579583 process_optional_resource (
584+ f"{ path } [{ cidx } ].envFrom[{ eidx } ]" ,
580585 env_from ,
581586 "ConfigMap" ,
582587 "configMapRef.name" ,
583588 "configMapRef.optional"
584589 )
585590 process_optional_resource (
591+ f"{ path } [{ cidx } ].envFrom[{ eidx } ]" ,
586592 env_from ,
587593 "Secret" ,
588594 "secretRef.name" ,
589595 "secretRef.optional"
590596 )
597+
591598 for target_resource in target_resources :
592599 self .add_edge_to_rid (path , target_resource , "REFERENCE" )
593600
0 commit comments