Skip to content

Commit d87f18a

Browse files
Merge pull request #20532 from soltysh/external_images
External graph library and company
2 parents 0192e76 + d14912b commit d87f18a

File tree

94 files changed

+2145
-1989
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2145
-1989
lines changed

hack/import-restrictions.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -524,16 +524,15 @@
524524
"vendor/github.com/davecgh/go-spew/spew",
525525

526526
"github.com/openshift/origin/pkg/authorization/generated",
527-
"github.com/openshift/origin/pkg/build/apis/build/v1",
528527
"github.com/openshift/origin/pkg/build/generated",
529-
"github.com/openshift/origin/pkg/build/apis/build/internal_helpers",
530-
"github.com/openshift/origin/pkg/image/apis/image/v1",
528+
"github.com/openshift/origin/pkg/image/apis/image/v1",
531529
"github.com/openshift/origin/pkg/image/generated",
532-
"github.com/openshift/origin/pkg/image/util",
530+
"github.com/openshift/origin/pkg/image/util",
533531
"github.com/openshift/origin/pkg/network/generated",
534532
"github.com/openshift/origin/pkg/oauth/generated",
535533
"github.com/openshift/origin/pkg/project/generated",
536534
"github.com/openshift/origin/pkg/quota/generated",
535+
"github.com/openshift/origin/pkg/route/apis/route/v1",
537536
"github.com/openshift/origin/pkg/route/generated",
538537
"github.com/openshift/origin/pkg/template/apis/template/v1",
539538
"github.com/openshift/origin/pkg/template/client/v1",
@@ -561,6 +560,7 @@
561560
"github.com/openshift/origin/pkg/build/apis/build",
562561
"github.com/openshift/origin/pkg/build/apis/build/install",
563562
"github.com/openshift/origin/pkg/build/buildapihelpers",
563+
"github.com/openshift/origin/pkg/build/apis/build/internal_helpers",
564564
"github.com/openshift/origin/pkg/build/client",
565565
"github.com/openshift/origin/pkg/build/client/v1",
566566
"github.com/openshift/origin/pkg/build/util",
@@ -587,7 +587,6 @@
587587
"github.com/openshift/origin/pkg/cmd/util/variable",
588588
"github.com/openshift/origin/pkg/git",
589589
"github.com/openshift/origin/pkg/image/apis/image",
590-
"github.com/openshift/origin/pkg/image/apis/image/install",
591590
"github.com/openshift/origin/pkg/image/apis/image/v1/trigger",
592591
"github.com/openshift/origin/pkg/image/apis/image/docker10",
593592
"github.com/openshift/origin/pkg/image/apis/image/reference",
@@ -645,7 +644,6 @@
645644
"vendor/github.com/miekg/dns",
646645

647646
"vendor/k8s.io/kubernetes/pkg/api/legacyscheme",
648-
"vendor/k8s.io/kubernetes/pkg/api/ref",
649647
"vendor/k8s.io/kubernetes/pkg/controller",
650648
"vendor/k8s.io/kubernetes/pkg/controller/deployment/util",
651649
"vendor/k8s.io/kubernetes/pkg/credentialprovider",

pkg/api/imagereferencemutators/pods.go

