Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix feature install order #1033

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions examples/ordered-features/.devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"image": "ubuntu",
"features": {
"./afeature1": {},
"./afeature2": {}
}
}
7 changes: 7 additions & 0 deletions examples/ordered-features/afeature1/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "A feature 1",
"id": "afeature1",
"version": "1.0.0",
"description": "A feature 1.",
"options": {}
}
3 changes: 3 additions & 0 deletions examples/ordered-features/afeature1/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo "hello world from feature 1 !"
10 changes: 10 additions & 0 deletions examples/ordered-features/afeature2/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "A feature 2",
"id": "afeature2",
"version": "1.0.0",
"description": "A feature 2.",
"options": {},
"installsAfter": [
"./afeature1"
]
}
3 changes: 3 additions & 0 deletions examples/ordered-features/afeature2/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo "hello world from feature 2 !"
6 changes: 3 additions & 3 deletions pkg/devcontainer/feature/extend.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,12 @@ func computeAutomaticFeatureOrder(features []*config.FeatureSet) ([]*config.Feat
// build lookup map
lookup := map[string]*config.FeatureSet{}
for _, feature := range features {
lookup[feature.ConfigID] = feature
lookup[feature.Config.ID] = feature
}

// build graph
for _, feature := range features {
_, err := g.InsertNodeAt("root", feature.ConfigID, feature)
_, err := g.InsertNodeAt("root", feature.Config.ID, feature)
if err != nil {
return nil, err
}
Expand All @@ -325,7 +325,7 @@ func computeAutomaticFeatureOrder(features []*config.FeatureSet) ([]*config.Feat
}

// add an edge from feature to installAfterFeature
_, err = g.InsertNodeAt(feature.ConfigID, installAfter, installAfterFeature)
_, err = g.InsertNodeAt(feature.Config.ID, installAfter, installAfterFeature)
if err != nil {
return nil, err
}
Expand Down