@@ -37,11 +37,15 @@ func (b *BuildPlan) hydrate() error {
3737 }
3838
3939 // We have all the artifacts we're interested in now, but we still want to relate them to a source; ie. an ingredient.
40+ // We also want to relate artifacts to their builders, because dynamically imported ingredients have a special installation process.
4041 // This will also hydrate our requirements, because they are based on the source ID.
4142 for _ , artifact := range b .artifacts {
4243 if err := b .hydrateWithIngredients (artifact , platformID , ingredientLookup ); err != nil {
4344 return errs .Wrap (err , "hydrating with ingredients failed" )
4445 }
46+ if err := b .hydrateWithBuilders (artifact , artifactLookup ); err != nil {
47+ return errs .Wrap (err , "hydrating with builders failed" )
48+ }
4549 }
4650 }
4751
@@ -202,6 +206,30 @@ func (b *BuildPlan) hydrateWithIngredients(artifact *Artifact, platformID *strfm
202206 return nil
203207}
204208
209+ func (b * BuildPlan ) hydrateWithBuilders (artifact * Artifact , artifactLookup map [strfmt.UUID ]* Artifact ) error {
210+ err := b .raw .WalkViaSteps ([]strfmt.UUID {artifact .ArtifactID }, raw .WalkViaBuilder , func (node interface {}, parent * raw.Artifact ) error {
211+ v , ok := node .(* raw.Artifact )
212+ if ! ok {
213+ return nil // continue
214+ }
215+
216+ builder , ok := artifactLookup [v .NodeID ]
217+ if ! ok {
218+ builder = createArtifact (v )
219+ b .artifacts = append (b .artifacts , builder )
220+ artifactLookup [v .NodeID ] = builder
221+ }
222+
223+ artifact .Builder = builder
224+ return nil
225+ })
226+ if err != nil {
227+ return errs .Wrap (err , "error hydrating builders" )
228+ }
229+
230+ return nil
231+ }
232+
205233// sanityCheck will for convenience sake validate that we have no duplicates here while on a dev machine.
206234// If there are duplicates we're likely to see failures down the chain if live, though that's by no means guaranteed.
207235// Surfacing it here will make it easier to reason about the failure.
0 commit comments