-
Notifications
You must be signed in to change notification settings - Fork 345
/
build_types.go
313 lines (277 loc) · 11.8 KB
/
build_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// Important: Run "make generate-deepcopy" to regenerate code after modifying this file
// BuildSpec defines the list of tasks to be execute for a Build. From Camel K version 2, it would be more appropriate
// to think it as pipeline.
type BuildSpec struct {
// The sequence of tasks (pipeline) to be performed.
Tasks []Task `json:"tasks,omitempty"`
// The configuration that should be used to perform the Build.
// Deprecated: no longer in use in Camel K 2 - maintained for backward compatibility
Configuration BuildConfiguration `json:"configuration,omitempty"`
// The container image to be used to run the build.
// Deprecated: no longer in use in Camel K 2 - maintained for backward compatibility
ToolImage string `json:"toolImage,omitempty"`
// The namespace where to run the builder Pod (must be the same of the operator in charge of this Build reconciliation).
// Deprecated: no longer in use in Camel K 2 - maintained for backward compatibility
BuilderPodNamespace string `json:"operatorNamespace,omitempty"`
// Timeout defines the Build maximum execution duration.
// The Build deadline is set to the Build start time plus the Timeout duration.
// If the Build deadline is exceeded, the Build context is canceled,
// and its phase set to BuildPhaseFailed.
// +kubebuilder:validation:Format=duration
Timeout metav1.Duration `json:"timeout,omitempty"`
// the maximum amount of parallel running builds started by this operator instance
// Deprecated: no longer in use in Camel K 2 - maintained for backward compatibility
MaxRunningBuilds int32 `json:"maxRunningBuilds,omitempty"`
}
// Task represents the abstract task. Only one of the task should be configured to represent the specific task chosen.
type Task struct {
// Application building
// a BuilderTask, used to generate and build the project
Builder *BuilderTask `json:"builder,omitempty"`
// User customizable task execution. These are executed after the build and before the package task.
Custom *UserTask `json:"custom,omitempty"`
// Application pre publishing
// a PackageTask, used to package the project
Package *BuilderTask `json:"package,omitempty"`
// Application Publishing
// a BuildahTask, for Buildah strategy
// Deprecated: use spectrum, jib, s2i or a custom publishing strategy instead
Buildah *BuildahTask `json:"buildah,omitempty"`
// a KanikoTask, for Kaniko strategy
// Deprecated: use spectrum, jib, s2i or a custom publishing strategy instead
Kaniko *KanikoTask `json:"kaniko,omitempty"`
// a SpectrumTask, for Spectrum strategy
Spectrum *SpectrumTask `json:"spectrum,omitempty"`
// a S2iTask, for S2I strategy
S2i *S2iTask `json:"s2i,omitempty"`
// a JibTask, for Jib strategy
Jib *JibTask `json:"jib,omitempty"`
}
// BaseTask is a base for the struct hierarchy.
type BaseTask struct {
// name of the task
Name string `json:"name,omitempty"`
// The configuration that should be used to perform the Build.
Configuration BuildConfiguration `json:"configuration,omitempty"`
}
// BuilderTask is the generic task in charge of building the application image.
type BuilderTask struct {
BaseTask `json:",inline"`
// the base image layer
BaseImage string `json:"baseImage,omitempty"`
// the configuration required for the runtime application
Runtime RuntimeSpec `json:"runtime,omitempty"`
// the list of dependencies to use for this build
Dependencies []string `json:"dependencies,omitempty"`
// the list of steps to execute (see pkg/builder/)
Steps []string `json:"steps,omitempty"`
// the configuration required by Maven for the application build phase
Maven MavenBuildSpec `json:"maven,omitempty"`
// workspace directory to use
BuildDir string `json:"buildDir,omitempty"`
// the sources to add at build time
Sources []SourceSpec `json:"sources,omitempty"`
}
// MavenBuildSpec defines the Maven configuration plus additional repositories to use.
type MavenBuildSpec struct {
// base Maven specification
MavenSpec `json:",inline"`
// additional repositories
Repositories []Repository `json:"repositories,omitempty"`
// Servers (auth)
Servers []Server `json:"servers,omitempty"`
}
// PublishTask image publish configuration.
type PublishTask struct {
// can be useful to share info with other tasks
ContextDir string `json:"contextDir,omitempty"`
// base image layer
BaseImage string `json:"baseImage,omitempty"`
// final image name
Image string `json:"image,omitempty"`
// where to publish the final image
Registry RegistrySpec `json:"registry,omitempty"`
}
// BuildahTask is used to configure Buildah.
type BuildahTask struct {
BaseTask `json:",inline"`
PublishTask `json:",inline"`
// The platform of build image
Platform string `json:"platform,omitempty"`
// log more information
Verbose *bool `json:"verbose,omitempty"`
// docker image to use
ExecutorImage string `json:"executorImage,omitempty"`
}
// KanikoTask is used to configure Kaniko.
type KanikoTask struct {
BaseTask `json:",inline"`
PublishTask `json:",inline"`
// log more information
Verbose *bool `json:"verbose,omitempty"`
// use a cache
Cache KanikoTaskCache `json:"cache,omitempty"`
// docker image to use
ExecutorImage string `json:"executorImage,omitempty"`
}
// KanikoTaskCache is used to configure Kaniko cache.
type KanikoTaskCache struct {
// true if a cache is enabled
Enabled *bool `json:"enabled,omitempty"`
// the PVC used to store the cache
PersistentVolumeClaim string `json:"persistentVolumeClaim,omitempty"`
}
// JibTask is used to configure Jib.
type JibTask struct {
BaseTask `json:",inline"`
PublishTask `json:",inline"`
}
// SpectrumTask is used to configure Spectrum.
type SpectrumTask struct {
BaseTask `json:",inline"`
PublishTask `json:",inline"`
}
// S2iTask is used to configure S2I.
type S2iTask struct {
BaseTask `json:",inline"`
// can be useful to share info with other tasks
ContextDir string `json:"contextDir,omitempty"`
// used by the ImageStream
Tag string `json:"tag,omitempty"`
}
// UserTask is used to execute any generic custom operation.
type UserTask struct {
BaseTask `json:",inline"`
// the container image to use
ContainerImage string `json:"image,omitempty"`
// the user id used to run the container
ContainerUserID *int64 `json:"userId,omitempty"`
// the command to execute
// Deprecated: use ContainerCommands
ContainerCommand string `json:"command,omitempty"`
// the command to execute
ContainerCommands []string `json:"commands,omitempty"`
// the desired image build name
PublishingImage string `json:"publishingImage,omitempty"`
}
// BuildStatus defines the observed state of Build.
type BuildStatus struct {
// ObservedGeneration is the most recent generation observed for this Build.
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// describes the phase
Phase BuildPhase `json:"phase,omitempty"`
// the image name built
Image string `json:"image,omitempty"`
// the digest from image
Digest string `json:"digest,omitempty"`
// root image (the first image from which the incremental image has started)
RootImage string `json:"rootImage,omitempty"`
// the base image used for this build
BaseImage string `json:"baseImage,omitempty"`
// a list of artifacts contained in the build
Artifacts []Artifact `json:"artifacts,omitempty"`
// the error description (if any)
Error string `json:"error,omitempty"`
// the reason of the failure (if any)
Failure *Failure `json:"failure,omitempty"`
// the time when it started
StartedAt *metav1.Time `json:"startedAt,omitempty"`
// a list of conditions occurred during the build
Conditions []BuildCondition `json:"conditions,omitempty"`
// how long it took for the build
// Change to Duration / ISO 8601 when CRD uses OpenAPI spec v3
// https://github.com/OAI/OpenAPI-Specification/issues/845
Duration string `json:"duration,omitempty"`
}
// BuildPhase -- .
type BuildPhase string
// BuildConditionType -- .
type BuildConditionType string
const (
// BuildKind -- .
BuildKind string = "Build"
// BuildPhaseNone -- .
BuildPhaseNone BuildPhase = ""
// BuildPhaseInitialization -- .
BuildPhaseInitialization BuildPhase = "Initialization"
// BuildPhaseScheduling -- .
BuildPhaseScheduling BuildPhase = "Scheduling"
// BuildPhasePending -- .
BuildPhasePending BuildPhase = "Pending"
// BuildPhaseRunning -- .
BuildPhaseRunning BuildPhase = "Running"
// BuildPhaseSucceeded -- .
BuildPhaseSucceeded BuildPhase = "Succeeded"
// BuildPhaseFailed -- .
BuildPhaseFailed BuildPhase = "Failed"
// BuildPhaseInterrupted -- .
BuildPhaseInterrupted = "Interrupted"
// BuildPhaseError -- .
BuildPhaseError BuildPhase = "Error"
// BuildConditionScheduled --.
BuildConditionScheduled BuildConditionType = "Scheduled"
// BuildConditionReadyReason --.
BuildConditionReadyReason string = "Ready"
// BuildConditionWaitingReason --.
BuildConditionWaitingReason string = "Waiting"
)
// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=builds,scope=Namespaced,shortName=ikb,categories=kamel;camel
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.phase`,description="The build phase"
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,description="The time at which the build was created"
// +kubebuilder:printcolumn:name="Started",type=date,JSONPath=`.status.startedAt`,description="The time at which the build was last (re-)started"
// Change format to 'duration' when CRD uses OpenAPI spec v3 (https://github.com/OAI/OpenAPI-Specification/issues/845)
// +kubebuilder:printcolumn:name="Duration",type=string,JSONPath=`.status.duration`,description="The build last execution duration"
// +kubebuilder:printcolumn:name="Attempts",type=integer,JSONPath=`.status.failure.recovery.attempt`,description="The number of execution attempts"
// Build is the Schema for the builds API.
type Build struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec BuildSpec `json:"spec,omitempty"`
Status BuildStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// BuildList contains a list of Build.
type BuildList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Build `json:"items"`
}
// BuildCondition describes the state of a resource at a certain point.
type BuildCondition struct {
// Type of integration condition.
Type BuildConditionType `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status corev1.ConditionStatus `json:"status"`
// The last time this condition was updated.
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
// Last time the condition transitioned from one status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
// The reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
// A human-readable message indicating details about the transition.
Message string `json:"message,omitempty"`
}