Skip to content

Commit

Permalink
fix: fix feature install order
Browse files Browse the repository at this point in the history
  • Loading branch information
aacebedo committed Apr 29, 2024
1 parent c3f49b7 commit 7eedfad
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
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

0 comments on commit 7eedfad

Please sign in to comment.