client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ProwLabelSeparator formats labels key:val pairs into `{key} ::: {val}`
	// The separator was arbitrarily selected.
	ProwLabelSeparator = " ::: "
)

Variables

This section is empty.

Functions

func GetProwLabels

func GetProwLabels(bld *cloudbuildpb.Build) map[string]string

GetProwLabels gets labels from cloud build struct, simulating k8s pods labels format of map[string]string.

func KvPairFromProwLabel

func KvPairFromProwLabel(tag string) (key, val string)

KvPairFromProwLabel trims label into key:val pairs. returns empty string as value if the label is not formatted as prow label format.

func ProwLabel

func ProwLabel(key, val string) string

ProwLabel formats labels key:val pairs into `{key} ::: {val}`. These labels will be parsed by prow controller manager for mapping a GCB build to a prow job.

Types

type Client

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

Client wraps native cloudbuild client.

func NewClient

func NewClient(ctx context.Context, credentialFile string) (*Client, error)

NewClient creates a new Client, with optional credentialFile.

func (*Client) CancelBuild

func (c *Client) CancelBuild(ctx context.Context, project, id string) (*cloudbuildpb.Build, error)

CancelBuild cancels build and wait for it.

func (*Client) CreateBuild

func (c *Client) CreateBuild(ctx context.Context, project string, bld *cloudbuildpb.Build) (*cloudbuildpb.Build, error)

CreateBuild creates build and wait for the operation to complete.

func (*Client) GetBuild

func (c *Client) GetBuild(ctx context.Context, project, id string) (*cloudbuildpb.Build, error)

GetBuild gets build by GCB build id.

func (*Client) ListBuildsByTag

func (c *Client) ListBuildsByTag(ctx context.Context, project string, tags []string) ([]*cloudbuildpb.Build, error)

ListBuildsByTag lists builds by GCB tags.

This will be used by prow for listing builds triggered by prow, for example `created-by-prow ::: true`.

type Operator

type Operator interface {
	GetBuild(ctx context.Context, project, id string) (*cloudbuildpb.Build, error)
	ListBuildsByTag(ctx context.Context, project string, tags []string) ([]*cloudbuildpb.Build, error)
	CreateBuild(ctx context.Context, project string, bld *cloudbuildpb.Build) (*cloudbuildpb.Build, error)
	CancelBuild(ctx context.Context, project, id string) (*cloudbuildpb.Build, error)
}

Operator is the interface that's highly recommended to be used by any package that imports current package. Unit test can be carried out with a mock implemented under fake of current package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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