MCPcopy
hub / github.com/redspread/spread / validateContainer

Function validateContainer

pkg/entity/container.go:128–158  ·  view source on GitHub ↗
(c kube.Container)

Source from the content-addressed store, hash-verified

126}
127
128func validateContainer(c kube.Container) error {
129 validMeta := kube.ObjectMeta{
130 Name: "valid",
131 Namespace: "object",
132 }
133
134 pod := kube.Pod{
135 ObjectMeta: validMeta,
136 Spec: kube.PodSpec{
137 Containers: []kube.Container{c},
138 RestartPolicy: kube.RestartPolicyAlways,
139 DNSPolicy: kube.DNSClusterFirst,
140 },
141 }
142
143 // fake volumes to allow validation
144 for _, mount := range c.VolumeMounts {
145 volume := kube.Volume{
146 Name: mount.Name,
147 VolumeSource: kube.VolumeSource{EmptyDir: &kube.EmptyDirVolumeSource{}},
148 }
149 pod.Spec.Volumes = append(pod.Spec.Volumes, volume)
150 }
151
152 errList := validation.ValidatePod(&pod)
153
154 // Remove error for missing image field
155 return errList.Filter(func(e error) bool {
156 return e.Error() == NoImageErrStr
157 }).ToAggregate()
158}
159
160var (
161 // ErrMissingImage is where the Container is being used in a context where it must be valid and doesn't have an Image.

Callers 1

NewContainerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected