utils

package
v0.0.0-...-909f21c Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GCSListAPIHost is the host of the api for a bucket
	GCSListAPIHost = "www.googleapis.com"
	// GCSBucketHost is the host for GCS bucket directory requests
	GCSBucketHost = "storage.googleapis.com"
)
View Source
const (
	// KubekinsBucket is the name of the kubekins bucket
	KubekinsBucket = "kubernetes-jenkins"
	// LogDir is the directory of kubekins
	LogDir = "logs"
	// PullLogDir is the directory of the pr builder jenkins
	PullLogDir = "pr-logs"
	// PullKey is a string to look for in a job name to figure out if it's
	// a pull (presubmit) job.
	PullKey = "pull"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

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

Bucket represents a GCS bucket. It will craft file and list requests for you.

func NewBucket

func NewBucket(name string) *Bucket

NewBucket constructs a new bucket pointing at the default URLs.

func NewTestBucket

func NewTestBucket(name string, host string) *Bucket

NewTestBucket constructs a new bucket pointing at a specific host.

func (*Bucket) ExpandListURL

func (b *Bucket) ExpandListURL(pathElements ...interface{}) *url.URL

ExpandListURL produces the URL for a list API query which will list files enclosed by the provided path. Note that there's currently no way to get a path that ends in '/'.

func (*Bucket) ExpandPathURL

func (b *Bucket) ExpandPathURL(pathElements ...interface{}) *url.URL

ExpandPathURL turns the given path into a complete URL, good for accessing a file.

func (*Bucket) List

func (b *Bucket) List(pathElements ...interface{}) ([]string, error)

List returns a list of all files inside the given path. The returned file name included the complete path from bucket root

func (*Bucket) ReadFile

func (b *Bucket) ReadFile(pathElements ...interface{}) (*http.Response, error)

ReadFile assembles the path and initiates a read operation.

type FinishedFile

type FinishedFile struct {
	Result    string `json:"result"`
	Timestamp uint64 `json:"timestamp"`
}

FinishedFile is a type in which we store test result in GCS as finished.json

type StartedFile

type StartedFile struct {
	Version     string `json:"version"`
	Timestamp   uint64 `json:"timestamp"`
	JenkinsNode string `json:"jenkins-node"`
}

StartedFile is a type in which we store test starting informatio in GCS as started.json

type Utils

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

Utils is a struct handling all communication with a given bucket

func NewTestUtils

func NewTestUtils(bucket, directory, url string) *Utils

NewTestUtils returnes new Utils struct for a given url pointing to a file server.

func NewUtils

func NewUtils(bucket, directory string) *Utils

NewUtils returnes new Utils struct for a given bucket name and subdirectory

func NewWithPresubmitDetection

func NewWithPresubmitDetection(bucket, directory, presubmitKey, presubmitDirectory string) *Utils

NewWithPresubmitDetection returnes new Utils struct for a given bucket name and subdirectory. If a job name contains the presubmitKey, it will be gotten from the presubmitDirectory and trigger the dereferencing logic.

func (*Utils) CheckFinishedStatus

func (u *Utils) CheckFinishedStatus(job string, buildNumber int) (bool, error)

CheckFinishedStatus reads the finished.json file for a given job and build number. It returns true if the result stored there is success, and false otherwise.

func (*Utils) CheckStartedStatus

func (u *Utils) CheckStartedStatus(job string, buildNumber int) (*StartedFile, error)

CheckStartedStatus reads the started.json file for a given job and build number. It returns true if the result stored there is success, and false otherwise.

func (*Utils) GetFileFromJenkinsGoogleBucket

func (u *Utils) GetFileFromJenkinsGoogleBucket(job string, buildNumber int, path string) (*http.Response, error)

GetFileFromJenkinsGoogleBucket reads data from Google project's GCS bucket for the given job and buildNumber. Returns a response with file stored under a given (relative) path or an error.

func (*Utils) GetLastestBuildNumberFromJenkinsGoogleBucket

func (u *Utils) GetLastestBuildNumberFromJenkinsGoogleBucket(job string) (int, error)

GetLastestBuildNumberFromJenkinsGoogleBucket reads a the number of last completed build of the given job from the Google project's GCS bucket.

func (*Utils) GetPathToJenkinsGoogleBucket

func (u *Utils) GetPathToJenkinsGoogleBucket(job string, buildNumber int) string

GetPathToJenkinsGoogleBucket returns a GCS path containing the artifacts for a given job and buildNumber. This only formats the path. It doesn't include a host or protocol necessary for a full URI. Note: the purpose of this function was to allow us to change the host (to gubernator) without breaking detection of old links.

func (*Utils) ListFilesInBuild

func (u *Utils) ListFilesInBuild(job string, buildNumber int, prefix string) ([]string, error)

ListFilesInBuild takes build info and list all file names with matching prefix The returned file name included the complete path from bucket root

func (*Utils) ListFilesWithPrefix

func (u *Utils) ListFilesWithPrefix(prefix string) ([]string, error)

ListFilesWithPrefix returns all files with matching prefix in the bucket The returned file name included the complete path from bucket root

Jump to

Keyboard shortcuts

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