clouds

package
v0.9.15 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package clouds provides interfaces for accessing cloud APIs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account added in v0.8.4

type Account struct {
	ID          string
	DisplayName string
	Description string
}

Account represents a user or service account within the underlying system.

type AccountManager added in v0.8.4

type AccountManager interface {

	// GetServiceAccounts returns a chan for per service account for the given project.
	// Ends writing when all service accounts are sent or ctx is cancels.
	GetServiceAccounts(ctx context.Context, project string) (<-chan *Account, error)

	// RemoveServiceAccount removes a service account related to the given project.
	RemoveServiceAccount(ctx context.Context, project, accountID string) error

	// ManageAccountKeys maintains or removes keys on a clean-up cycle. Returns: remaining keys for account, removed keys for account, and error.
	ManageAccountKeys(ctx context.Context, project, accountID string, ttl, maxKeyTTL time.Duration, now time.Time, keysPerAccount int64) (int, int, error)
}

AccountManager abstracts account management within a target cloud environment.

type MockAccountManager added in v0.8.4

type MockAccountManager struct {
	// contains filtered or unexported fields
}

MockAccountManager provides an account manager implementation for testing.

func NewMockAccountManager added in v0.8.4

func NewMockAccountManager(accounts []*Account) *MockAccountManager

NewMockAccountManager creates a mock AccountManager.

func (*MockAccountManager) GetServiceAccounts added in v0.8.4

func (m *MockAccountManager) GetServiceAccounts(ctx context.Context, project string) (<-chan *Account, error)

GetServiceAccounts returns a chan for per service account for the given project. Ends writing when all service accounts are sent or ctx is cancels.

func (*MockAccountManager) ManageAccountKeys added in v0.8.4

func (m *MockAccountManager) ManageAccountKeys(ctx context.Context, project, accountID string, ttl, maxKeyTTL time.Duration, now time.Time, keysPerAccount int64) (int, int, error)

ManageAccountKeys maintains or removes keys on a clean-up cycle. Returns: remaining keys for account, removed keys for account, and error.

func (*MockAccountManager) RemoveServiceAccount added in v0.8.4

func (m *MockAccountManager) RemoveServiceAccount(ctx context.Context, project, accountID string) error

RemoveServiceAccount removes a service account related to the given project.

type MockAccountManagerEntry added in v0.8.4

type MockAccountManagerEntry struct {
	Call           string
	AccountID      string
	Project        string
	TTL            time.Duration
	MaxKeyTTL      time.Duration
	Now            time.Time
	KeysPerAccount int64
}

MockAccountManagerEntry represents a call to an account management endpoint

type MockTokenCreator

type MockTokenCreator struct {
	// contains filtered or unexported fields
}

MockTokenCreator provides a token creator implementation for testing.

func NewMockTokenCreator

func NewMockTokenCreator(includeParams bool) *MockTokenCreator

NewMockTokenCreator creates a mock ResourceTokenCreator.

func (*MockTokenCreator) Calls

func (*MockTokenCreator) DeleteTokens

func (m *MockTokenCreator) DeleteTokens(ctx context.Context, project, id string, names []string) error

DeleteTokens removes tokens belonging to 'id' with given names. If 'names' is empty, delete all tokens belonging to 'id'.

func (*MockTokenCreator) GetTokenMetadata

func (m *MockTokenCreator) GetTokenMetadata(ctx context.Context, project, id, name string) (*cpb.TokenMetadata, error)

GetTokenMetadata returns an access token based on its name.

func (*MockTokenCreator) ListTokenMetadata

func (m *MockTokenCreator) ListTokenMetadata(ctx context.Context, project, id string) ([]*cpb.TokenMetadata, error)

ListTokenMetadata returns a list of outstanding access tokens.

func (*MockTokenCreator) MintTokenWithTTL

func (m *MockTokenCreator) MintTokenWithTTL(ctx context.Context, id string, ttl, maxTTL time.Duration, numKeys int, params *ResourceTokenCreationParams) (*ResourceTokenResult, error)

MintTokenWithTTL returns an account and a resource token for resource accessing.

func (*MockTokenCreator) RegisterAccountProject

func (m *MockTokenCreator) RegisterAccountProject(project string, tx storage.Tx) error

RegisterAccountProject registers account hosting project in key garbage collector.

func (*MockTokenCreator) UnregisterAccountProject added in v0.8.4

func (m *MockTokenCreator) UnregisterAccountProject(project string, tx storage.Tx) error

UnregisterAccountProject (eventually) removes a project from the active state, and allows cleanup work to be performed.

func (*MockTokenCreator) UpdateSettings added in v0.8.4

func (m *MockTokenCreator) UpdateSettings(maxRequestedTTL time.Duration, keysPerAccount int, tx storage.Tx) error

UpdateSettings alters resource management settings.

type MockTokenCreatorEntry

type MockTokenCreatorEntry struct {
	AccountID string
	TokenID   string
	TTL       time.Duration
	MaxTTL    time.Duration
	NumKeys   int
	Params    ResourceTokenCreationParams
	IssuedAt  int64
	Expires   int64
	Token     string
}

type ResourceTokenCreationParams

type ResourceTokenCreationParams struct {
	AccountProject string
	Items          []map[string]string
	Roles          []string
	Scopes         []string
	TokenFormat    string
	BillingProject string
}

ResourceTokenCreationParams provides information on a set of items to perform an action upon.

type ResourceTokenCreator

type ResourceTokenCreator interface {

	// RegisterAccountProject registers account hosting project in key garbage collector.
	RegisterAccountProject(project string, tx storage.Tx) error

	// UnregisterAccountProject (eventually) removes a project from the active state, and allows cleanup work to be performed.
	UnregisterAccountProject(project string, tx storage.Tx) error

	// UpdateSettings alters resource management settings.
	UpdateSettings(maxRequestedTTL time.Duration, keysPerAccount int, tx storage.Tx) error

	// MintTokenWithTTL returns an account and a newly minted resource token for resource accessing.
	MintTokenWithTTL(ctx context.Context, id string, ttl, maxTTL time.Duration, numKeys int, params *ResourceTokenCreationParams) (*ResourceTokenResult, error)

	// GetTokenMetadata returns an access token based on its name.
	GetTokenMetadata(ctx context.Context, project, id, name string) (*cpb.TokenMetadata, error)

	// ListTokenMetadata returns a list of outstanding access tokens.
	ListTokenMetadata(ctx context.Context, project, id string) ([]*cpb.TokenMetadata, error)

	// DeleteTokens removes tokens belonging to 'id' with given names.
	// If 'names' is empty, delete all tokens belonging to 'id'.
	DeleteTokens(ctx context.Context, project, id string, names []string) error
}

ResourceTokenCreator abstracts token creation for resource accessing in cloud platforms. This refers to Service Account Warehouses (SAWs) in GCP and our communication.

type ResourceTokenResult

type ResourceTokenResult struct {
	Account    string
	Token      string
	AccountKey string
	Format     string
}

ResourceTokenResult is returned from GetTokenWithTTL().

Jump to

Keyboard shortcuts

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