@@ -73,8 +73,8 @@ func findLastAnsibleJob(clt client.Client, subIns *subv1.Subscription, hookType
7373
7474 klog .Infof ("total prehook/posthook ansible jobs num: %v" , len (ansibleJobList .Items ))
7575
76- for i := 0 ; i < len ( ansibleJobList .Items ); i ++ {
77- hostingAppsub , ok := ansibleJobList . Items [ i ] .Annotations [subv1 .AnnotationHosting ]
76+ for _ , ansibleJob := range ansibleJobList .Items {
77+ hostingAppsub , ok := ansibleJob .Annotations [subv1 .AnnotationHosting ]
7878
7979 if ! ok {
8080 continue
@@ -84,7 +84,7 @@ func findLastAnsibleJob(clt client.Client, subIns *subv1.Subscription, hookType
8484 continue
8585 }
8686
87- curHookType , ok := ansibleJobList . Items [ i ] .Annotations [subv1 .AnnotationHookType ]
87+ curHookType , ok := ansibleJob .Annotations [subv1 .AnnotationHookType ]
8888
8989 if ! ok {
9090 continue
@@ -94,7 +94,7 @@ func findLastAnsibleJob(clt client.Client, subIns *subv1.Subscription, hookType
9494 continue
9595 }
9696
97- hookTpl , ok := ansibleJobList . Items [ i ] .Annotations [subv1 .AnnotationHookTemplate ]
97+ hookTpl , ok := ansibleJob .Annotations [subv1 .AnnotationHookTemplate ]
9898
9999 if ! ok {
100100 continue
@@ -104,7 +104,7 @@ func findLastAnsibleJob(clt client.Client, subIns *subv1.Subscription, hookType
104104 continue
105105 }
106106
107- lastAnsibleJob := ansibleJobList . Items [ i ] .DeepCopy ()
107+ lastAnsibleJob := ansibleJob .DeepCopy ()
108108
109109 klog .Infof ("last ansible job: %v/%v, hookType: %v, hookTemplate: %v" , lastAnsibleJob .Namespace , lastAnsibleJob .Name , hookType , jobKey .String ())
110110
0 commit comments