iam

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DummyTime = time.Now()

DummyTime is a placeholder time for service accounts (they don't have modification times)

Functions

func Close

func Close() error

Close closes the IAM client. Note: The IAM client doesn't require explicit cleanup, but this is provided for consistency with other clients.

func FormatHeader

func FormatHeader() string

FormatHeader returns the header for long format listing.

func GetClient

func GetClient(ctx context.Context, opts ...option.ClientOption) (*iam.Service, error)

GetClient returns a singleton IAM client. The client is initialized on first call and reused for subsequent calls.

func ParseIAMPath

func ParseIAMPath(path string) (projectID string, resourceType string, err error)

ParseIAMPath parses an IAM path and returns the project ID and resource type. Expected format: iam://project-id/service-accounts

Types

type ServiceAccountInfo

type ServiceAccountInfo struct {
	Email       string
	Name        string
	DisplayName string
	Description string
	Disabled    bool
	ProjectID   string
}

ServiceAccountInfo represents information about a service account.

func GetServiceAccount

func GetServiceAccount(ctx context.Context, projectID, accountEmail string) (*ServiceAccountInfo, error)

GetServiceAccount retrieves details about a specific service account.

func ListServiceAccounts

func ListServiceAccounts(ctx context.Context, projectID string) ([]*ServiceAccountInfo, error)

ListServiceAccounts lists all service accounts in a project.

func (*ServiceAccountInfo) FormatDetailed

func (sa *ServiceAccountInfo) FormatDetailed(aliasPath string) string

FormatDetailed formats service account info with all details.

func (*ServiceAccountInfo) FormatLong

func (sa *ServiceAccountInfo) FormatLong() string

FormatLong formats service account info in long format (email, displayName, disabled).

func (*ServiceAccountInfo) FormatShort

func (sa *ServiceAccountInfo) FormatShort() string

FormatShort formats service account info in short format (just email).

func (*ServiceAccountInfo) FormatShortWithAlias

func (sa *ServiceAccountInfo) FormatShortWithAlias(aliasPath string) string

FormatShortWithAlias formats service account info with alias path.

type ServiceAccountKeyInfo

type ServiceAccountKeyInfo struct {
	Name            string
	KeyID           string
	KeyType         string // USER_MANAGED or SYSTEM_MANAGED
	ValidAfterTime  time.Time
	ValidBeforeTime time.Time
	KeyAlgorithm    string
	Disabled        bool
}

ServiceAccountKeyInfo represents information about a service account key.

func ListServiceAccountKeys

func ListServiceAccountKeys(ctx context.Context, projectID, accountEmail string) ([]*ServiceAccountKeyInfo, error)

ListServiceAccountKeys lists all keys for a service account.

type UsageInfo

type UsageInfo struct {
	ResourceType string // "storage", "bigquery", "compute", etc.
	ResourceName string // bucket name, dataset name, instance name, etc.
	Roles        []string
}

UsageInfo represents a resource where a service account has permissions.

func GetServiceAccountUsage

func GetServiceAccountUsage(ctx context.Context, projectID, accountEmail string) ([]*UsageInfo, error)

GetServiceAccountUsage finds all resources where a service account has IAM permissions. This uses the Cloud Asset Inventory API to search across all resources.

Jump to

Keyboard shortcuts

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