Version: v0.0.0-...-51f9457 Latest Latest

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 13 Imported by: 0



Package access is DEPRECATED.



This section is empty.


This section is empty.


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.


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.

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

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

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

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

	// ReadACL: View bucket ACLs.

	// WriteACL: Change bucket ACLs.

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

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

	// PauseBucket: Pause builds for a given bucket.

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

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

ToProto converts a Permissions into a PermittedActionsResponse.

type TestClient

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

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

func (*TestClient) Description

Description implements the AccessClient interface.

func (*TestClient) PermittedActions

PermittedActions implements the AccessClient interface.

Jump to

Keyboard shortcuts

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