@@ -80,7 +80,7 @@ func (b *BuildPlan) hydrate() error {
8080}
8181
8282func (b * BuildPlan ) hydrateWithBuildClosure (nodeIDs []strfmt.UUID , platformID * strfmt.UUID , artifactLookup map [strfmt.UUID ]* Artifact ) error {
83- err := b .raw .WalkViaSteps (nodeIDs , raw .TagDependency , func (node interface {}, parent * raw.Artifact ) error {
83+ err := b .raw .WalkViaSteps (nodeIDs , raw .WalkViaDeps , func (node interface {}, parent * raw.Artifact ) error {
8484 switch v := node .(type ) {
8585 case * raw.Artifact :
8686 // logging.Debug("Walking build closure artifact '%s (%s)'", v.DisplayName, v.NodeID)
@@ -151,51 +151,44 @@ func (b *BuildPlan) hydrateWithRuntimeClosure(nodeIDs []strfmt.UUID, platformID
151151}
152152
153153func (b * BuildPlan ) hydrateWithIngredients (artifact * Artifact , platformID * strfmt.UUID , ingredientLookup map [strfmt.UUID ]* Ingredient ) error {
154- err := b .raw .WalkViaSteps ([]strfmt.UUID {artifact .ArtifactID }, raw .TagSource ,
154+ err := b .raw .WalkViaSteps ([]strfmt.UUID {artifact .ArtifactID }, raw .WalkViaSingleSource ,
155155 func (node interface {}, parent * raw.Artifact ) error {
156- switch v := node .(type ) {
157- case * raw.Source :
158- // logging.Debug("Walking source '%s (%s)'", v.Name, v.NodeID)
159-
160- // Ingredients aren't explicitly represented in buildplans. Technically all sources are ingredients
161- // but this may not always be true in the future. For our purposes we will initialize our own ingredients
162- // based on the source information, but we do not want to make the assumption in our logic that all
163- // sources are ingredients.
164- ingredient , ok := ingredientLookup [v .IngredientID ]
165- if ! ok {
166- ingredient = & Ingredient {
167- IngredientSource : & v .IngredientSource ,
168- platforms : []strfmt.UUID {},
169- Artifacts : []* Artifact {},
170- }
171- b .ingredients = append (b .ingredients , ingredient )
172- ingredientLookup [v .IngredientID ] = ingredient
173- }
156+ // logging.Debug("Walking source '%s (%s)'", v.Name, v.NodeID)
157+ v , ok := node .(* raw.Source )
158+ if ! ok {
159+ return nil // continue
160+ }
174161
175- // With multiple terminals it's possible we encounter the same combination multiple times.
176- // And an artifact usually only has one ingredient, so this is the cheapest lookup.
177- if ! sliceutils .Contains (artifact .Ingredients , ingredient ) {
178- artifact .Ingredients = append (artifact .Ingredients , ingredient )
179- ingredient .Artifacts = append (ingredient .Artifacts , artifact )
180- }
181- if platformID != nil {
182- ingredient .platforms = append (ingredient .platforms , * platformID )
162+ // Ingredients aren't explicitly represented in buildplans. Technically all sources are ingredients
163+ // but this may not always be true in the future. For our purposes we will initialize our own ingredients
164+ // based on the source information, but we do not want to make the assumption in our logic that all
165+ // sources are ingredients.
166+ ingredient , ok := ingredientLookup [v .IngredientID ]
167+ if ! ok {
168+ ingredient = & Ingredient {
169+ IngredientSource : & v .IngredientSource ,
170+ platforms : []strfmt.UUID {},
171+ Artifacts : []* Artifact {},
183172 }
173+ b .ingredients = append (b .ingredients , ingredient )
174+ ingredientLookup [v .IngredientID ] = ingredient
175+ }
184176
185- if artifact .isBuildtimeDependency {
186- ingredient .IsBuildtimeDependency = true
187- }
188- if artifact .isRuntimeDependency {
189- ingredient .IsRuntimeDependency = true
190- }
177+ // With multiple terminals it's possible we encounter the same combination multiple times.
178+ // And an artifact usually only has one ingredient, so this is the cheapest lookup.
179+ if ! sliceutils .Contains (artifact .Ingredients , ingredient ) {
180+ artifact .Ingredients = append (artifact .Ingredients , ingredient )
181+ ingredient .Artifacts = append (ingredient .Artifacts , artifact )
182+ }
183+ if platformID != nil {
184+ ingredient .platforms = append (ingredient .platforms , * platformID )
185+ }
191186
192- return nil
193- default :
194- if a , ok := v .(* raw.Artifact ); ok && a .NodeID == artifact .ArtifactID {
195- return nil // continue
196- }
197- // Source ingredients are only relevant when they link DIRECTLY to the artifact
198- return raw.WalkInterrupt {}
187+ if artifact .isBuildtimeDependency {
188+ ingredient .IsBuildtimeDependency = true
189+ }
190+ if artifact .isRuntimeDependency {
191+ ingredient .IsRuntimeDependency = true
199192 }
200193
201194 return nil
0 commit comments