Documentation
¶
Index ¶
- Constants
- func GetLocalArtifactsDir() string
- func Initialize(serviceAccount string) error
- func IsCI() bool
- type Build
- func (b *Build) GetArtifacts() []string
- func (b *Build) GetArtifactsDir() string
- func (b *Build) GetBuildLogPath() string
- func (b *Build) GetFinishTime() (int64, error)
- func (b *Build) GetStartTime() (int64, error)
- func (b *Build) IsFinished() bool
- func (b *Build) IsStarted() bool
- func (b *Build) ParseLog(checkLog func(s []string) *string) ([]string, error)
- func (b *Build) ReadFile(relPath string) ([]byte, error)
- type EnvConfig
- type Finished
- type Job
- type Metadata
- type Started
Constants ¶
const ( // BucketName is the gcs bucket for all knative builds BucketName = "knative-prow" // Latest is the filename storing latest build number Latest = "latest-build.txt" // BuildLog is the filename for build log BuildLog = "build-log.txt" // StartedJSON is the json file containing build started info StartedJSON = "started.json" // FinishedJSON is the json file containing build finished info FinishedJSON = "finished.json" // ArtifactsDir is the dir containing artifacts ArtifactsDir = "artifacts" // PresubmitJob means it runs on unmerged PRs. PresubmitJob = "presubmit" // PostsubmitJob means it runs on each new commit. PostsubmitJob = "postsubmit" // PeriodicJob means it runs on a time-basis, unrelated to git changes. PeriodicJob = "periodic" // BatchJob tests multiple unmerged PRs at the same time. BatchJob = "batch" )
Variables ¶
This section is empty.
Functions ¶
func GetLocalArtifactsDir ¶
func GetLocalArtifactsDir() string
GetLocalArtifactsDir gets the artifacts directory where prow looks for artifacts. By default, it will look at the env var ARTIFACTS.
func Initialize ¶
Initialize wraps gcs authentication, have to be invoked before any other functions
Types ¶
type Build ¶
type Build struct {
JobName string
StoragePath string
BuildID int
Bucket string // optional
StartTime *int64
FinishTime *int64
}
Build points to a build stored under a particular gcs path.
func (*Build) GetArtifacts ¶
GetArtifacts gets gcs path for all artifacts of current build
func (*Build) GetArtifactsDir ¶
GetArtifactsDir gets gcs path for artifacts of current build
func (*Build) GetBuildLogPath ¶
GetBuildLogPath gets "build-log.txt" path for current build
func (*Build) GetFinishTime ¶
GetFinishTime gets finished timestamp of a build, returning -1 if the build didn't finish or if it failed to get the timestamp
func (*Build) GetStartTime ¶
GetStartTime gets started timestamp of a build, returning -1 if the build didn't start or if it failed to get the timestamp
func (*Build) IsFinished ¶
IsFinished check if build has finished by looking at "finished.json" file
type EnvConfig ¶
type EnvConfig struct {
CI bool
Artifacts string
JobName string `split_words:"true"`
JobType string `split_words:"true"`
JobSpec string `split_words:"true"`
BuildID string `envconfig:"BUILD_ID"`
ProwJobID string `envconfig:"PROW_JOB_ID"`
RepoOwner string `split_words:"true"`
RepoName string `split_words:"true"`
PullBaseRef string `split_words:"true"`
PullBaseSha string `split_words:"true"`
PullRefs string `split_words:"true"`
PullNumber uint `split_words:"true"`
PullPullSha string `split_words:"true"`
}
EnvConfig consists of all the environment variables that can be set in a Prow job, check https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md#job-environment-variables for more information.
func GetEnvConfig ¶
GetEnvConfig returns values of all the environment variables that can be possibly set in a Prow job.
type Finished ¶
type Finished struct {
// Timestamp is epoch seconds
Timestamp int64 `json:"timestamp"`
Passed bool `json:"passed"`
JobVersion string `json:"job-version"`
Metadata Metadata `json:"metadata"`
}
Finished holds the finished.json values of the build
type Job ¶
type Job struct {
Name string
Type string
Bucket string // optional
Org string // optional
Repo string // optional
StoragePath string // optional
PullID int // only for Presubmit jobs
Builds []Build // optional
}
Job struct represents a job directory in gcs. gcs job StoragePath will be derived from Type if it's defined,
func NewJob ¶
NewJob creates new job struct pullID is only saved by Presubmit job for determining StoragePath
func (*Job) GetBuildIDs ¶
GetBuildIDs gets all build IDs from this job on gcs, scans all direct child of gcs directory for job, keeps the ones that can be parsed as integer
func (*Job) GetBuilds ¶
GetBuilds gets all builds from this job on gcs, precomputes start/finish time of builds by parsing "Started.json" and "Finished.json" on gcs, could be very expensive if there are large number of builds
func (*Job) GetFinishedBuilds ¶
GetFinishedBuilds gets all builds that have finished, by looking at existence of "finished.json" file
func (*Job) GetLatestBuildNumber ¶
GetLatestBuildNumber gets the latest build number for job
func (*Job) GetLatestBuilds ¶
GetLatestBuilds get latest builds from gcs, sort by start time from newest to oldest, will return count number of builds
func (*Job) NewBuild ¶
NewBuild gets build struct based on job info No gcs operation is performed by this function
func (*Job) PathExists ¶
PathExists checks if the storage path of a job exists in gcs or not
type Started ¶
type Started struct {
Timestamp int64 `json:"timestamp"` // epoch seconds
RepoVersion string `json:"repo-version"`
Node string `json:"node"`
Pull string `json:"pull"`
Repos map[string]string `json:"repos"` // {repo: branch_or_pull} map
}
Started holds the started.json values of the build.