Documentation

Overview

Package access is DEPRECATED.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(host string, client *http.Client) access.AccessClient

NewClient returns a new AccessClient which can be used to talk to buildbucket's access API.

Types

type Action

type Action uint32

Action is a kind of RPC that can be ACLed.

const (
	// AddBuild: Schedule a build.
	AddBuild Action = 1 << iota

	// ViewBuild: Get information about a build.
	ViewBuild

	// LeaseBuild: Lease a build for execution. Normally done by build systems.
	LeaseBuild

	// CancelBuild: Cancel an existing build. Does not require a lease key.
	CancelBuild

	// ResetBuild: Unlease and reset state of an existing build. Normally done by admins.
	ResetBuild

	// SearchBuilds: Search for builds or get a list of scheduled builds.
	SearchBuilds

	// ReadACL: View bucket ACLs.
	ReadACL

	// WriteACL: Change bucket ACLs.
	WriteACL

	// DeleteScheduledBuilds: Delete all scheduled builds from a bucket.
	DeleteScheduledBuilds

	// AccessBucket: Know about bucket existence and read its info.
	AccessBucket

	// PauseBucket: Pause builds for a given bucket.
	PauseBucket

	// SetNextNumber: Set the number for the next build in a builder.
	SetNextNumber
)

func ParseAction

func ParseAction(action string) (Action, error)

ParseAction parses the action name into an.

func (*Action) MarshalBinary

func (a *Action) MarshalBinary() ([]byte, error)

MarshalBinary encodes the Action as bytes.

func (Action) String

func (a Action) String() string

String returns the action name as a string.

func (*Action) UnmarshalBinary

func (a *Action) UnmarshalBinary(blob []byte) error

UnmarshalBinary decodes an Action from bytes.

type Permissions

type Permissions map[string]Action

Permissions represents a set of permitted actions for a set of buckets.

Since Action is encoded as bits, the Action here is actually the bitwise OR of all available Actions for a particular bucket.

func BucketPermissions

func BucketPermissions(c context.Context, client access.AccessClient, buckets []string) (Permissions, time.Duration, error)

BucketPermissions retrieves permitted actions for a set of buckets, for the identity specified in the client. It also returns the duration for which the client is allowed to cache the permissions.

func (Permissions) Can

func (p Permissions) Can(bucket string, action Action) bool

Can checks whether an Action is allowed for a given bucket.

func (Permissions) FromProto

func (p Permissions) FromProto(resp *access.PermittedActionsResponse) error

FromProto populates a Permissions from an access.PermittedActionsResponse.

func (Permissions) ToProto

func (p Permissions) ToProto(validTime time.Duration) *access.PermittedActionsResponse

ToProto converts a Permissions into a PermittedActionsResponse.

type TestClient

type TestClient struct {
	*access.PermittedActionsResponse
	*access.DescriptionResponse
	Error                    error
	PermittedActionsRequests []*access.PermittedActionsRequest
}

TestClient implements an access.AccessClient with stubs for use in testing.

func (*TestClient) Description

func (c *TestClient) Description(_ context.Context, _ *empty.Empty, _ ...grpc.CallOption) (*access.DescriptionResponse, error)

Description implements the AccessClient interface.

func (*TestClient) PermittedActions

func (c *TestClient) PermittedActions(_ context.Context, req *access.PermittedActionsRequest, _ ...grpc.CallOption) (*access.PermittedActionsResponse, error)

PermittedActions implements the AccessClient interface.