+109-40
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ package imagereferencemutators
33
import (
44
"fmt"
55

6-
appsv1beta1 "k8s.io/api/apps/v1beta1"
6+
kappsv1 "k8s.io/api/apps/v1"
7+
kappsv1beta1 "k8s.io/api/apps/v1beta1"
8+
kappsv1beta2 "k8s.io/api/apps/v1beta2"
79
batchv1 "k8s.io/api/batch/v1"
10+
batchv1beta1 "k8s.io/api/batch/v1beta1"
811
batchv2alpha1 "k8s.io/api/batch/v2alpha1"
912
corev1 "k8s.io/api/core/v1"
10-
kapiv1 "k8s.io/api/core/v1"
1113
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
1214
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1315
"k8s.io/apimachinery/pkg/runtime"
@@ -93,38 +95,72 @@ func GetPodSpec(obj runtime.Object) (*kapi.PodSpec, *field.Path, error) {
9395
// GetPodSpecV1 returns a mutable pod spec out of the provided object, including a field path
9496
// to the field in the object, or an error if the object does not contain a pod spec.
9597
// This only returns pod specs for v1 compatible objects.
96-
func GetPodSpecV1(obj runtime.Object) (*kapiv1.PodSpec, *field.Path, error) {
98+
func GetPodSpecV1(obj runtime.Object) (*corev1.PodSpec, *field.Path, error) {
9799
switch r := obj.(type) {
98-
case *kapiv1.Pod:
100+
101+
case *corev1.Pod:
99102
return &r.Spec, field.NewPath("spec"), nil
100-
case *kapiv1.PodTemplate:
103+
104+
case *corev1.PodTemplate:
101105
return &r.Template.Spec, field.NewPath("template", "spec"), nil
102-
case *kapiv1.ReplicationController:
106+
107+
case *corev1.ReplicationController:
103108
if r.Spec.Template != nil {
104109
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
105110
}
111+
106112
case *extensionsv1beta1.DaemonSet:
107113
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
114+
case *kappsv1.DaemonSet:
115+
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
116+
case *kappsv1beta2.DaemonSet:
117+
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
118+
108119
case *extensionsv1beta1.Deployment:
109120
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
121+
case *kappsv1.Deployment:
122+
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
123+
case *kappsv1beta1.Deployment:
124+
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
125+
case *kappsv1beta2.Deployment:
126+
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
127+
110128
case *extensionsv1beta1.ReplicaSet:
111129
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
130+
case *kappsv1.ReplicaSet:
131+
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
132+
case *kappsv1beta2.ReplicaSet:
133+
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
134+
112135
case *batchv1.Job:
113136
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
137+
114138
case *batchv2alpha1.CronJob:
115139
return &r.Spec.JobTemplate.Spec.Template.Spec, field.NewPath("spec", "jobTemplate", "spec", "template", "spec"), nil
140+
case *batchv1beta1.CronJob:
141+
return &r.Spec.JobTemplate.Spec.Template.Spec, field.NewPath("spec", "jobTemplate", "spec", "template", "spec"), nil
142+
116143
case *batchv2alpha1.JobTemplate:
117144
return &r.Template.Spec.Template.Spec, field.NewPath("template", "spec", "template", "spec"), nil
118-
case *appsv1beta1.StatefulSet:
145+
case *batchv1beta1.JobTemplate:
146+
return &r.Template.Spec.Template.Spec, field.NewPath("template", "spec", "template", "spec"), nil
147+
148+
case *kappsv1.StatefulSet:
149+
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
150+
case *kappsv1beta1.StatefulSet:
119151
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
120-
case *appsv1beta1.Deployment:
152+
case *kappsv1beta2.StatefulSet:
121153
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
154+
122155
case *securityv1.PodSecurityPolicySubjectReview:
123156
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
157+
124158
case *securityv1.PodSecurityPolicySelfSubjectReview:
125159
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
160+
126161
case *securityv1.PodSecurityPolicyReview:
127162
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
163+
128164
case *appsv1.DeploymentConfig:
129165
if r.Spec.Template != nil {
130166
return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil
@@ -137,68 +173,101 @@ func GetPodSpecV1(obj runtime.Object) (*kapiv1.PodSpec, *field.Path, error) {
137173
// the object contains, or false if no such object is available.
138174
func GetTemplateMetaObject(obj runtime.Object) (metav1.Object, bool) {
139175
switch r := obj.(type) {
140-
case *kapiv1.PodTemplate:
176+
177+
case *kapi.PodTemplate:
178+
return &r.Template.ObjectMeta, true
179+
case *corev1.PodTemplate:
141180
return &r.Template.ObjectMeta, true
142-
case *kapiv1.ReplicationController:
181+
182+
case *kapi.ReplicationController:
183+
if r.Spec.Template != nil {
184+
return &r.Spec.Template.ObjectMeta, true
185+
}
186+
case *corev1.ReplicationController:
143187
if r.Spec.Template != nil {
144188
return &r.Spec.Template.ObjectMeta, true
145189
}
190+
191+
case *extensions.DaemonSet:
192+
return &r.Spec.Template.ObjectMeta, true
146193
case *extensionsv1beta1.DaemonSet:
147194
return &r.Spec.Template.ObjectMeta, true
148-
case *extensionsv1beta1.Deployment:
195+
case *kappsv1.DaemonSet:
149196
return &r.Spec.Template.ObjectMeta, true
150-
case *extensionsv1beta1.ReplicaSet:
197+
case *kappsv1beta2.DaemonSet:
151198
return &r.Spec.Template.ObjectMeta, true
152-
case *batchv1.Job:
199+
200+
case *extensions.Deployment:
153201
return &r.Spec.Template.ObjectMeta, true
154-
case *batchv2alpha1.CronJob:
155-
return &r.Spec.JobTemplate.Spec.Template.ObjectMeta, true
156-
case *batchv2alpha1.JobTemplate:
157-
return &r.Template.Spec.Template.ObjectMeta, true
158-
case *appsv1beta1.StatefulSet:
202+
case *extensionsv1beta1.Deployment:
159203
return &r.Spec.Template.ObjectMeta, true
160-
case *appsv1beta1.Deployment:
204+
case *kappsv1.Deployment:
161205
return &r.Spec.Template.ObjectMeta, true
162-
case *securityv1.PodSecurityPolicySubjectReview:
206+
case *kappsv1beta1.Deployment:
163207
return &r.Spec.Template.ObjectMeta, true
164-
case *securityv1.PodSecurityPolicySelfSubjectReview:
208+
case *kappsv1beta2.Deployment:
165209
return &r.Spec.Template.ObjectMeta, true
166-
case *securityv1.PodSecurityPolicyReview:
210+
211+
case *extensions.ReplicaSet:
167212
return &r.Spec.Template.ObjectMeta, true
168-
case *appsv1.DeploymentConfig:
169-
if r.Spec.Template != nil {
170-
return &r.Spec.Template.ObjectMeta, true
171-
}
172-
case *kapi.PodTemplate:
173-
return &r.Template.ObjectMeta, true
174-
case *kapi.ReplicationController:
175-
if r.Spec.Template != nil {
176-
return &r.Spec.Template.ObjectMeta, true
177-
}
178-
case *extensions.DaemonSet:
213+
case *extensionsv1beta1.ReplicaSet:
179214
return &r.Spec.Template.ObjectMeta, true
180-
case *extensions.Deployment:
215+
case *kappsv1.ReplicaSet:
181216
return &r.Spec.Template.ObjectMeta, true
182-
case *extensions.ReplicaSet:
217+
case *kappsv1beta2.ReplicaSet:
183218
return &r.Spec.Template.ObjectMeta, true
219+
184220
case *batch.Job:
185221
return &r.Spec.Template.ObjectMeta, true
222+
case *batchv1.Job:
223+
return &r.Spec.Template.ObjectMeta, true
224+
186225
case *batch.CronJob:
187226
return &r.Spec.JobTemplate.Spec.Template.ObjectMeta, true
227+
case *batchv2alpha1.CronJob:
228+
return &r.Spec.JobTemplate.Spec.Template.ObjectMeta, true
229+
case *batchv1beta1.CronJob:
230+
return &r.Spec.JobTemplate.Spec.Template.ObjectMeta, true
231+
188232
case *batch.JobTemplate:
189233
return &r.Template.Spec.Template.ObjectMeta, true
234+
case *batchv2alpha1.JobTemplate:
235+
return &r.Template.Spec.Template.ObjectMeta, true
236+
case *batchv1beta1.JobTemplate:
237+
return &r.Template.Spec.Template.ObjectMeta, true
238+
190239
case *apps.StatefulSet:
191240
return &r.Spec.Template.ObjectMeta, true
241+
case *kappsv1.StatefulSet:
242+
return &r.Spec.Template.ObjectMeta, true
243+
case *kappsv1beta1.StatefulSet:
244+
return &r.Spec.Template.ObjectMeta, true
245+
case *kappsv1beta2.StatefulSet:
246+
return &r.Spec.Template.ObjectMeta, true
247+
192248
case *securityapi.PodSecurityPolicySubjectReview:
193249
return &r.Spec.Template.ObjectMeta, true
250+
case *securityv1.PodSecurityPolicySubjectReview:
251+
return &r.Spec.Template.ObjectMeta, true
252+
194253
case *securityapi.PodSecurityPolicySelfSubjectReview:
195254
return &r.Spec.Template.ObjectMeta, true
255+
case *securityv1.PodSecurityPolicySelfSubjectReview:
256+
return &r.Spec.Template.ObjectMeta, true
257+
196258
case *securityapi.PodSecurityPolicyReview:
197259
return &r.Spec.Template.ObjectMeta, true
260+
case *securityv1.PodSecurityPolicyReview:
261+
return &r.Spec.Template.ObjectMeta, true
262+
198263
case *appsapi.DeploymentConfig:
199264
if r.Spec.Template != nil {
200265
return &r.Spec.Template.ObjectMeta, true
201266
}
267+
case *appsv1.DeploymentConfig:
268+
if r.Spec.Template != nil {
269+
return &r.Spec.Template.ObjectMeta, true
270+
}
202271
}
203272
return nil, false
204273
}
@@ -212,7 +281,7 @@ func (m containerMutator) GetImage() string { return m.Image }
212281
func (m containerMutator) SetImage(image string) { m.Image = image }
213282

214283
type containerV1Mutator struct {
215-
*kapiv1.Container
284+
*corev1.Container
216285
}
217286

218287
func (m containerV1Mutator) GetName() string { return m.Name }
@@ -322,16 +391,16 @@ func (m *podSpecMutator) GetContainerByIndex(init bool, i int) (ContainerMutator
322391

323392
// podSpecV1Mutator implements the mutation interface over objects with a pod spec.
324393
type podSpecV1Mutator struct {
325-
spec *kapiv1.PodSpec
326-
oldSpec *kapiv1.PodSpec
394+
spec *corev1.PodSpec
395+
oldSpec *corev1.PodSpec
327396
path *field.Path
328397
}
329398

330399
func (m *podSpecV1Mutator) Path() *field.Path {
331400
return m.path
332401
}
333402

334-
func hasIdenticalPodSpecV1Image(spec *kapiv1.PodSpec, containerName, image string) bool {
403+
func hasIdenticalPodSpecV1Image(spec *corev1.PodSpec, containerName, image string) bool {
335404
if spec == nil {
336405
return false
337406
}
@@ -405,7 +474,7 @@ func (m *podSpecV1Mutator) GetContainerByName(name string) (ContainerMutator, bo
405474
}
406475

407476
func (m *podSpecV1Mutator) GetContainerByIndex(init bool, i int) (ContainerMutator, bool) {
408-
var container *kapiv1.Container
477+
var container *corev1.Container
409478
spec := m.spec
410479
if init {
411480
if i < 0 || i >= len(spec.InitContainers) {

0 commit comments

Comments
 (0)