kubesphere.io/api@v0.0.0-20231107125330-c9a03957060c/devops/v1alpha1/s2irun_types.go (about) 1 /* 2 Copyright 2020 The KubeSphere 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 v1alpha1 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 ) 22 23 // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! 24 // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. 25 26 const ( 27 ResourceKindS2iRun = "S2iRun" 28 ResourceSingularS2iRun = "s2irun" 29 ResourcePluralS2iRun = "s2iruns" 30 ) 31 32 // S2iRunSpec defines the desired state of S2iRun 33 type S2iRunSpec struct { 34 //BuilderName specify the name of s2ibuilder, required 35 BuilderName string `json:"builderName"` 36 //BackoffLimit limits the restart count of each s2irun. Default is 0 37 BackoffLimit int32 `json:"backoffLimit,omitempty"` 38 //SecondsAfterFinished if is set and greater than zero, and the job created by s2irun become successful or failed , the job will be auto deleted after SecondsAfterFinished 39 SecondsAfterFinished int32 `json:"secondsAfterFinished,omitempty"` 40 //NewTag override the default tag in its s2ibuilder, image name cannot be changed. 41 NewTag string `json:"newTag,omitempty"` 42 //NewRevisionId override the default NewRevisionId in its s2ibuilder. 43 NewRevisionId string `json:"newRevisionId,omitempty"` 44 //NewSourceURL is used to download new binary artifacts 45 NewSourceURL string `json:"newSourceURL,omitempty"` 46 } 47 48 // S2iRunStatus defines the observed state of S2iRun 49 type S2iRunStatus struct { 50 // StartTime represent when this run began 51 StartTime *metav1.Time `json:"startTime,omitempty" protobuf:"bytes,2,opt,name=startTime"` 52 53 // Represents time when the job was completed. It is not guaranteed to 54 // be set in happens-before order across separate operations. 55 // It is represented in RFC3339 form and is in UTC. 56 // +optional 57 CompletionTime *metav1.Time `json:"completionTime,omitempty" protobuf:"bytes,3,opt,name=completionTime"` 58 // RunState indicates whether this job is done or failed 59 RunState RunState `json:"runState,omitempty"` 60 //LogURL is uesd for external log handler to let user know where is log located in 61 LogURL string `json:"logURL,omitempty"` 62 //KubernetesJobName is the job name in k8s 63 KubernetesJobName string `json:"kubernetesJobName,omitempty"` 64 65 // S2i build result info. 66 S2iBuildResult *S2iBuildResult `json:"s2iBuildResult,omitempty"` 67 // S2i build source info. 68 S2iBuildSource *S2iBuildSource `json:"s2iBuildSource,omitempty"` 69 } 70 71 type S2iBuildResult struct { 72 //ImageName is the name of artifact 73 ImageName string `json:"imageName,omitempty"` 74 //The size in bytes of the image 75 ImageSize int64 `json:"imageSize,omitempty"` 76 // Image ID. 77 ImageID string `json:"imageID,omitempty"` 78 // Image created time. 79 ImageCreated string `json:"imageCreated,omitempty"` 80 // image tags. 81 ImageRepoTags []string `json:"imageRepoTags,omitempty"` 82 // Command for pull image. 83 CommandPull string `json:"commandPull,omitempty"` 84 } 85 86 type S2iBuildSource struct { 87 // SourceURL is url of the codes such as https://github.com/a/b.git 88 SourceUrl string `json:"sourceUrl,omitempty"` 89 // The RevisionId is a branch name or a SHA-1 hash of every important thing about the commit 90 RevisionId string `json:"revisionId,omitempty"` 91 // Binary file Name 92 BinaryName string `json:"binaryName,omitempty"` 93 // Binary file Size 94 BinarySize uint64 `json:"binarySize,omitempty"` 95 96 // // BuilderImage describes which image is used for building the result images. 97 BuilderImage string `json:"builderImage,omitempty"` 98 // Description is a result image description label. The default is no 99 // description. 100 Description string `json:"description,omitempty"` 101 102 // CommitID represents an arbitrary extended object reference in Git as SHA-1 103 CommitID string `json:"commitID,omitempty"` 104 // CommitterName contains the name of the committer 105 CommitterName string `json:"committerName,omitempty"` 106 // CommitterEmail contains the e-mail of the committer 107 CommitterEmail string `json:"committerEmail,omitempty"` 108 } 109 110 // +genclient 111 // +kubebuilder:object:root=true 112 113 // S2iRun is the Schema for the s2iruns API 114 // +k8s:openapi-gen=true 115 // +kubebuilder:subresource:status 116 // +kubebuilder:resource:shortName=s2ir 117 // +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.runState" 118 // +kubebuilder:printcolumn:name="K8sJobName",type="string",JSONPath=".status.kubernetesJobName" 119 // +kubebuilder:printcolumn:name="StartTime",type="date",JSONPath=".status.startTime" 120 // +kubebuilder:printcolumn:name="CompletionTime",type="date",JSONPath=".status.completionTime" 121 // +kubebuilder:printcolumn:name="ImageName",type="string",JSONPath=".status.s2iBuildResult.imageName" 122 type S2iRun struct { 123 metav1.TypeMeta `json:",inline"` 124 metav1.ObjectMeta `json:"metadata,omitempty"` 125 126 Spec S2iRunSpec `json:"spec,omitempty"` 127 Status S2iRunStatus `json:"status,omitempty"` 128 } 129 130 // +kubebuilder:object:root=true 131 132 // S2iRunList contains a list of S2iRun 133 type S2iRunList struct { 134 metav1.TypeMeta `json:",inline"` 135 metav1.ListMeta `json:"metadata,omitempty"` 136 Items []S2iRun `json:"items"` 137 } 138 139 func init() { 140 SchemeBuilder.Register(&S2iRun{}, &S2iRunList{}) 141 }