@@ -71,12 +71,12 @@ const (
7171Automation: {{ .AutomationObject }}
7272
7373Files:
74- {{ range $filename, $_ := .Updated .Files -}}
74+ {{ range $filename, $_ := .Changed.ImageResult .Files -}}
7575- {{ $filename }}
7676{{ end -}}
7777
7878Objects:
79- {{ range $resource, $_ := .Updated .Objects -}}
79+ {{ range $resource, $_ := .Changed.ImageResult .Objects -}}
8080{{ if eq $resource.Kind "Deployment" -}}
8181- {{ $resource.Kind | lower }} {{ $resource.Name | lower }}
8282{{ else -}}
@@ -85,7 +85,7 @@ Objects:
8585{{ end -}}
8686
8787Images:
88- {{ range .Updated .Images -}}
88+ {{ range .Changed.ImageResult .Images -}}
8989- {{.}} ({{.Policy.Name}})
9090{{ end -}}
9191`
@@ -841,6 +841,98 @@ Automation: %s/update-test
841841 }
842842}
843843
844+ // TestImageUpdateAutomationReconciler_deprecatedTemplateField tests deprecated .Updated template field usage.
845+ // TODO: Remove this test function after .Updated template field is completely removed from the API.
846+ func TestImageUpdateAutomationReconciler_deprecatedTemplateField (t * testing.T ) {
847+ g := NewWithT (t )
848+ ctx := context .TODO ()
849+
850+ policySpec := imagev1_reflect.ImagePolicySpec {
851+ ImageRepositoryRef : meta.NamespacedObjectReference {
852+ Name : "not-expected-to-exist" ,
853+ },
854+ Policy : imagev1_reflect.ImagePolicyChoice {
855+ SemVer : & imagev1_reflect.SemVerPolicy {
856+ Range : "1.x" ,
857+ },
858+ },
859+ }
860+ fixture := "testdata/appconfig"
861+ latest := "helloworld:v1.0.0"
862+
863+ deprecatedTemplate := `Commit summary
864+
865+ Automation: {{ .AutomationObject }}
866+
867+ Files:
868+ {{ range $filename, $_ := .Updated.Files -}}
869+ - {{ $filename }}
870+ {{ end -}}
871+
872+ Objects:
873+ {{ range $resource, $_ := .Updated.Objects -}}
874+ {{ if eq $resource.Kind "Deployment" -}}
875+ - {{ $resource.Kind | lower }} {{ $resource.Name | lower }}
876+ {{ else -}}
877+ - {{ $resource.Kind }} {{ $resource.Name }}
878+ {{ end -}}
879+ {{ end -}}
880+
881+ Images:
882+ {{ range .Updated.Images -}}
883+ - {{.}} ({{.Policy.Name}})
884+ {{ end -}}
885+ `
886+
887+ namespace , err := testEnv .CreateNamespace (ctx , "image-auto-test" )
888+ g .Expect (err ).ToNot (HaveOccurred ())
889+ defer func () { g .Expect (testEnv .Delete (ctx , namespace )).To (Succeed ()) }()
890+
891+ testWithRepoAndImagePolicy (
892+ ctx , g , testEnv , namespace .Name , fixture , policySpec , latest ,
893+ func (g * WithT , s repoAndPolicyArgs , repoURL string , localRepo * extgogit.Repository ) {
894+ policyKey := types.NamespacedName {
895+ Name : s .imagePolicyName ,
896+ Namespace : s .namespace ,
897+ }
898+ _ = testutil .CommitInRepo (ctx , g , repoURL , s .branch , originRemote , "Install setter marker" , func (tmp string ) {
899+ g .Expect (testutil .ReplaceMarker (filepath .Join (tmp , "deploy.yaml" ), policyKey )).To (Succeed ())
900+ })
901+
902+ preChangeCommitId := testutil .CommitIdFromBranch (localRepo , s .branch )
903+ waitForNewHead (g , localRepo , s .branch , preChangeCommitId )
904+ preChangeCommitId = testutil .CommitIdFromBranch (localRepo , s .branch )
905+
906+ updateStrategy := & imagev1.UpdateStrategy {
907+ Strategy : imagev1 .UpdateStrategySetters ,
908+ }
909+ err := createImageUpdateAutomation (ctx , testEnv , "update-test" , s .namespace , s .gitRepoName , s .gitRepoNamespace , s .branch , s .branch , "" , deprecatedTemplate , "" , updateStrategy )
910+ g .Expect (err ).ToNot (HaveOccurred ())
911+ defer func () {
912+ g .Expect (deleteImageUpdateAutomation (ctx , testEnv , "update-test" , s .namespace )).To (Succeed ())
913+ }()
914+
915+ imageUpdateKey := types.NamespacedName {
916+ Namespace : s .namespace ,
917+ Name : "update-test" ,
918+ }
919+
920+ g .Eventually (func () bool {
921+ var imageUpdate imagev1.ImageUpdateAutomation
922+ _ = testEnv .Get (context .TODO (), imageUpdateKey , & imageUpdate )
923+ stalledCondition := apimeta .FindStatusCondition (imageUpdate .Status .Conditions , meta .StalledCondition )
924+ return stalledCondition != nil &&
925+ stalledCondition .Status == metav1 .ConditionTrue &&
926+ stalledCondition .Reason == imagev1 .DeprecatedTemplateFieldReason &&
927+ strings .Contains (stalledCondition .Message , "template uses deprecated '.Updated' field" )
928+ }, timeout ).Should (BeTrue ())
929+
930+ head , _ := localRepo .Head ()
931+ g .Expect (head .Hash ().String ()).To (Equal (preChangeCommitId ))
932+ },
933+ )
934+ }
935+
844936func TestImageUpdateAutomationReconciler_crossNamespaceRef (t * testing.T ) {
845937 g := NewWithT (t )
846938 policySpec := imagev1_reflect.ImagePolicySpec {
0 commit comments