Skip to content

Commit

Permalink
Enable federation for Unleash instances (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
Starefossen authored Aug 16, 2024
1 parent 863e440 commit a40cb61
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
6 changes: 4 additions & 2 deletions internal/unleash/bifrost.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ func (m *Manager) NewUnleash(ctx context.Context, name string, allowedTeams []st
// TODO implement auth, set iap header with actor from context or use psk - must update bifrost to support this
teams := strings.Join(allowedTeams, ",")
bi := bifrost.UnleashConfig{
Name: name,
AllowedTeams: teams,
Name: name,
AllowedTeams: teams,
EnableFederation: true,
AllowedClusters: "dev-gcp,prod-gcp,dev-fss,prod-fss",
}
unleashResponse, err := m.bifrostClient.Post(ctx, "/unleash/new", bi)
if err != nil {
Expand Down
17 changes: 14 additions & 3 deletions internal/unleash/bifrost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestBifrostClient_Post(t *testing.T) {
Expand All @@ -26,6 +26,9 @@ func TestBifrostClient_Post(t *testing.T) {
}
assert.Equal(t, "/unleash/new", r.URL.Path)
assert.Equal(t, "test", u.Name)
assert.Equal(t, "team1,team2", u.AllowedTeams)
assert.Equal(t, true, u.EnableFederation)
assert.Equal(t, "cluster1,cluster2", u.AllowedClusters)

unleashInstance := unleash_nais_io_v1.Unleash{
ObjectMeta: v1.ObjectMeta{
Expand All @@ -38,6 +41,12 @@ func TestBifrostClient_Post(t *testing.T) {
Value: u.AllowedTeams,
},
},
Federation: unleash_nais_io_v1.UnleashFederationConfig{
Enabled: true,
Clusters: []string{"cluster1", "cluster2"},
SecretNonce: "abc123",
Namespaces: []string{"team1", "team2"},
},
},
}

Expand All @@ -53,8 +62,10 @@ func TestBifrostClient_Post(t *testing.T) {
logger, _ := test.NewNullLogger()
bifrostClient := unleash.NewBifrostClient(s.URL, logger)
cfg := &bifrost.UnleashConfig{
Name: "test",
AllowedTeams: "team1,team2",
Name: "test",
AllowedTeams: "team1,team2",
EnableFederation: true,
AllowedClusters: "cluster1,cluster2",
}
resp, err := bifrostClient.Post(context.Background(), "/unleash/new", cfg)
assert.NoError(t, err)
Expand Down

0 comments on commit a40cb61

Please sign in to comment.