github.com/munnerz/test-infra@v0.0.0-20190108210205-ce3d181dc989/prow/kube/prowjob.go (about)

     1  /*
     2  Copyright 2018 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package kube
    18  
    19  import (
    20  	"k8s.io/test-infra/prow/apis/prowjobs/v1"
    21  )
    22  
    23  // The following are aliases to aid in the refactoring while we move
    24  // API definitions under prow/apis/
    25  
    26  // ProwJobType specifies how the job is triggered.
    27  type ProwJobType = v1.ProwJobType
    28  
    29  // ProwJobState specifies whether the job is running
    30  type ProwJobState = v1.ProwJobState
    31  
    32  // ProwJobAgent specifies the controller (such as plank or jenkins-agent) that runs the job.
    33  type ProwJobAgent = v1.ProwJobAgent
    34  
    35  // Various job types.
    36  const (
    37  	// PresubmitJob means it runs on unmerged PRs.
    38  	PresubmitJob = v1.PresubmitJob
    39  	// PostsubmitJob means it runs on each new commit.
    40  	PostsubmitJob = v1.PostsubmitJob
    41  	// Periodic job means it runs on a time-basis, unrelated to git changes.
    42  	PeriodicJob = v1.PeriodicJob
    43  	// BatchJob tests multiple unmerged PRs at the same time.
    44  	BatchJob = v1.BatchJob
    45  )
    46  
    47  // Various job states.
    48  const (
    49  	// TriggeredState means the job has been created but not yet scheduled.
    50  	TriggeredState = v1.TriggeredState
    51  	// PendingState means the job is scheduled but not yet running.
    52  	PendingState = v1.PendingState
    53  	// SuccessState means the job completed without error (exit 0)
    54  	SuccessState = v1.SuccessState
    55  	// FailureState means the job completed with errors (exit non-zero)
    56  	FailureState = v1.FailureState
    57  	// AbortedState means prow killed the job early (new commit pushed, perhaps).
    58  	AbortedState = v1.AbortedState
    59  	// ErrorState means the job could not schedule (bad config, perhaps).
    60  	ErrorState = v1.ErrorState
    61  )
    62  
    63  const (
    64  	// KubernetesAgent means prow will create a pod to run this job.
    65  	KubernetesAgent = v1.KubernetesAgent
    66  	// JenkinsAgent means prow will schedule the job on jenkins.
    67  	JenkinsAgent = v1.JenkinsAgent
    68  )
    69  
    70  const (
    71  	// CreatedByProw is added on resources created by prow.
    72  	// Since resources often live in another cluster/namespace,
    73  	// the k8s garbage collector would immediately delete these
    74  	// resources
    75  	// TODO: Namespace this label.
    76  	CreatedByProw = "created-by-prow"
    77  	// ProwJobTypeLabel is added in resources created by prow and
    78  	// carries the job type (presubmit, postsubmit, periodic, batch)
    79  	// that the pod is running.
    80  	ProwJobTypeLabel = "prow.k8s.io/type"
    81  	// ProwJobIDLabel is added in resources created by prow and
    82  	// carries the ID of the ProwJob that the pod is fulfilling.
    83  	// We also name resources after the ProwJob that spawned them but
    84  	// this allows for multiple resources to be linked to one
    85  	// ProwJob.
    86  	ProwJobIDLabel = "prow.k8s.io/id"
    87  	// ProwJobAnnotation is added in resources created by prow and
    88  	// carries the name of the job that the pod is running. Since
    89  	// job names can be arbitrarily long, this is added as
    90  	// an annotation instead of a label.
    91  	ProwJobAnnotation = "prow.k8s.io/job"
    92  	// OrgLabel is added in resources created by prow and
    93  	// carries the org associated with the job, eg kubernetes-sigs.
    94  	OrgLabel = "prow.k8s.io/refs.org"
    95  	// RepoLabel is added in resources created by prow and
    96  	// carries the repo associated with the job, eg test-infra
    97  	RepoLabel = "prow.k8s.io/refs.repo"
    98  	// PullLabel is added in resources created by prow and
    99  	// carries the PR number associated with the job, eg 321.
   100  	PullLabel = "prow.k8s.io/refs.pull"
   101  )
   102  
   103  // ProwJob contains the spec as well as runtime metadata.
   104  type ProwJob = v1.ProwJob
   105  
   106  // ProwJobSpec configures the details of the prow job.
   107  //
   108  // Details include the podspec, code to clone, the cluster it runs
   109  // any child jobs, concurrency limitations, etc.
   110  type ProwJobSpec = v1.ProwJobSpec
   111  
   112  // DecorationConfig specifies how to augment pods.
   113  //
   114  // This is primarily used to provide automatic integration with gubernator
   115  // and testgrid.
   116  type DecorationConfig = v1.DecorationConfig
   117  
   118  // UtilityImages holds pull specs for the utility images
   119  // to be used for a job
   120  type UtilityImages = v1.UtilityImages
   121  
   122  // PathStrategy specifies minutia about how to construct the url.
   123  // Usually consumed by gubernator/testgrid.
   124  const (
   125  	PathStrategyLegacy   = v1.PathStrategyLegacy
   126  	PathStrategySingle   = v1.PathStrategySingle
   127  	PathStrategyExplicit = v1.PathStrategyExplicit
   128  )
   129  
   130  // GCSConfiguration holds options for pushing logs and
   131  // artifacts to GCS from a job.
   132  type GCSConfiguration = v1.GCSConfiguration
   133  
   134  // ProwJobStatus provides runtime metadata, such as when it finished, whether it is running, etc.
   135  type ProwJobStatus = v1.ProwJobStatus
   136  
   137  // Pull describes a pull request at a particular point in time.
   138  type Pull = v1.Pull
   139  
   140  // Refs describes how the repo was constructed.
   141  type Refs = v1.Refs