@@ -727,55 +727,120 @@ var _ = Describe("getRolloutsContainerImage tests", func() {
727727	})
728728
729729	AfterEach (func () {
730- 		a  =  * makeTestRolloutManager ()
731730		os .Unsetenv ("ARGO_ROLLOUTS_IMAGE" ) // Ensure env variable is not set unless needed 
732731	})
733732
734733	When ("the spec Image and Version are empty" , func () {
735734		It ("returns the default image and tag combined" , func () {
736735			a .Spec .Image  =  "" 
737736			a .Spec .Version  =  "" 
738- 			Expect (getRolloutsContainerImage (a )).To (Equal (DefaultArgoRolloutsImage  +  ":"  +  DefaultArgoRolloutsVersion ))
737+ 			img , err  :=  getRolloutsContainerImage (a )
738+ 			Expect (err ).ToNot (HaveOccurred ())
739+ 			Expect (img ).To (Equal (DefaultArgoRolloutsImage  +  ":"  +  DefaultArgoRolloutsVersion ))
739740		})
740741	})
741742
742743	When ("the spec Image is set but Version is empty" , func () {
743744		It ("returns the custom image with the default tag" , func () {
744745			a .Spec .Image  =  "custom-image" 
745- 			Expect (getRolloutsContainerImage (a )).To (Equal ("custom-image:"  +  DefaultArgoRolloutsVersion ))
746+ 			a .Spec .Version  =  "" 
747+ 			img , err  :=  getRolloutsContainerImage (a )
748+ 			Expect (err ).ToNot (HaveOccurred ())
749+ 			Expect (img ).To (Equal ("custom-image:"  +  DefaultArgoRolloutsVersion ))
746750		})
747751	})
748752
749753	When ("the spec Image is empty but Version is set" , func () {
750754		It ("returns the default image with the custom tag" , func () {
755+ 			a .Spec .Image  =  "" 
751756			a .Spec .Version  =  "custom-tag" 
752- 			Expect (getRolloutsContainerImage (a )).To (Equal (DefaultArgoRolloutsImage  +  ":custom-tag" ))
757+ 			img , err  :=  getRolloutsContainerImage (a )
758+ 			Expect (err ).ToNot (HaveOccurred ())
759+ 			Expect (img ).To (Equal (DefaultArgoRolloutsImage  +  ":custom-tag" ))
753760		})
754761	})
755762
756763	When ("both spec Image and Version are set" , func () {
757764		It ("returns the custom image and custom tag combined" , func () {
758765			a .Spec .Image  =  "custom-image" 
759766			a .Spec .Version  =  "custom-tag" 
760- 			Expect (getRolloutsContainerImage (a )).To (Equal ("custom-image:custom-tag" ))
767+ 			img , err  :=  getRolloutsContainerImage (a )
768+ 			Expect (err ).ToNot (HaveOccurred ())
769+ 			Expect (img ).To (Equal ("custom-image:custom-tag" ))
761770		})
762771	})
763772
764773	When ("the environment variable is set and spec is empty" , func () {
765774		It ("returns the environment variable image" , func () {
766- 			os .Setenv ("ARGO_ROLLOUTS_IMAGE" , "env-image" )
767- 			Expect (getRolloutsContainerImage (a )).To (Equal ("env-image" ))
775+ 			a .Spec .Image  =  "" 
776+ 			a .Spec .Version  =  "" 
777+ 			os .Setenv ("ARGO_ROLLOUTS_IMAGE" , "quay.io/argoproj/argo-rollouts-custom:latest@sha256:841328df1b9f8c4087adbdcfec6cc99ac8308805dea83f6d415d6fb8d40227c1" )
778+ 
779+ 			img , err  :=  getRolloutsContainerImage (a )
780+ 			Expect (err ).ToNot (HaveOccurred ())
781+ 			Expect (img ).To (Equal ("quay.io/argoproj/argo-rollouts-custom:latest@sha256:841328df1b9f8c4087adbdcfec6cc99ac8308805dea83f6d415d6fb8d40227c1" ))
782+ 		})
783+ 	})
784+ 
785+ 	When ("the environment variable is set and version is set, but env contains unparseable image" , func () {
786+ 		It ("returns an error" , func () {
787+ 			a .Spec .Image  =  "" 
788+ 			a .Spec .Version  =  "custom-tag" 
789+ 			os .Setenv ("ARGO_ROLLOUTS_IMAGE" , "quay.io/argoproj/argo-rollouts-custom:latest@sha256:invalidsha256" )
790+ 
791+ 			_ , err  :=  getRolloutsContainerImage (a )
792+ 			Expect (err ).To (HaveOccurred ())
793+ 		})
794+ 	})
795+ 
796+ 	When ("the environment variable is set and image/version are set, but env contains unparseable image" , func () {
797+ 		It ("does not return an error since env var does not need to be parsed" , func () {
798+ 			a .Spec .Image  =  "custom-image" 
799+ 			a .Spec .Version  =  "custom-tag" 
800+ 			os .Setenv ("ARGO_ROLLOUTS_IMAGE" , "quay.io/argoproj/argo-rollouts-custom:latest@sha256:invalidsha256" )
801+ 
802+ 			img , err  :=  getRolloutsContainerImage (a )
803+ 			Expect (err ).ToNot (HaveOccurred ())
804+ 			Expect (img ).To (Equal ("custom-image:custom-tag" ))
768805		})
769806	})
770807
771808	When ("the environment variable is set but spec is not empty" , func () {
772809		It ("returns the custom image and tag ignoring the environment variable" , func () {
773810			a .Spec .Image  =  "custom-image" 
774811			a .Spec .Version  =  "custom-tag" 
775- 			os .Setenv ("ARGO_ROLLOUTS_IMAGE" , "env-image" )
776- 			Expect (getRolloutsContainerImage (a )).To (Equal ("custom-image:custom-tag" ))
812+ 			os .Setenv ("ARGO_ROLLOUTS_IMAGE" , "quay.io/argoproj/argo-rollouts-custom:latest" )
813+ 			img , err  :=  getRolloutsContainerImage (a )
814+ 			Expect (err ).ToNot (HaveOccurred ())
815+ 
816+ 			Expect (img ).To (Equal ("custom-image:custom-tag" ))
777817		})
778818	})
819+ 
820+ 	When ("the environment variable is set, and spec version is set" , func () {
821+ 		It ("returns the env var image with tag from spec" , func () {
822+ 			a .Spec .Image  =  "" 
823+ 			a .Spec .Version  =  "custom-tag" 
824+ 			os .Setenv ("ARGO_ROLLOUTS_IMAGE" , "quay.io/argoproj/argo-rollouts-custom:latest" )
825+ 
826+ 			img , err  :=  getRolloutsContainerImage (a )
827+ 			Expect (err ).ToNot (HaveOccurred ())
828+ 			Expect (img ).To (Equal ("quay.io/argoproj/argo-rollouts-custom:custom-tag" ))
829+ 		})
830+ 	})
831+ 
832+ 	When ("the environment variable is set with a full sha256 value, and spec version is set" , func () {
833+ 		It ("returns the env var image with tag from spec" , func () {
834+ 			a .Spec .Image  =  "" 
835+ 			a .Spec .Version  =  "custom-tag" 
836+ 			os .Setenv ("ARGO_ROLLOUTS_IMAGE" , "quay.io/argoproj/argo-rollouts-custom:latest@sha256:841328df1b9f8c4087adbdcfec6cc99ac8308805dea83f6d415d6fb8d40227c1" )
837+ 
838+ 			img , err  :=  getRolloutsContainerImage (a )
839+ 			Expect (err ).ToNot (HaveOccurred ())
840+ 			Expect (img ).To (Equal ("quay.io/argoproj/argo-rollouts-custom:custom-tag" ))
841+ 		})
842+ 	})
843+ 
779844})
780845
781846var  _  =  Describe ("rolloutsContainer tests" , func () {
0 commit comments