Skip to content

Commit fb1c024

Browse files
address comments
1 parent 6607c80 commit fb1c024

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

cmd/clusterctl/pkg/client/repository/components.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,10 @@ func inspectImages(objs []unstructured.Unstructured) ([]string, error) {
550550
for _, c := range d.Spec.Template.Spec.Containers {
551551
images = append(images, c.Image)
552552
}
553+
554+
for _, c := range d.Spec.Template.Spec.InitContainers {
555+
images = append(images, c.Image)
556+
}
553557
}
554558
}
555559

cmd/clusterctl/pkg/client/repository/components_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,39 @@ func Test_inspectImages(t *testing.T) {
804804
want: []string{"gcr.io/k8s-staging-cluster-api/cluster-api-controller:master", "gcr.io/kubebuilder/kube-rbac-proxy:v0.4.1"},
805805
wantErr: false,
806806
},
807+
{
808+
name: "controller with init container",
809+
args: args{
810+
objs: []unstructured.Unstructured{
811+
{
812+
Object: map[string]interface{}{
813+
"apiVersion": "apps/v1",
814+
"kind": deploymentKind,
815+
"spec": map[string]interface{}{
816+
"template": map[string]interface{}{
817+
"spec": map[string]interface{}{
818+
"containers": []map[string]interface{}{
819+
{
820+
"name": controllerContainerName,
821+
"image": "gcr.io/k8s-staging-cluster-api/cluster-api-controller:master",
822+
},
823+
},
824+
"initContainers": []map[string]interface{}{
825+
{
826+
"name": controllerContainerName,
827+
"image": "gcr.io/k8s-staging-cluster-api/cluster-api-controller:init",
828+
},
829+
},
830+
},
831+
},
832+
},
833+
},
834+
},
835+
},
836+
},
837+
want: []string{"gcr.io/k8s-staging-cluster-api/cluster-api-controller:master", "gcr.io/k8s-staging-cluster-api/cluster-api-controller:init"},
838+
wantErr: false,
839+
},
807840
}
808841
for _, tt := range tests {
809842
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)