Documentation ¶
Overview ¶
Package gcs provides utilities for interacting with GCS.
This includes basic CRUD operations. It is primarily focused on reading prow build results uploaded to GCS.
Index ¶
- Constants
- func ClientWithCreds(ctx context.Context, creds ...string) (*storage.Client, error)
- func DownloadGrid(ctx context.Context, opener Opener, path Path) (*statepb.Grid, error)
- func LeastRecentlyUpdated(ctx context.Context, log logrus.FieldLogger, client Stater, paths []Path) map[Path]int64
- func MarshalGrid(grid *statepb.Grid) ([]byte, error)
- func Sort(builds []Build)
- func Touch(ctx context.Context, client ConditionalClient, path Path, generation int64, ...) error
- func Upload(ctx context.Context, client *storage.Client, path Path, buf []byte, ...) error
- func UploadHandle(ctx context.Context, handle *storage.ObjectHandle, buf []byte, ...) error
- type Build
- func (build Build) Artifacts(ctx context.Context, lister Lister, artifacts chan<- string) error
- func (build Build) Build() string
- func (build Build) Finished(ctx context.Context, opener Opener) (*Finished, error)
- func (build Build) Job() string
- func (build Build) PodInfo(ctx context.Context, opener Opener) (*PodInfo, error)
- func (build Build) Started(ctx context.Context, opener Opener) (*Started, error)
- func (build Build) String() string
- func (build Build) Suites(parent context.Context, opener Opener, artifacts <-chan string, ...) error
- type Client
- type ConditionalClient
- type Copier
- type Downloader
- type Error
- type Finished
- type Iterator
- type Lister
- type Opener
- type Path
- func (g Path) Bucket() string
- func (g Path) MarshalJSON() ([]byte, error)
- func (g Path) Object() string
- func (g Path) ResolveReference(ref *url.URL) (*Path, error)
- func (g *Path) Set(v string) error
- func (g *Path) SetURL(u *url.URL) error
- func (g Path) String() string
- func (g Path) URL() url.URL
- func (g *Path) UnmarshalJSON(buf []byte) error
- type PodInfo
- type Started
- type Stater
- type SuitesMeta
- type Uploader
Constants ¶
const ( // DefaultACL for this upload DefaultACL = false // PublicRead ACL for this upload. PublicRead = true )
const ( // MissingPodInfo appears when builds complete without a podinfo.json report. MissingPodInfo = "podinfo.json not found, please install prow's GCS reporter" // NoPodUtils appears when builds run without decoration. NoPodUtils = "not using decoration, please set decorate: true on prowjob" )
Variables ¶
This section is empty.
Functions ¶
func ClientWithCreds ¶
ClientWithCreds returns a storage client, optionally authenticated with the specified .json creds
func DownloadGrid ¶ added in v0.0.55
DownloadGrid downloads and decompresses a grid from the specified path.
func LeastRecentlyUpdated ¶ added in v0.0.63
func LeastRecentlyUpdated(ctx context.Context, log logrus.FieldLogger, client Stater, paths []Path) map[Path]int64
LeastRecentlyUpdated sorts paths by their update timestamp, noting generations and any errors.
func MarshalGrid ¶ added in v0.0.70
MarshalGrid serializes a state proto into zlib-compressed bytes.
func Sort ¶ added in v0.0.39
func Sort(builds []Build)
Sort the builds by monotonically decreasing original prefix base name.
In other words,
gs://b/1 gs://a/5 gs://c/10
becomes:
gs://c/10 gs://a/5 gs://b/1
func Touch ¶ added in v0.0.63
func Touch(ctx context.Context, client ConditionalClient, path Path, generation int64, genZero []byte) error
Touch attempts to win an update of the object.
Cloud copies the current object to itself when the object already exists. Otherwise uploads genZero bytes.
func Upload ¶
func Upload(ctx context.Context, client *storage.Client, path Path, buf []byte, worldReadable bool, cacheControl string) error
Upload writes bytes to the specified Path by converting the client and path into an ObjectHandle.
func UploadHandle ¶ added in v0.0.34
func UploadHandle(ctx context.Context, handle *storage.ObjectHandle, buf []byte, worldReadable bool, cacheControl string) error
UploadHandle writes bytes to the specified ObjectHandle
Types ¶
type Build ¶
type Build struct { Path Path // contains filtered or unexported fields }
Build points to a build stored under a particular gcs prefix.
func ListBuilds ¶
ListBuilds returns the array of builds under path, sorted in monotonically decreasing order.
func (Build) Artifacts ¶
Artifacts writes the object name of all paths under the build's artifact dir to the output channel.
func (Build) Suites ¶
func (build Build) Suites(parent context.Context, opener Opener, artifacts <-chan string, suites chan<- SuitesMeta) error
Suites takes a channel of artifact names, parses those representing junit suites, writing the result to the suites channel.
Note that junit suites are parsed in parallel, so there are no guarantees about suites ordering.
type Client ¶ added in v0.0.16
type Client interface { Uploader Downloader Stater Copier }
A Client can upload, download and stat.
type ConditionalClient ¶ added in v0.0.34
type ConditionalClient interface { Client // If specifies conditions on the object read from and/or written to. If(read, write *storage.Conditions) ConditionalClient }
A ConditionalClient can limit actions to those matching conditions.
func NewClient ¶ added in v0.0.16
func NewClient(client *storage.Client) ConditionalClient
NewClient returns a flexible (local or GCS) storage client.
func NewGCSClient ¶ added in v0.0.53
func NewGCSClient(client *storage.Client) ConditionalClient
NewGCSClient returns a GCSUploadClient for the storage.Client.
func NewLocalClient ¶ added in v0.0.53
func NewLocalClient() ConditionalClient
NewLocalClient returns a GCSUploadClient for the storage.Client.
type Copier ¶ added in v0.0.34
type Copier interface { // Copy an object to the specified path Copy(ctx context.Context, from, to Path) error }
A Copier can cloud copy an object to a new location.
type Downloader ¶ added in v0.0.16
Downloader can list files and open them for reading.
type Error ¶ added in v0.0.59
type Error struct { Path // contains filtered or unexported fields }
Error wraps an error in an associated Path.
type Finished ¶
type Finished struct { metadata.Finished // Running when the job hasn't finished and finished.json doesn't exist Running bool }
Finished holds finished.json data.
type Iterator ¶ added in v0.0.16
type Iterator interface {
Next() (*storage.ObjectAttrs, error)
}
An Iterator returns the attributes of the listed objects or an iterator.Done error.
type Lister ¶ added in v0.0.16
type Lister interface {
Objects(ctx context.Context, prefix Path, delimiter, start string) Iterator
}
A Lister returns objects under a prefix.
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path parses gs://bucket/obj urls
func (Path) MarshalJSON ¶ added in v0.0.66
MarshalJSON encodes Path as a string
func (Path) ResolveReference ¶
ResolveReference returns the path relative to the current path
func (*Path) UnmarshalJSON ¶ added in v0.0.66
MarshalJSON decodes a string into Path