Skip to content

Commit 3663f05

Browse files
committed
🎨 Misc fixes.
Not sure the new test will work in CI but going to try it.
1 parent 5044284 commit 3663f05

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

‎components/migrations.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,8 @@ func (comp *migrationsComponent) Reconcile(ctx *cu.Context) (cu.Result, error) {
210210

211211
// Purge any migration wait initContainers since that would be a yodawg situation.
212212
initContainers := []map[string]interface{}{}
213-
migrationInitContainers := migrationPodSpec["initContainers"].([]interface{})
214-
if migrationInitContainers != nil {
215-
for _, c := range migrationInitContainers {
213+
if migrationPodSpec["initContainers"] != nil {
214+
for _, c := range migrationPodSpec["initContainers"].([]interface{}) {
216215
container := c.(map[string]interface{})
217216
if !strings.HasPrefix(container["name"].(string), "migrate-wait-") {
218217
initContainers = append(initContainers, container)
@@ -250,7 +249,7 @@ func (comp *migrationsComponent) Reconcile(ctx *cu.Context) (cu.Result, error) {
250249
migrationJob.SetLabels(obj.Labels)
251250
migrationJob.UnstructuredContent()["spec"] = map[string]interface{}{
252251
"template": map[string]interface{}{
253-
"meta": map[string]interface{}{
252+
"metadata": map[string]interface{}{
254253
"labels": jobTemplateLabels,
255254
"annotations": jobTemplateAnnotations,
256255
},
@@ -346,7 +345,7 @@ func (_ *migrationsComponent) findOwners(ctx *cu.Context, obj *unstructured.Unst
346345
break
347346
}
348347
gvk := schema.FromAPIVersionAndKind(ref.APIVersion, ref.Kind)
349-
obj := &unstructured.Unstructured{}
348+
obj = &unstructured.Unstructured{}
350349
obj.SetGroupVersionKind(gvk)
351350
obj.SetName(ref.Name) // Is this needed?
352351
err := ctx.Client.Get(ctx, types.NamespacedName{Name: ref.Name, Namespace: namespace}, obj)
@@ -376,14 +375,14 @@ func (_ *migrationsComponent) findSpecFor(ctx *cu.Context, obj *unstructured.Uns
376375
return template["spec"].(map[string]interface{})
377376
case "argoproj.io/Rollout":
378377
spec := obj.UnstructuredContent()["spec"].(map[string]interface{})
379-
workloadRef := spec["workloadRef"].(map[string]interface{})
380-
if workloadRef != nil {
378+
if spec["workloadRef"] != nil {
379+
workloadRef := spec["workloadRef"].(map[string]interface{})
381380
workloadKind := workloadRef["kind"].(string)
382381
if workloadKind == "Deployment" {
383382
deployment := &unstructured.Unstructured{}
384383
deployment.SetAPIVersion(workloadRef["apiVersion"].(string))
385384
deployment.SetKind(workloadKind)
386-
err := ctx.Client.Get(ctx, types.NamespacedName{Name: workloadRef["name"].(string), Namespace: obj.GetNamespace()}, obj)
385+
err := ctx.Client.Get(ctx, types.NamespacedName{Name: workloadRef["name"].(string), Namespace: obj.GetNamespace()}, deployment)
387386
if err != nil {
388387
return nil
389388
}

‎components/migrations_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ var _ = Describe("Migrations component", func() {
406406

407407
helper.TestClient.Create(upod)
408408
helper.MustReconcile()
409-
Expect(helper.Events).To(Receive(Equal("Normal MigrationsStarted Started migration job default/testing-migrations using image myapp:latest")))
409+
Expect(helper.Events).To(Receive(Equal("Normal MigrationsStarted Started migration job default/testing-migrations using image fake")))
410410
Expect(obj).To(HaveCondition("MigrationsReady").WithReason("MigrationsRunning").WithStatus("False"))
411411

412412
ujob := &unstructured.Unstructured{}
@@ -415,9 +415,11 @@ var _ = Describe("Migrations component", func() {
415415
spec := ujob.UnstructuredContent()["spec"].(map[string]interface{})
416416
template := spec["template"].(map[string]interface{})
417417
tSpec := template["spec"].(map[string]interface{})
418-
initContainers := tSpec["initContainers"].([]map[string]interface{})
419-
containers := tSpec["containers"].([]map[string]interface{})
420-
Expect(containers[0]["name"]).To(Equal("migrations"))
421-
Expect(initContainers[0]["restartPolicy"]).To(Equal("Always"))
418+
initContainers := (tSpec["initContainers"].([]interface{}))
419+
containers := tSpec["containers"].([]interface{})
420+
initContainer := initContainers[0].(map[string]interface{})
421+
container := containers[0].(map[string]interface{})
422+
Expect(initContainer["restartPolicy"]).To(Equal("Always"))
423+
Expect(container["name"]).To(Equal("migrations"))
422424
})
423425
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy