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

Expect GetContext for context v2 resources #5025

Merged
merged 1 commit into from
Nov 22, 2024
Merged
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
8 changes: 4 additions & 4 deletions internal/controlplane/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type HasProtoContextV2Compat interface {

// HasProtoContextV2 is an interface that can be implemented by a request
type HasProtoContextV2 interface {
GetContextV2() *pb.ContextV2
GetContext() *pb.ContextV2
}

// HasProtoContext is an interface that can be implemented by a request
Expand All @@ -74,13 +74,13 @@ func getProjectFromContextV2Compat(accessor HasProtoContextV2Compat) (uuid.UUID,
}

func getProjectFromContextV2(accessor HasProtoContextV2) (uuid.UUID, error) {
if accessor.GetContextV2() == nil {
if accessor.GetContext() == nil {
return uuid.Nil, util.UserVisibleError(codes.InvalidArgument, "context cannot be nil")
}

// First check if the context is V2
if accessor.GetContextV2() != nil && accessor.GetContextV2().GetProjectId() != "" {
return parseProject(accessor.GetContextV2().GetProjectId())
if accessor.GetContext() != nil && accessor.GetContext().GetProjectId() != "" {
return parseProject(accessor.GetContext().GetProjectId())
}

return uuid.Nil, ErrNoProjectInContext
Expand Down
2 changes: 1 addition & 1 deletion internal/controlplane/handlers_authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func getProviderFromContext(req any) string {
}
return req.GetContext().GetProvider()
case HasProtoContextV2:
return req.GetContextV2().GetProvider()
return req.GetContext().GetProvider()
case HasProtoContext:
return req.GetContext().GetProvider()
default:
Expand Down
Loading