Skip to content

Commit

Permalink
fix: ensure the network feature in k8s is enabled first
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsgruk committed Jan 28, 2025
1 parent b1adf0c commit 72c8f4c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/jnsgruk/concierge

go 1.22.7
go 1.23

require (
github.com/canonical/x-go v0.0.0-20230522092633-7947a7587f5b
Expand Down
14 changes: 13 additions & 1 deletion internal/providers/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package providers
import (
"fmt"
"log/slog"
"maps"
"path"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -158,7 +160,17 @@ func (k *K8s) init() error {

// configureFeatures iterates over the specified features, enabling and configuring them.
func (k *K8s) configureFeatures() error {
for featureName, conf := range k.Features {
// Ensure the network feature is always enabled firsti if specified, as others depend on it.
keys := slices.Sorted(maps.Keys(k.Features))
// If the network feature is specified, ensure it's at the front of the list of features
// that we iterate over so it's enabled first
if slices.Contains(keys, "network") {
remaining := slices.DeleteFunc(keys, func(v string) bool { return v == "network" })
keys = slices.Insert(remaining, 0, "network")
}

for _, featureName := range keys {
conf := k.Features[featureName]
for key, value := range conf {
featureConfig := fmt.Sprintf("%s.%s=%s", featureName, key, value)

Expand Down

0 comments on commit 72c8f4c

Please sign in to comment.