Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/buildplan/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type Artifact struct {
IsRuntimeDependency bool
IsBuildtimeDependency bool

Builder *Artifact

platforms []strfmt.UUID
children []ArtifactRelation
}
Expand Down
28 changes: 28 additions & 0 deletions pkg/buildplan/hydrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ func (b *BuildPlan) hydrate() error {
}

// We have all the artifacts we're interested in now, but we still want to relate them to a source; ie. an ingredient.
// We also want to relate artifacts to their builders, because dynamically imported ingredients have a special installation process.
// This will also hydrate our requirements, because they are based on the source ID.
for _, artifact := range b.artifacts {
if err := b.hydrateWithIngredients(artifact, platformID, ingredientLookup); err != nil {
return errs.Wrap(err, "hydrating with ingredients failed")
}
if err := b.hydrateWithBuilders(artifact, artifactLookup); err != nil {
return errs.Wrap(err, "hydrating with builders failed")
}
}
}

Expand Down Expand Up @@ -202,6 +206,30 @@ func (b *BuildPlan) hydrateWithIngredients(artifact *Artifact, platformID *strfm
return nil
}

func (b *BuildPlan) hydrateWithBuilders(artifact *Artifact, artifactLookup map[strfmt.UUID]*Artifact) error {
err := b.raw.WalkViaSteps([]strfmt.UUID{artifact.ArtifactID}, raw.WalkViaBuilder, func(node interface{}, parent *raw.Artifact) error {
v, ok := node.(*raw.Artifact)
if !ok {
return nil // continue
}

builder, ok := artifactLookup[v.NodeID]
if !ok {
builder = createArtifact(v)
b.artifacts = append(b.artifacts, builder)
artifactLookup[v.NodeID] = builder
}

artifact.Builder = builder
return nil
})
if err != nil {
return errs.Wrap(err, "error hydrating builders")
}

return nil
}

// sanityCheck will for convenience sake validate that we have no duplicates here while on a dev machine.
// If there are duplicates we're likely to see failures down the chain if live, though that's by no means guaranteed.
// Surfacing it here will make it easier to reason about the failure.
Expand Down
1 change: 1 addition & 0 deletions pkg/buildplan/raw/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type StepInputTag string
const (
// Tag types
TagSource StepInputTag = "src"
TagBuilder StepInputTag = "builder"
TagDependency StepInputTag = "deps"
)

Expand Down
4 changes: 4 additions & 0 deletions pkg/buildplan/raw/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ var (
TagDependency,
false,
}
WalkViaBuilder = WalkStrategy{
TagBuilder,
true,
}
)

// WalkViaSteps walks the graph and reports on nodes it encounters
Expand Down
6 changes: 6 additions & 0 deletions pkg/runtime/ecosystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
ecosys "github.com/ActiveState/cli/pkg/runtime/ecosystem"
)

const starBuilder = "star-builder"

type ecosystem interface {
Init(runtimePath string, buildplan *buildplan.BuildPlan) error
Namespaces() []string
Expand All @@ -27,6 +29,10 @@ func init() {
}

func artifactMatchesEcosystem(a *buildplan.Artifact, e ecosystem) bool {
if a.Builder != nil && a.Builder.DisplayName != starBuilder {
return false
}
Comment on lines +32 to +34
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the crux of the PR. If an artifact's builder is not a star-builder, it cannot match a DI ecosystem for install and will go through the usual State Tool artifact install.


for _, namespace := range e.Namespaces() {
for _, i := range a.Ingredients {
if i.Namespace == namespace {
Expand Down
Loading