utils

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataSourceFromInstanceWithType

func DataSourceFromInstanceWithType(instance *store.InstanceMessage, dataSourceType storepb.DataSourceType) *storepb.DataSource

DataSourceFromInstanceWithType gets a typed data source from an instance.

func GetUserFormattedRolesMap

func GetUserFormattedRolesMap(ctx context.Context, stores MemberStore, user *store.UserMessage, projectPolicies ...*storepb.IamPolicy) map[string]bool

See GetUserRoles. The returned map key format is roles/{role}.

func GetUserIAMPolicyBindings

func GetUserIAMPolicyBindings(ctx context.Context, stores MemberStore, user *store.UserMessage, policies ...*storepb.IamPolicy) []*storepb.Binding

GetUserIAMPolicyBindings return the valid bindings for the user.

func GetUserRolesInIamPolicy

func GetUserRolesInIamPolicy(ctx context.Context, stores MemberStore, user *store.UserMessage, policies ...*storepb.IamPolicy) []string

GetUserRolesInIamPolicy returns the `uniq`ed roles of a user, including workspace roles and the roles in the projects. the condition of role binding is respected and evaluated with request.time=time.Now(). the returned role name should in the roles/{id} format.

func GetUsersByMember

func GetUsersByMember(ctx context.Context, stores MemberStore, member string) []*store.UserMessage

GetUsersByMember gets user messages by member. The member should in users/{uid} or groups/{email} format.

func Uniq

func Uniq[T comparable](array []T) []T

Types

type MemberStore

type MemberStore interface {
	GetGroup(ctx context.Context, email string) (*store.GroupMessage, error)
	GetUserByID(ctx context.Context, id int) (*store.UserMessage, error)
}

MemberStore is the subset of *store.Store the IAM membership helpers read. Narrowing it keeps the expansion logic testable without a database and documents exactly which lookups group expansion performs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL