/
types.go
736 lines (598 loc) · 39 KB
/
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
package v1
import (
"time"
"k8s.io/kubernetes/pkg/api/unversioned"
kapi "k8s.io/kubernetes/pkg/api/v1"
)
// Build encapsulates the inputs needed to produce a new deployable image, as well as
// the status of the execution and a reference to the Pod which executed the build.
type Build struct {
unversioned.TypeMeta `json:",inline"`
// Standard object's metadata.
kapi.ObjectMeta `json:"metadata,omitempty"`
// Spec is all the inputs used to execute the build.
Spec BuildSpec `json:"spec,omitempty" description:"specification of the desired behavior for a build"`
// Status is the current status of the build.
Status BuildStatus `json:"status,omitempty" description:"most recently observed status of a build as populated by the system"`
}
// BuildSpec encapsulates all the inputs necessary to represent a build.
type BuildSpec struct {
// ServiceAccount is the name of the ServiceAccount to use to run the pod
// created by this build.
// The pod will be allowed to use secrets referenced by the ServiceAccount
ServiceAccount string `json:"serviceAccount,omitempty" description:"the name of the service account to use to run pods created by the build, pod will be allowed to use secrets referenced by the service account"`
// Source describes the SCM in use.
Source BuildSource `json:"source,omitempty" description:"describes the source control management system in use"`
// Revision is the information from the source for a specific repo snapshot.
// This is optional.
Revision *SourceRevision `json:"revision,omitempty" description:"specific revision in the source repository"`
// Strategy defines how to perform a build.
Strategy BuildStrategy `json:"strategy" description:"defines how to perform a build"`
// Output describes the Docker image the Strategy should produce.
Output BuildOutput `json:"output,omitempty" description:"describes the output of a build that a strategy should produce"`
// Compute resource requirements to execute the build
Resources kapi.ResourceRequirements `json:"resources,omitempty" description:"the desired compute resources the build should have"`
// PostCommit is a build hook executed after the build output image is
// committed, before it is pushed to a registry.
PostCommit BuildPostCommitSpec `json:"postCommit,omitempty" description:"an action executed after the build output image is committed"`
// Optional duration in seconds, counted from the time when a build pod gets
// scheduled in the system, that the build may be active on a node before the
// system actively tries to terminate the build; value must be positive integer
CompletionDeadlineSeconds *int64 `json:"completionDeadlineSeconds,omitempty" description:"optional duration in seconds the build may be active on a node before the system will actively try to mark it failed and kill associated containers; value must be a positive integer"`
}
// BuildStatus contains the status of a build
type BuildStatus struct {
// Phase is the point in the build lifecycle.
Phase BuildPhase `json:"phase" description:"observed point in the build lifecycle"`
// Cancelled describes if a cancel event was triggered for the build.
Cancelled bool `json:"cancelled,omitempty" description:"describes if a cancel event was triggered for the build"`
// Reason is a brief CamelCase string that describes any failure and is meant for machine parsing and tidy display in the CLI.
Reason StatusReason `json:"reason,omitempty" description:"brief CamelCase string describing a failure, meant for machine parsing and tidy display in the CLI"`
// Message is a human-readable message indicating details about why the build has this status.
Message string `json:"message,omitempty" description:"human-readable message indicating details about why the build has this status"`
// StartTimestamp is a timestamp representing the server time when this Build started
// running in a Pod.
// It is represented in RFC3339 form and is in UTC.
StartTimestamp *unversioned.Time `json:"startTimestamp,omitempty" description:"server time when this build started running in a pod"`
// CompletionTimestamp is a timestamp representing the server time when this Build was
// finished, whether that build failed or succeeded. It reflects the time at which
// the Pod running the Build terminated.
// It is represented in RFC3339 form and is in UTC.
CompletionTimestamp *unversioned.Time `json:"completionTimestamp,omitempty" description:"server time when the pod running this build stopped running"`
// Duration contains time.Duration object describing build time.
Duration time.Duration `json:"duration,omitempty" description:"amount of time the build has been running"`
// OutputDockerImageReference contains a reference to the Docker image that
// will be built by this build. It's value is computed from
// Build.Spec.Output.To, and should include the registry address, so that
// it can be used to push and pull the image.
OutputDockerImageReference string `json:"outputDockerImageReference,omitempty" description:"reference to the Docker image built by this build, computed from build.spec.output.to, and can be used to push and pull the image"`
// Config is an ObjectReference to the BuildConfig this Build is based on.
Config *kapi.ObjectReference `json:"config,omitempty" description:"reference to build config from which this build was derived"`
}
// BuildPhase represents the status of a build at a point in time.
type BuildPhase string
// Valid values for BuildPhase.
const (
// BuildPhaseNew is automatically assigned to a newly created build.
BuildPhaseNew BuildPhase = "New"
// BuildPhasePending indicates that a pod name has been assigned and a build is
// about to start running.
BuildPhasePending BuildPhase = "Pending"
// BuildPhaseRunning indicates that a pod has been created and a build is running.
BuildPhaseRunning BuildPhase = "Running"
// BuildPhaseComplete indicates that a build has been successful.
BuildPhaseComplete BuildPhase = "Complete"
// BuildPhaseFailed indicates that a build has executed and failed.
BuildPhaseFailed BuildPhase = "Failed"
// BuildPhaseError indicates that an error prevented the build from executing.
BuildPhaseError BuildPhase = "Error"
// BuildPhaseCancelled indicates that a running/pending build was stopped from executing.
BuildPhaseCancelled BuildPhase = "Cancelled"
)
// StatusReason is a brief CamelCase string that describes a temporary or
// permanent build error condition, meant for machine parsing and tidy display
// in the CLI.
type StatusReason string
// BuildSourceType is the type of SCM used.
type BuildSourceType string
// Valid values for BuildSourceType.
const (
//BuildSourceGit instructs a build to use a Git source control repository as the build input.
BuildSourceGit BuildSourceType = "Git"
// BuildSourceDockerfile uses a Dockerfile as the start of a build
BuildSourceDockerfile BuildSourceType = "Dockerfile"
// BuildSourceBinary indicates the build will accept a Binary file as input.
BuildSourceBinary BuildSourceType = "Binary"
// BuildSourceImage indicates the build will accept an image as input
BuildSourceImage BuildSourceType = "Image"
)
// BuildSource is the SCM used for the build.
type BuildSource struct {
// Type of build input to accept
Type BuildSourceType `json:"type" description:"type of build input to accept"`
// Binary builds accept a binary as their input. The binary is generally assumed to be a tar,
// gzipped tar, or zip file depending on the strategy. For Docker builds, this is the build
// context and an optional Dockerfile may be specified to override any Dockerfile in the
// build context. For Source builds, this is assumed to be an archive as described above. For
// Source and Docker builds, if binary.asFile is set the build will receive a directory with
// a single file. contextDir may be used when an archive is provided. Custom builds will
// receive this binary as input on STDIN.
Binary *BinaryBuildSource `json:"binary,omitempty" description:"the binary will be provided by the builder as an archive or file to be placed within the input directory; allows Dockerfile to be optionally set; may not be set with git source type also set"`
// Dockerfile is the raw contents of a Dockerfile which should be built. When this option is
// specified, the FROM may be modified based on your strategy base image and additional ENV
// stanzas from your strategy environment will be added after the FROM, but before the rest
// of your Dockerfile stanzas. The Dockerfile source type may be used with other options like
// git - in those cases the Git repo will have any innate Dockerfile replaced in the context
// dir.
Dockerfile *string `json:"dockerfile,omitempty" description:"the contents of a Dockerfile to build; FROM may be overridden by your strategy source, and additional ENV from your strategy will be placed before the rest of the Dockerfile stanzas"`
// Git contains optional information about git build source
Git *GitBuildSource `json:"git,omitempty" description:"optional information about git build source"`
// Images describes a set of images to be used to provide source for the build
Images []ImageSource `json:"images,omitempty" description:"optional images for build source."`
// ContextDir specifies the sub-directory where the source code for the application exists.
// This allows to have buildable sources in directory other than root of
// repository.
ContextDir string `json:"contextDir,omitempty" description:"specifies sub-directory where the source code for the application exists, allows for sources to be built from a directory other than the root of a repository"`
// SourceSecret is the name of a Secret that would be used for setting
// up the authentication for cloning private repository.
// The secret contains valid credentials for remote repository, where the
// data's key represent the authentication method to be used and value is
// the base64 encoded credentials. Supported auth methods are: ssh-privatekey.
SourceSecret *kapi.LocalObjectReference `json:"sourceSecret,omitempty" description:"supported auth methods are: ssh-privatekey"`
// Secrets represents a list of secrets and their destinations that will
// be used only for the build.
Secrets []SecretBuildSource `json:"secrets" description:"list of build secrets and destination directories"`
}
// ImageSource describes an image that is used as source for the build
type ImageSource struct {
// From is a reference to an ImageStreamTag, ImageStreamImage, or DockerImage to
// copy source from.
From kapi.ObjectReference `json:"from" description:"reference to ImageStreamTag, ImageStreamImage, or DockerImage"`
// Paths is a list of source and destination paths to copy from the image.
Paths []ImageSourcePath `json:"paths" description:"paths to copy from image"`
// PullSecret is a reference to a secret to be used to pull the image from a registry
// If the image is pulled from the OpenShift registry, this field does not need to be set.
PullSecret *kapi.LocalObjectReference `json:"pullSecret,omitempty" description:"overrides the default pull secret for the source image"`
}
// ImageSourcePath describes a path to be copied from a source image and its destination within the build directory.
type ImageSourcePath struct {
// SourcePath is the absolute path of the file or directory inside the image to
// copy to the build directory.
SourcePath string `json:"sourcePath" description:"source path (directory or file) inside image"`
// DestinationDir is the relative directory within the build directory
// where files copied from the image are placed.
DestinationDir string `json:"destinationDir" description:"relative destination directory in build home"`
}
// SecretBuildSource describes a secret and its destination directory that will be
// used only at the build time. The content of the secret referenced here will
// be copied into the destination directory instead of mounting.
type SecretBuildSource struct {
// Secret is a reference to an existing secret that you want to use in your
// build.
Secret kapi.LocalObjectReference `json:"secret" description:"name of a secret to be used as a source"`
// DestinationDir is the directory where the files from the secret should be
// available for the build time.
// For the Source build strategy, these will be injected into a container
// where the assemble script runs. Later, when the script finishes, all files
// injected will be truncated to zero length.
// For the Docker build strategy, these will be copied into the build
// directory, where the Dockerfile is located, so users can ADD or COPY them
// during docker build.
DestinationDir string `json:"destinationDir,omitempty" description:"destination directory for the secret files"`
}
// BinaryBuildSource describes a binary file to be used for the Docker and Source build strategies,
// where the file will be extracted and used as the build source.
type BinaryBuildSource struct {
// AsFile indicates that the provided binary input should be considered a single file
// within the build input. For example, specifying "webapp.war" would place the provided
// binary as `/webapp.war` for the builder. If left empty, the Docker and Source build
// strategies assume this file is a zip, tar, or tar.gz file and extract it as the source.
// The custom strategy receives this binary as standard input. This filename may not
// contain slashes or be '..' or '.'.
AsFile string `json:"asFile,omitempty" description:"indicate the provided binary should be considered a single file placed within the root of the input; must be a valid filename with no path segments"`
}
// SourceRevision is the revision or commit information from the source for the build
type SourceRevision struct {
// Type of the build source
Type BuildSourceType `json:"type" description:"type of the build source"`
// Git contains information about git-based build source
Git *GitSourceRevision `json:"git,omitempty" description:"information about git-based build source"`
}
// GitSourceRevision is the commit information from a git source for a build
type GitSourceRevision struct {
// Commit is the commit hash identifying a specific commit
Commit string `json:"commit,omitempty" description:"hash identifying a specific commit"`
// Author is the author of a specific commit
Author SourceControlUser `json:"author,omitempty" description:"author of a specific commit"`
// Committer is the committer of a specific commit
Committer SourceControlUser `json:"committer,omitempty" description:"committer of a specific commit"`
// Message is the description of a specific commit
Message string `json:"message,omitempty" description:"description of a specific commit"`
}
// GitBuildSource defines the parameters of a Git SCM
type GitBuildSource struct {
// URI points to the source that will be built. The structure of the source
// will depend on the type of build to run
URI string `json:"uri" description:"points to the source that will be built, structure of the source will depend on the type of build to run"`
// Ref is the branch/tag/ref to build.
Ref string `json:"ref,omitempty" description:"identifies the branch/tag/ref to build"`
// HTTPProxy is a proxy used to reach the git repository over http
HTTPProxy *string `json:"httpProxy,omitempty" description:"specifies a http proxy to be used during git clone operations"`
// HTTPSProxy is a proxy used to reach the git repository over https
HTTPSProxy *string `json:"httpsProxy,omitempty" description:"specifies a https proxy to be used during git clone operations"`
}
// SourceControlUser defines the identity of a user of source control
type SourceControlUser struct {
// Name of the source control user
Name string `json:"name,omitempty" description:"name of the source control user"`
// Email of the source control user
Email string `json:"email,omitempty" description:"e-mail of the source control user"`
}
// BuildStrategy contains the details of how to perform a build.
type BuildStrategy struct {
// Type is the kind of build strategy.
Type BuildStrategyType `json:"type" description:"identifies the type of build strategy"`
// DockerStrategy holds the parameters to the Docker build strategy.
DockerStrategy *DockerBuildStrategy `json:"dockerStrategy,omitempty" description:"holds parameters for the Docker build strategy"`
// SourceStrategy holds the parameters to the Source build strategy.
SourceStrategy *SourceBuildStrategy `json:"sourceStrategy,omitempty" description:"holds parameters to the Source build strategy"`
// CustomStrategy holds the parameters to the Custom build strategy
CustomStrategy *CustomBuildStrategy `json:"customStrategy,omitempty" description:"holds parameters to the Custom build strategy"`
}
// BuildStrategyType describes a particular way of performing a build.
type BuildStrategyType string
// Valid values for BuildStrategyType.
const (
// DockerBuildStrategyType performs builds using a Dockerfile.
DockerBuildStrategyType BuildStrategyType = "Docker"
// SourceBuildStrategyType performs builds build using Source To Images with a Git repository
// and a builder image.
SourceBuildStrategyType BuildStrategyType = "Source"
// CustomBuildStrategyType performs builds using custom builder Docker image.
CustomBuildStrategyType BuildStrategyType = "Custom"
)
// CustomBuildStrategy defines input parameters specific to Custom build.
type CustomBuildStrategy struct {
// From is reference to an DockerImage, ImageStreamTag, or ImageStreamImage from which
// the docker image should be pulled
From kapi.ObjectReference `json:"from" description:"reference to an image stream, image stream tag, or image stream image from which the Docker image should be pulled"`
// PullSecret is the name of a Secret that would be used for setting up
// the authentication for pulling the Docker images from the private Docker
// registries
PullSecret *kapi.LocalObjectReference `json:"pullSecret,omitempty" description:"supported type: dockercfg"`
// Env contains additional environment variables you want to pass into a builder container
Env []kapi.EnvVar `json:"env,omitempty" description:"additional environment variables you want to pass into a builder container"`
// ExposeDockerSocket will allow running Docker commands (and build Docker images) from
// inside the Docker container.
// TODO: Allow admins to enforce 'false' for this option
ExposeDockerSocket bool `json:"exposeDockerSocket,omitempty" description:"allow running Docker commands (and build Docker images) from inside the container"`
// ForcePull describes if the controller should configure the build pod to always pull the images
// for the builder or only pull if it is not present locally
ForcePull bool `json:"forcePull,omitempty" description:"forces pulling of builder image from remote registry if true"`
// Secrets is a list of additional secrets that will be included in the build pod
Secrets []SecretSpec `json:"secrets,omitempty" description:"a list of secrets to include in the build pod in addition to pull, push and source secrets"`
// BuildAPIVersion is the requested API version for the Build object serialized and passed to the custom builder
BuildAPIVersion string `json:"buildAPIVersion,omitempty" description:"requested API version for the Build object serialized and passed to the custom builder"`
}
// DockerBuildStrategy defines input parameters specific to Docker build.
type DockerBuildStrategy struct {
// From is reference to an DockerImage, ImageStreamTag, or ImageStreamImage from which
// the docker image should be pulled
// the resulting image will be used in the FROM line of the Dockerfile for this build.
From *kapi.ObjectReference `json:"from,omitempty" description:"reference to image stream, image stream tag, or image stream image from which docker image should be pulled, resulting image will be used in the FROM line for the Dockerfile for this build"`
// PullSecret is the name of a Secret that would be used for setting up
// the authentication for pulling the Docker images from the private Docker
// registries
PullSecret *kapi.LocalObjectReference `json:"pullSecret,omitempty" description:"supported type: dockercfg"`
// NoCache if set to true indicates that the docker build must be executed with the
// --no-cache=true flag
NoCache bool `json:"noCache,omitempty" description:"if true, indicates that the Docker build must be executed with the --no-cache=true flag"`
// Env contains additional environment variables you want to pass into a builder container
Env []kapi.EnvVar `json:"env,omitempty" description:"additional environment variables you want to pass into a builder container"`
// ForcePull describes if the builder should pull the images from registry prior to building.
ForcePull bool `json:"forcePull,omitempty" description:"forces the source build to pull the image if true"`
// DockerfilePath is the path of the Dockerfile that will be used to build the Docker image,
// relative to the root of the context (contextDir).
DockerfilePath string `json:"dockerfilePath,omitempty" description:"path of the Dockerfile to use for building the Docker image, relative to the contextDir, if set"`
}
// SourceBuildStrategy defines input parameters specific to an Source build.
type SourceBuildStrategy struct {
// From is reference to an DockerImage, ImageStreamTag, or ImageStreamImage from which
// the docker image should be pulled
From kapi.ObjectReference `json:"from" description:"reference to an image stream, image stream tag, or image stream image from which the Docker image should be pulled"`
// PullSecret is the name of a Secret that would be used for setting up
// the authentication for pulling the Docker images from the private Docker
// registries
PullSecret *kapi.LocalObjectReference `json:"pullSecret,omitempty" description:"supported type: dockercfg"`
// Env contains additional environment variables you want to pass into a builder container
Env []kapi.EnvVar `json:"env,omitempty" description:"additional environment variables you want to pass into a builder container"`
// Scripts is the location of Source scripts
Scripts string `json:"scripts,omitempty" description:"location of the source scripts"`
// Incremental flag forces the Source build to do incremental builds if true.
Incremental bool `json:"incremental,omitempty" description:"forces the source build to do incremental builds if true"`
// ForcePull describes if the builder should pull the images from registry prior to building.
ForcePull bool `json:"forcePull,omitempty" description:"forces the source build to pull the image if true"`
}
// A BuildPostCommitSpec holds a build post commit hook specification. The hook
// executes a command in a temporary container running the build output image,
// immediately after the last layer of the image is committed and before the
// image is pushed to a registry. The command is executed with the current
// working directory ($PWD) set to the image's WORKDIR.
//
// The build will be marked as failed if the hook execution fails. It will fail
// if the script or command return a non-zero exit code, or if there is any
// other error related to starting the temporary container.
//
// There are five different ways to configure the hook. As an example, all forms
// below are equivalent and will execute `rake test --verbose`.
//
// 1. Shell script:
//
// BuildPostCommitSpec{
// Script: "rake test --verbose",
// }
//
// The above is a convenient form which is equivalent to:
//
// BuildPostCommitSpec{
// Command: []string{"/bin/sh", "-c"},
// Args: []string{"rake test --verbose"},
// }
//
// 2. Command as the image entrypoint:
//
// BuildPostCommitSpec{
// Command: []string{"rake", "test", "--verbose"},
// }
//
// Command overrides the image entrypoint in the exec form, as documented in
// Docker: https://docs.docker.com/engine/reference/builder/#entrypoint.
//
// 3. Pass arguments to the default entrypoint:
//
// BuildPostCommitSpec{
// Args: []string{"rake", "test", "--verbose"},
// }
//
// This form is only useful if the image entrypoint can handle arguments.
//
// 4. Shell script with arguments:
//
// BuildPostCommitSpec{
// Script: "rake test $1",
// Args: []string{"--verbose"},
// }
//
// This form is useful if you need to pass arguments that would otherwise be
// hard to quote properly in the shell script. In the script, $0 will be
// "/bin/sh" and $1, $2, etc, are the positional arguments from Args.
//
// 5. Command with arguments:
//
// BuildPostCommitSpec{
// Command: []string{"rake", "test"},
// Args: []string{"--verbose"},
// }
//
// This form is equivalent to appending the arguments to the Command slice.
//
// It is invalid to provide both Script and Command simultaneously. If none of
// the fields are specified, the hook is not executed.
type BuildPostCommitSpec struct {
// Command is the command to run. It may not be specified with Script.
// This might be needed if the image doesn't have "/bin/sh", or if you
// do not want to use a shell. In all other cases, using Script might be
// more convenient.
Command []string `json:"command,omitempty" description:"command to be executed in a container running the build output image replacing the image's entrypoint"`
// Args is a list of arguments that are provided to either Command,
// Script or the Docker image's default entrypoint. The arguments are
// placed immediately after the command to be run.
Args []string `json:"args,omitempty" description:"arguments to command, script or the default image entrypoint"`
// Script is a shell script to be run with `/bin/sh -c`. It may not be
// specified with Command. Use Script when a shell script is appropriate
// to execute the post build hook, for example for running unit tests
// with "rake test". If you need control over the image entrypoint, or
// if the image does not have "/bin/sh", use Command and/or Args.
Script string `json:"script,omitempty" description:"shell script to be executed in a container running the build output image"`
}
// BuildOutput is input to a build strategy and describes the Docker image that the strategy
// should produce.
type BuildOutput struct {
// To defines an optional location to push the output of this build to.
// Kind must be one of 'ImageStreamTag' or 'DockerImage'.
// This value will be used to look up a Docker image repository to push to.
// In the case of an ImageStreamTag, the ImageStreamTag will be looked for in the namespace of
// the build unless Namespace is specified.
To *kapi.ObjectReference `json:"to,omitempty" description:"The optional image stream to push the output of this build. The namespace may be empty, in which case, the image stream will be looked up based on the namespace of the build."`
// PushSecret is the name of a Secret that would be used for setting
// up the authentication for executing the Docker push to authentication
// enabled Docker Registry (or Docker Hub).
PushSecret *kapi.LocalObjectReference `json:"pushSecret,omitempty" description:"supported type: dockercfg"`
}
// BuildConfig is a template which can be used to create new builds.
type BuildConfig struct {
unversioned.TypeMeta `json:",inline"`
// Standard object's metadata.
kapi.ObjectMeta `json:"metadata,omitempty"`
// Spec holds all the input necessary to produce a new build, and the conditions when
// to trigger them.
Spec BuildConfigSpec `json:"spec" description:"holds all the input necessary to produce a new build, and the conditions when to trigger them"`
// Status holds any relevant information about a build config
Status BuildConfigStatus `json:"status" description:"holds any relevant information about a build config derived by the system"`
}
// BuildConfigSpec describes when and how builds are created
type BuildConfigSpec struct {
// Triggers determine how new Builds can be launched from a BuildConfig. If no triggers
// are defined, a new build can only occur as a result of an explicit client build creation.
Triggers []BuildTriggerPolicy `json:"triggers" description:"determines how new builds can be launched from a build config. if no triggers are defined, a new build can only occur as a result of an explicit client build creation."`
// BuildSpec is the desired build specification
BuildSpec `json:",inline" description:"the desired build specification"`
}
// BuildConfigStatus contains current state of the build config object.
type BuildConfigStatus struct {
// LastVersion is used to inform about number of last triggered build.
LastVersion int `json:"lastVersion" description:"used to inform about number of last triggered build"`
}
// WebHookTrigger is a trigger that gets invoked using a webhook type of post
type WebHookTrigger struct {
// Secret used to validate requests.
Secret string `json:"secret,omitempty" description:"secret used to validate requests"`
}
// ImageChangeTrigger allows builds to be triggered when an ImageStream changes
type ImageChangeTrigger struct {
// LastTriggeredImageID is used internally by the ImageChangeController to save last
// used image ID for build
LastTriggeredImageID string `json:"lastTriggeredImageID,omitempty" description:"used internally to save last used image ID for build"`
// From is a reference to an ImageStreamTag that will trigger a build when updated
// It is optional. If no From is specified, the From image from the build strategy
// will be used. Only one ImageChangeTrigger with an empty From reference is allowed in
// a build configuration.
From *kapi.ObjectReference `json:"from,omitempty" description:"reference to an ImageStreamTag that will trigger the build"`
}
// BuildTriggerPolicy describes a policy for a single trigger that results in a new Build.
type BuildTriggerPolicy struct {
// Type is the type of build trigger
Type BuildTriggerType `json:"type" description:"type of build trigger"`
// GitHubWebHook contains the parameters for a GitHub webhook type of trigger
GitHubWebHook *WebHookTrigger `json:"github,omitempty" description:"parameters for a GitHub webhook type of trigger"`
// GenericWebHook contains the parameters for a Generic webhook type of trigger
GenericWebHook *WebHookTrigger `json:"generic,omitempty" description:"parameters for a Generic webhook type of trigger"`
// ImageChange contains parameters for an ImageChange type of trigger
ImageChange *ImageChangeTrigger `json:"imageChange,omitempty" description:"parameters for an ImageChange type of trigger"`
}
// BuildTriggerType refers to a specific BuildTriggerPolicy implementation.
type BuildTriggerType string
const (
// GitHubWebHookBuildTriggerType represents a trigger that launches builds on
// GitHub webhook invocations
GitHubWebHookBuildTriggerType BuildTriggerType = "GitHub"
GitHubWebHookBuildTriggerTypeDeprecated BuildTriggerType = "github"
// GenericWebHookBuildTriggerType represents a trigger that launches builds on
// generic webhook invocations
GenericWebHookBuildTriggerType BuildTriggerType = "Generic"
GenericWebHookBuildTriggerTypeDeprecated BuildTriggerType = "generic"
// ImageChangeBuildTriggerType represents a trigger that launches builds on
// availability of a new version of an image
ImageChangeBuildTriggerType BuildTriggerType = "ImageChange"
ImageChangeBuildTriggerTypeDeprecated BuildTriggerType = "imageChange"
// ConfigChangeBuildTriggerType will trigger a build on an initial build config creation
// WARNING: In the future the behavior will change to trigger a build on any config change
ConfigChangeBuildTriggerType BuildTriggerType = "ConfigChange"
)
// BuildList is a collection of Builds.
type BuildList struct {
unversioned.TypeMeta `json:",inline"`
// Standard object's metadata.
unversioned.ListMeta `json:"metadata,omitempty"`
// Items is a list of builds
Items []Build `json:"items" description:"list of builds"`
}
// BuildConfigList is a collection of BuildConfigs.
type BuildConfigList struct {
unversioned.TypeMeta `json:",inline"`
// Standard object's metadata.
unversioned.ListMeta `json:"metadata,omitempty"`
// Items is a list of build configs
Items []BuildConfig `json:"items" description:"list of build configs"`
}
// GenericWebHookEvent is the payload expected for a generic webhook post
type GenericWebHookEvent struct {
// Type is the type of source repository
Type BuildSourceType `json:"type,omitempty" description:"type of source repository"`
// Git is the git information if the Type is BuildSourceGit
Git *GitInfo `json:"git,omitempty" description:"git information if type is git"`
}
// GitInfo is the aggregated git information for a generic webhook post
type GitInfo struct {
GitBuildSource `json:",inline"`
GitSourceRevision `json:",inline"`
}
// BuildLog is the (unused) resource associated with the build log redirector
type BuildLog struct {
unversioned.TypeMeta `json:",inline"`
}
// BuildRequest is the resource used to pass parameters to build generator
type BuildRequest struct {
unversioned.TypeMeta `json:",inline"`
// Standard object's metadata.
kapi.ObjectMeta `json:"metadata,omitempty"`
// Revision is the information from the source for a specific repo snapshot.
Revision *SourceRevision `json:"revision,omitempty" description:"information from the source for a specific repo snapshot"`
// TriggeredByImage is the Image that triggered this build.
TriggeredByImage *kapi.ObjectReference `json:"triggeredByImage,omitempty" description:"image that triggered this build"`
// From is the reference to the ImageStreamTag that triggered the build.
From *kapi.ObjectReference `json:"from,omitempty" description:"ImageStreamTag that triggered this build"`
// Binary indicates a request to build from a binary provided to the builder
Binary *BinaryBuildSource `json:"binary,omitempty" description:"the binary will be provided by the builder as an archive or file to be placed within the input directory; allows Dockerfile to be optionally set; may not be set with git source type also set"`
// LastVersion (optional) is the LastVersion of the BuildConfig that was used
// to generate the build. If the BuildConfig in the generator doesn't match, a build will
// not be generated.
LastVersion *int `json:"lastVersion,omitempty" description:"LastVersion of the BuildConfig that triggered this build"`
// Env contains additional environment variables you want to pass into a builder container
Env []kapi.EnvVar `json:"env,omitempty" description:"additional environment variables you want to pass into a builder container"`
}
// BinaryBuildRequestOptions are the options required to fully speficy a binary build request
type BinaryBuildRequestOptions struct {
unversioned.TypeMeta `json:",inline"`
// Standard object's metadata.
kapi.ObjectMeta `json:"metadata,omitempty"`
// AsFile determines if the binary should be created as a file within the source rather than extracted as an archive
AsFile string `json:"asFile,omitempty" description:"If set, the binary should be created as a file within the source rather than extracted as an archive"`
// TODO: Improve map[string][]string conversion so we can handled nested objects
// Commit is the value identifying a specific commit
Commit string `json:"revision.commit,omitempty" description:"string identifying a specific commit"`
// Message is the description of a specific commit
Message string `json:"revision.message,omitempty" description:"description of a specific commit"`
// AuthorName of the source control user
AuthorName string `json:"revision.authorName,omitempty" description:"name of the user who authored the commit"`
// AuthorEmail of the source control user
AuthorEmail string `json:"revision.authorEmail,omitempty" description:"e-mail of the user who authored the commit"`
// CommitterName of the source control user
CommitterName string `json:"revision.committerName,omitempty" description:"name of the user who added the commit"`
// CommitterEmail of the source control user
CommitterEmail string `json:"revision.committerEmail,omitempty" description:"e-mail of the user who added the commit"`
}
// BuildLogOptions is the REST options for a build log
type BuildLogOptions struct {
unversioned.TypeMeta `json:",inline"`
// The container for which to stream logs. Defaults to only container if there is one container in the pod.
Container string `json:"container,omitempty" description:"the container for which to stream logs; defaults to only container if there is one container in the pod"`
// Follow if true indicates that the build log should be streamed until
// the build terminates.
Follow bool `json:"follow,omitempty" description:"if true indicates that the log should be streamed; defaults to false"`
// Return previous build logs. Defaults to false.
Previous bool `json:"previous,omitempty" description:"return previous build logs; defaults to false."`
// A relative time in seconds before the current time from which to show logs. If this value
// precedes the time a pod was started, only logs since the pod start will be returned.
// If this value is in the future, no logs will be returned.
// Only one of sinceSeconds or sinceTime may be specified.
SinceSeconds *int64 `json:"sinceSeconds,omitempty" description:"relative time in seconds before the current time from which to show logs"`
// An RFC3339 timestamp from which to show logs. If this value
// preceeds the time a pod was started, only logs since the pod start will be returned.
// If this value is in the future, no logs will be returned.
// Only one of sinceSeconds or sinceTime may be specified.
SinceTime *unversioned.Time `json:"sinceTime,omitempty" description:"relative time in seconds before the current time from which to show logs"`
// If true, add an RFC3339 or RFC3339Nano timestamp at the beginning of every line
// of log output. Defaults to false.
Timestamps bool `json:"timestamps,omitempty" description:"add an RFC3339 or RFC3339Nano timestamp at the beginning of every line of log output"`
// If set, the number of lines from the end of the logs to show. If not specified,
// logs are shown from the creation of the container or sinceSeconds or sinceTime
TailLines *int64 `json:"tailLines,omitempty" description:"the number of lines from the end of the logs to show"`
// If set, the number of bytes to read from the server before terminating the
// log output. This may not display a complete final line of logging, and may return
// slightly more or slightly less than the specified limit.
LimitBytes *int64 `json:"limitBytes,omitempty" description:"the number of bytes to read from the server before terminating the log output"`
// NoWait if true causes the call to return immediately even if the build
// is not available yet. Otherwise the server will wait until the build has started.
// TODO: Fix the tag to 'noWait' in v2
NoWait bool `json:"nowait,omitempty" description:"if true indicates that the server should not wait for a log to be available before returning; defaults to false"`
// Version of the build for which to view logs.
Version *int64 `json:"version,omitempty" description:"the version of the build for which to view logs"`
}
// SecretSpec specifies a secret to be included in a build pod and its corresponding mount point
type SecretSpec struct {
// SecretSource is a reference to the secret
SecretSource kapi.LocalObjectReference `json:"secretSource" description:"a reference to a secret"`
// MountPath is the path at which to mount the secret
MountPath string `json:"mountPath" description:"path within the container at which the secret should be mounted"`
}