Skip to content

Commit 9b71b6d

Browse files
committed
Add PodSpec based E2E for default configuration
1 parent a9d276c commit 9b71b6d

File tree

9 files changed

+4618
-0
lines changed

9 files changed

+4618
-0
lines changed

tests/integration/integration_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,12 @@ var _ = It("With all ok data", func() {
2828

2929
runner.RunTestsFromDir("testdata/all_ok")
3030
})
31+
32+
var _ = It("With default configurations", func() {
33+
runner := runner.NewRunnerBuilder().
34+
WithBinPath(binPath).
35+
WithExitCode(1).
36+
Runner()
37+
38+
runner.RunTestsFromDir("testdata/default_configurations")
39+
})

tests/integration/testdata/default_configurations/affinity.go

Lines changed: 489 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
linters:
2+
enabled: [] # This will mean only the default enabled linters are enabled.
3+
disabled: [] # This will mean only the default disabled linters are disabled.
4+
linterSettings: {} # This will mean only the default linter settings are used.

tests/integration/testdata/default_configurations/container.go

Lines changed: 1107 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
package defaultconfigurations
2+
3+
// An EphemeralContainer is a temporary container that you may add to an existing Pod for
4+
// user-initiated activities such as debugging. Ephemeral containers have no resource or
5+
// scheduling guarantees, and they will not be restarted when they exit or when a Pod is
6+
// removed or restarted. The kubelet may evict a Pod if an ephemeral container causes the
7+
// Pod to exceed its resource allocation.
8+
//
9+
// To add an ephemeral container, use the ephemeralcontainers subresource of an existing
10+
// Pod. Ephemeral containers may not be removed or restarted.
11+
type EphemeralContainer struct {
12+
// Ephemeral containers have all of the fields of Container, plus additional fields
13+
// specific to ephemeral containers. Fields in common with Container are in the
14+
// following inlined struct so than an EphemeralContainer may easily be converted
15+
// to a Container.
16+
EphemeralContainerCommon `json:",inline" protobuf:"bytes,1,req"`
17+
18+
// If set, the name of the container from PodSpec that this ephemeral container targets. // want "commentstart: godoc for field TargetContainerName should start with 'targetContainerName ...'"
19+
// The ephemeral container will be run in the namespaces (IPC, PID, etc) of this container.
20+
// If not set then the ephemeral container uses the namespaces configured in the Pod spec.
21+
//
22+
// The container runtime must implement support for this feature. If the runtime does not
23+
// support namespace targeting then the result of setting this field is undefined.
24+
// +optional
25+
TargetContainerName string `json:"targetContainerName,omitempty" protobuf:"bytes,2,opt,name=targetContainerName"` // want "optionalfields: field TargetContainerName should be a pointer."
26+
}
27+
28+
// EphemeralContainerCommon is a copy of all fields in Container to be inlined in
29+
// EphemeralContainer. This separate type allows easy conversion from EphemeralContainer
30+
// to Container and allows separate documentation for the fields of EphemeralContainer.
31+
// When a new field is added to Container it must be added here as well.
32+
type EphemeralContainerCommon struct {
33+
// Name of the ephemeral container specified as a DNS_LABEL. // want "commentstart: godoc for field Name should start with 'name ...'"
34+
// This name must be unique among all containers, init containers and ephemeral containers.
35+
Name string `json:"name" protobuf:"bytes,1,opt,name=name"` // want "optionalorrequired: field Name must be marked as optional or required"
36+
// Container image name. // want "commentstart: godoc for field Image should start with 'image ...'"
37+
// More info: https://kubernetes.io/docs/concepts/containers/images
38+
Image string `json:"image,omitempty" protobuf:"bytes,2,opt,name=image"` // want "optionalorrequired: field Image must be marked as optional or required"
39+
// Entrypoint array. Not executed within a shell. // want "commentstart: godoc for field Command should start with 'command ...'"
40+
// The image's ENTRYPOINT is used if this is not provided.
41+
// Variable references $(VAR_NAME) are expanded using the container's environment. If a variable
42+
// cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced
43+
// to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will
44+
// produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless
45+
// of whether the variable exists or not. Cannot be updated.
46+
// More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
47+
// +optional
48+
// +listType=atomic
49+
Command []string `json:"command,omitempty" protobuf:"bytes,3,rep,name=command"`
50+
// Arguments to the entrypoint. // want "commentstart: godoc for field Args should start with 'args ...'"
51+
// The image's CMD is used if this is not provided.
52+
// Variable references $(VAR_NAME) are expanded using the container's environment. If a variable
53+
// cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced
54+
// to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will
55+
// produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless
56+
// of whether the variable exists or not. Cannot be updated.
57+
// More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
58+
// +optional
59+
// +listType=atomic
60+
Args []string `json:"args,omitempty" protobuf:"bytes,4,rep,name=args"`
61+
// Container's working directory. // want "commentstart: godoc for field WorkingDir should start with 'workingDir ...'"
62+
// If not specified, the container runtime's default will be used, which
63+
// might be configured in the container image.
64+
// Cannot be updated.
65+
// +optional
66+
WorkingDir string `json:"workingDir,omitempty" protobuf:"bytes,5,opt,name=workingDir"` // want "optionalfields: field WorkingDir should be a pointer."
67+
// Ports are not allowed for ephemeral containers. // want "commentstart: godoc for field Ports should start with 'ports ...'"
68+
// +optional
69+
// +patchMergeKey=containerPort
70+
// +patchStrategy=merge
71+
// +listType=map
72+
// +listMapKey=containerPort
73+
// +listMapKey=protocol
74+
Ports []ContainerPort `json:"ports,omitempty" patchStrategy:"merge" patchMergeKey:"containerPort" protobuf:"bytes,6,rep,name=ports"` // want "arrayofstruct: EphemeralContainerCommon.Ports is an array of structs, but the struct has no required fields. At least one field should be marked as required to prevent ambiguous YAML configurations"
75+
// List of sources to populate environment variables in the container. // want "commentstart: godoc for field EnvFrom should start with 'envFrom ...'"
76+
// The keys defined within a source may consist of any printable ASCII characters except '='.
77+
// When a key exists in multiple
78+
// sources, the value associated with the last source will take precedence.
79+
// Values defined by an Env with a duplicate key will take precedence.
80+
// Cannot be updated.
81+
// +optional
82+
// +listType=atomic
83+
EnvFrom []EnvFromSource `json:"envFrom,omitempty" protobuf:"bytes,19,rep,name=envFrom"` // want "arrayofstruct: EphemeralContainerCommon.EnvFrom is an array of structs, but the struct has no required fields. At least one field should be marked as required to prevent ambiguous YAML configurations"
84+
// List of environment variables to set in the container. // want "commentstart: godoc for field Env should start with 'env ...'"
85+
// Cannot be updated.
86+
// +optional
87+
// +patchMergeKey=name
88+
// +patchStrategy=merge
89+
// +listType=map
90+
// +listMapKey=name
91+
Env []EnvVar `json:"env,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,7,rep,name=env"` // want "arrayofstruct: EphemeralContainerCommon.Env is an array of structs, but the struct has no required fields. At least one field should be marked as required to prevent ambiguous YAML configurations"
92+
// Resources are not allowed for ephemeral containers. Ephemeral containers use spare resources // want "commentstart: godoc for field Resources should start with 'resources ...'"
93+
// already allocated to the pod.
94+
// +optional
95+
Resources ResourceRequirements `json:"resources,omitempty" protobuf:"bytes,8,opt,name=resources"` // want "optionalfields: field Resources should be a pointer."
96+
// Resources resize policy for the container. // want "commentstart: godoc for field ResizePolicy should start with 'resizePolicy ...'"
97+
// +featureGate=InPlacePodVerticalScaling
98+
// +optional
99+
// +listType=atomic
100+
ResizePolicy []ContainerResizePolicy `json:"resizePolicy,omitempty" protobuf:"bytes,23,rep,name=resizePolicy"` // want "arrayofstruct: EphemeralContainerCommon.ResizePolicy is an array of structs, but the struct has no required fields. At least one field should be marked as required to prevent ambiguous YAML configurations"
101+
// Restart policy for the container to manage the restart behavior of each // want "commentstart: godoc for field RestartPolicy should start with 'restartPolicy ...'"
102+
// container within a pod.
103+
// You cannot set this field on ephemeral containers.
104+
// +optional
105+
RestartPolicy *ContainerRestartPolicy `json:"restartPolicy,omitempty" protobuf:"bytes,24,opt,name=restartPolicy,casttype=ContainerRestartPolicy"`
106+
// Represents a list of rules to be checked to determine if the // want "commentstart: godoc for field RestartPolicyRules should start with 'restartPolicyRules ...'"
107+
// container should be restarted on exit. You cannot set this field on
108+
// ephemeral containers.
109+
// +featureGate=ContainerRestartRules
110+
// +optional
111+
// +listType=atomic
112+
RestartPolicyRules []ContainerRestartRule `json:"restartPolicyRules,omitempty" protobuf:"bytes,25,rep,name=restartPolicyRules"`
113+
// Pod volumes to mount into the container's filesystem. Subpath mounts are not allowed for ephemeral containers. // want "commentstart: godoc for field VolumeMounts should start with 'volumeMounts ...'"
114+
// Cannot be updated.
115+
// +optional
116+
// +patchMergeKey=mountPath
117+
// +patchStrategy=merge
118+
// +listType=map
119+
// +listMapKey=mountPath
120+
VolumeMounts []VolumeMount `json:"volumeMounts,omitempty" patchStrategy:"merge" patchMergeKey:"mountPath" protobuf:"bytes,9,rep,name=volumeMounts"` // want "arrayofstruct: EphemeralContainerCommon.VolumeMounts is an array of structs, but the struct has no required fields. At least one field should be marked as required to prevent ambiguous YAML configurations"
121+
// volumeDevices is the list of block devices to be used by the container.
122+
// +patchMergeKey=devicePath
123+
// +patchStrategy=merge
124+
// +listType=map
125+
// +listMapKey=devicePath
126+
// +optional
127+
VolumeDevices []VolumeDevice `json:"volumeDevices,omitempty" patchStrategy:"merge" patchMergeKey:"devicePath" protobuf:"bytes,21,rep,name=volumeDevices"` // want "arrayofstruct: EphemeralContainerCommon.VolumeDevices is an array of structs, but the struct has no required fields. At least one field should be marked as required to prevent ambiguous YAML configurations"
128+
// Probes are not allowed for ephemeral containers. // want "commentstart: godoc for field LivenessProbe should start with 'livenessProbe ...'"
129+
// +optional
130+
LivenessProbe *Probe `json:"livenessProbe,omitempty" protobuf:"bytes,10,opt,name=livenessProbe"`
131+
// Probes are not allowed for ephemeral containers. // want "commentstart: godoc for field ReadinessProbe should start with 'readinessProbe ...'"
132+
// +optional
133+
ReadinessProbe *Probe `json:"readinessProbe,omitempty" protobuf:"bytes,11,opt,name=readinessProbe"`
134+
// Probes are not allowed for ephemeral containers. // want "commentstart: godoc for field StartupProbe should start with 'startupProbe ...'"
135+
// +optional
136+
StartupProbe *Probe `json:"startupProbe,omitempty" protobuf:"bytes,22,opt,name=startupProbe"`
137+
// Lifecycle is not allowed for ephemeral containers. // want "commentstart: godoc for field Lifecycle should start with 'lifecycle ...'"
138+
// +optional
139+
Lifecycle *Lifecycle `json:"lifecycle,omitempty" protobuf:"bytes,12,opt,name=lifecycle"`
140+
// Optional: Path at which the file to which the container's termination message // want "commentstart: godoc for field TerminationMessagePath should start with 'terminationMessagePath ...'"
141+
// will be written is mounted into the container's filesystem.
142+
// Message written is intended to be brief final status, such as an assertion failure message.
143+
// Will be truncated by the node if greater than 4096 bytes. The total message length across
144+
// all containers will be limited to 12kb.
145+
// Defaults to /dev/termination-log.
146+
// Cannot be updated.
147+
// +optional
148+
TerminationMessagePath string `json:"terminationMessagePath,omitempty" protobuf:"bytes,13,opt,name=terminationMessagePath"` // want "optionalfields: field TerminationMessagePath should be a pointer."
149+
// Indicate how the termination message should be populated. File will use the contents of // want "commentstart: godoc for field TerminationMessagePolicy should start with 'terminationMessagePolicy ...'"
150+
// terminationMessagePath to populate the container status message on both success and failure.
151+
// FallbackToLogsOnError will use the last chunk of container log output if the termination
152+
// message file is empty and the container exited with an error.
153+
// The log output is limited to 2048 bytes or 80 lines, whichever is smaller.
154+
// Defaults to File.
155+
// Cannot be updated.
156+
// +optional
157+
TerminationMessagePolicy TerminationMessagePolicy `json:"terminationMessagePolicy,omitempty" protobuf:"bytes,20,opt,name=terminationMessagePolicy,casttype=TerminationMessagePolicy"` // want "optionalfields: field TerminationMessagePolicy should be a pointer."
158+
// Image pull policy. // want "commentstart: godoc for field ImagePullPolicy should start with 'imagePullPolicy ...'"
159+
// One of Always, Never, IfNotPresent.
160+
// Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.
161+
// Cannot be updated.
162+
// More info: https://kubernetes.io/docs/concepts/containers/images#updating-images
163+
// +optional
164+
ImagePullPolicy PullPolicy `json:"imagePullPolicy,omitempty" protobuf:"bytes,14,opt,name=imagePullPolicy,casttype=PullPolicy"` // want "optionalfields: field ImagePullPolicy should be a pointer."
165+
// Optional: SecurityContext defines the security options the ephemeral container should be run with. // want "commentstart: godoc for field SecurityContext should start with 'securityContext ...'"
166+
// If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext.
167+
// +optional
168+
SecurityContext *SecurityContext `json:"securityContext,omitempty" protobuf:"bytes,15,opt,name=securityContext"`
169+
170+
// Variables for interactive containers, these have very specialized use-cases (e.g. debugging)
171+
// and shouldn't be used for general purpose containers.
172+
173+
// Whether this container should allocate a buffer for stdin in the container runtime. If this // want "commentstart: godoc for field Stdin should start with 'stdin ...'"
174+
// is not set, reads from stdin in the container will always result in EOF.
175+
// Default is false.
176+
// +optional
177+
Stdin bool `json:"stdin,omitempty" protobuf:"varint,16,opt,name=stdin"` // want "optionalfields: field Stdin should be a pointer."
178+
// Whether the container runtime should close the stdin channel after it has been opened by // want "commentstart: godoc for field StdinOnce should start with 'stdinOnce ...'"
179+
// a single attach. When stdin is true the stdin stream will remain open across multiple attach
180+
// sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the
181+
// first client attaches to stdin, and then remains open and accepts data until the client disconnects,
182+
// at which time stdin is closed and remains closed until the container is restarted. If this
183+
// flag is false, a container processes that reads from stdin will never receive an EOF.
184+
// Default is false
185+
// +optional
186+
StdinOnce bool `json:"stdinOnce,omitempty" protobuf:"varint,17,opt,name=stdinOnce"` // want "optionalfields: field StdinOnce should be a pointer."
187+
// Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. // want "commentstart: godoc for field TTY should start with 'tty ...'"
188+
// Default is false.
189+
// +optional
190+
TTY bool `json:"tty,omitempty" protobuf:"varint,18,opt,name=tty"` // want "optionalfields: field TTY should be a pointer."
191+
}

0 commit comments

Comments
 (0)