@@ -782,11 +782,11 @@ func calculateChildTargets(reqs map[string][]*reqForNode, opt map[string]Options
782
782
}
783
783
784
784
func waitContextDeps (ctx context.Context , index int , results * waitmap.Map , so * client.SolveOpt ) error {
785
- m := map [string ]string {}
785
+ m := map [string ][] string {}
786
786
for k , v := range so .FrontendAttrs {
787
787
if strings .HasPrefix (k , "context:" ) && strings .HasPrefix (v , "target:" ) {
788
788
target := resultKey (index , strings .TrimPrefix (v , "target:" ))
789
- m [target ] = k
789
+ m [target ] = append ( m [ target ], k )
790
790
}
791
791
}
792
792
if len (m ) == 0 {
@@ -801,7 +801,7 @@ func waitContextDeps(ctx context.Context, index int, results *waitmap.Map, so *c
801
801
return err
802
802
}
803
803
804
- for k , v := range m {
804
+ for k , contexts := range m {
805
805
r , ok := res [k ]
806
806
if ! ok {
807
807
continue
@@ -816,51 +816,54 @@ func waitContextDeps(ctx context.Context, index int, results *waitmap.Map, so *c
816
816
if so .FrontendInputs == nil {
817
817
so .FrontendInputs = map [string ]llb.State {}
818
818
}
819
- if len (rr .Refs ) > 0 {
820
- for platform , r := range rr .Refs {
821
- st , err := r .ToState ()
819
+
820
+ for _ , v := range contexts {
821
+ if len (rr .Refs ) > 0 {
822
+ for platform , r := range rr .Refs {
823
+ st , err := r .ToState ()
824
+ if err != nil {
825
+ return err
826
+ }
827
+ so .FrontendInputs [k + "::" + platform ] = st
828
+ so .FrontendAttrs [v + "::" + platform ] = "input:" + k + "::" + platform
829
+ metadata := make (map [string ][]byte )
830
+ if dt , ok := rr .Metadata [exptypes .ExporterImageConfigKey + "/" + platform ]; ok {
831
+ metadata [exptypes .ExporterImageConfigKey ] = dt
832
+ }
833
+ if dt , ok := rr .Metadata ["containerimage.buildinfo/" + platform ]; ok {
834
+ metadata ["containerimage.buildinfo" ] = dt
835
+ }
836
+ if len (metadata ) > 0 {
837
+ dt , err := json .Marshal (metadata )
838
+ if err != nil {
839
+ return err
840
+ }
841
+ so .FrontendAttrs ["input-metadata:" + k + "::" + platform ] = string (dt )
842
+ }
843
+ }
844
+ delete (so .FrontendAttrs , v )
845
+ }
846
+ if rr .Ref != nil {
847
+ st , err := rr .Ref .ToState ()
822
848
if err != nil {
823
849
return err
824
850
}
825
- so .FrontendInputs [k + "::" + platform ] = st
826
- so .FrontendAttrs [v + "::" + platform ] = "input:" + k + "::" + platform
851
+ so .FrontendInputs [k ] = st
852
+ so .FrontendAttrs [v ] = "input:" + k
827
853
metadata := make (map [string ][]byte )
828
- if dt , ok := rr .Metadata [exptypes .ExporterImageConfigKey + "/" + platform ]; ok {
854
+ if dt , ok := rr .Metadata [exptypes .ExporterImageConfigKey ]; ok {
829
855
metadata [exptypes .ExporterImageConfigKey ] = dt
830
856
}
831
- if dt , ok := rr .Metadata ["containerimage.buildinfo/" + platform ]; ok {
857
+ if dt , ok := rr .Metadata ["containerimage.buildinfo" ]; ok {
832
858
metadata ["containerimage.buildinfo" ] = dt
833
859
}
834
860
if len (metadata ) > 0 {
835
861
dt , err := json .Marshal (metadata )
836
862
if err != nil {
837
863
return err
838
864
}
839
- so .FrontendAttrs ["input-metadata:" + k + "::" + platform ] = string (dt )
840
- }
841
- }
842
- delete (so .FrontendAttrs , v )
843
- }
844
- if rr .Ref != nil {
845
- st , err := rr .Ref .ToState ()
846
- if err != nil {
847
- return err
848
- }
849
- so .FrontendInputs [k ] = st
850
- so .FrontendAttrs [v ] = "input:" + k
851
- metadata := make (map [string ][]byte )
852
- if dt , ok := rr .Metadata [exptypes .ExporterImageConfigKey ]; ok {
853
- metadata [exptypes .ExporterImageConfigKey ] = dt
854
- }
855
- if dt , ok := rr .Metadata ["containerimage.buildinfo" ]; ok {
856
- metadata ["containerimage.buildinfo" ] = dt
857
- }
858
- if len (metadata ) > 0 {
859
- dt , err := json .Marshal (metadata )
860
- if err != nil {
861
- return err
865
+ so .FrontendAttrs ["input-metadata:" + k ] = string (dt )
862
866
}
863
- so .FrontendAttrs ["input-metadata:" + k ] = string (dt )
864
867
}
865
868
}
866
869
}
0 commit comments