Skip to content

Commit

Permalink
fix: remove default namespace as a requirement to list namespaces (#3716
Browse files Browse the repository at this point in the history
)

* fix: remove default namespace as a requirement to list namespaces
  • Loading branch information
erka authored Dec 15, 2024
1 parent 2e3fd06 commit 45252bc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions build/testing/integration/authz/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ func (s clientCallSet) assert(t *testing.T, ctx context.Context, client sdk.SDK)
type clientCall func(*testing.T, context.Context, sdk.SDK) error

func GetNamespace(in *flipt.GetNamespaceRequest) clientCall {
if in.GetNamespaceKey() == "" {
in.Key = "default"
}
return func(t *testing.T, ctx context.Context, s sdk.SDK) error {
_, err := s.Flipt().GetNamespace(ctx, in)
return fmt.Errorf("GetNamespace: %w", err)
Expand Down Expand Up @@ -434,6 +437,7 @@ func CreateRollout(in *flipt.CreateRolloutRequest) clientCall {
return fmt.Errorf("CreateRollout: %w", err)
}
}

func UpdateRollout(in *flipt.UpdateRolloutRequest) clientCall {
return func(t *testing.T, ctx context.Context, s sdk.SDK) error {
_, err := s.Flipt().UpdateRollout(ctx, in)
Expand Down
8 changes: 7 additions & 1 deletion rpc/flipt/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ type Request struct {
Status Status `json:"status"`
}

func WithNoNamespace() func(*Request) {
return func(r *Request) {
r.Namespace = ""
}
}

func WithNamespace(ns string) func(*Request) {
return func(r *Request) {
if ns != "" {
Expand Down Expand Up @@ -98,7 +104,7 @@ func (req *GetNamespaceRequest) Request() []Request {
}

func (req *ListNamespaceRequest) Request() []Request {
return []Request{NewRequest(ResourceNamespace, ActionRead, WithNamespace(""))}
return []Request{NewRequest(ResourceNamespace, ActionRead, WithNoNamespace())}
}

func (req *CreateNamespaceRequest) Request() []Request {
Expand Down
4 changes: 3 additions & 1 deletion rpc/flipt/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ import (

func TestListNamespaceRequest_Request(t *testing.T) {
req := &ListNamespaceRequest{}
assert.Equal(t, []Request{NewRequest(ResourceNamespace, ActionRead)}, req.Request())
expected := NewRequest(ResourceNamespace, ActionRead)
expected.Namespace = ""
assert.Equal(t, []Request{expected}, req.Request())
}

0 comments on commit 45252bc

Please sign in to comment.