@@ -44,6 +44,10 @@ var _ = Describe("Component image controller", func() {
4444 Name : fmt .Sprintf ("imagerepository-for-%s-%s" , defaultComponentApplication , resourceImageProvisionKey .Name ),
4545 Namespace : resourceImageProvisionKey .Namespace ,
4646 }
47+ var imageRepositoryWithoutApplicationName = types.NamespacedName {
48+ Name : fmt .Sprintf ("imagerepository-for-%s" , resourceImageProvisionKey .Name ),
49+ Namespace : resourceImageProvisionKey .Namespace ,
50+ }
4751 var applicationKey = types.NamespacedName {Name : defaultComponentApplication , Namespace : imageTestNamespace }
4852 var componentSaName = getComponentSaName (resourceImageProvisionKey .Name )
4953
@@ -74,7 +78,8 @@ var _ = Describe("Component image controller", func() {
7478 It ("should do image repository provision" , func () {
7579 expectedVisibility := imagerepositoryv1alpha1 .ImageVisibility ("private" )
7680 createComponent (componentConfig {
77- ComponentKey : resourceImageProvisionKey ,
81+ ComponentKey : resourceImageProvisionKey ,
82+ ComponentApplication : defaultComponentApplication ,
7883 Annotations : map [string ]string {
7984 GenerateImageAnnotationName : "{\" visibility\" : \" private\" }" ,
8085 },
@@ -104,10 +109,45 @@ var _ = Describe("Component image controller", func() {
104109 deleteImageRepository (imageRepositoryName )
105110 })
106111
112+ It ("should do image repository provision, component doesn't have application" , func () {
113+ expectedVisibility := imagerepositoryv1alpha1 .ImageVisibility ("private" )
114+ createComponent (componentConfig {
115+ ComponentKey : resourceImageProvisionKey ,
116+ Annotations : map [string ]string {
117+ GenerateImageAnnotationName : "{\" visibility\" : \" private\" }" ,
118+ },
119+ })
120+ // wait for component_image_controller to finish
121+ waitComponentAnnotationGone (resourceImageProvisionKey , GenerateImageAnnotationName )
122+
123+ imageRepositoriesList := & imagerepositoryv1alpha1.ImageRepositoryList {}
124+ Expect (k8sClient .List (ctx , imageRepositoriesList , & client.ListOptions {Namespace : resourceImageProvisionKey .Namespace })).To (Succeed ())
125+ Expect (imageRepositoriesList .Items ).To (HaveLen (1 ))
126+
127+ component := getComponent (resourceImageProvisionKey )
128+ // wait for imagerepository_controller to finish
129+ waitImageRepositoryFinalizerOnImageRepository (imageRepositoryWithoutApplicationName )
130+ imageRepository := getImageRepository (imageRepositoryWithoutApplicationName )
131+
132+ _ , applicationLabelExists := imageRepository .ObjectMeta .Labels [ApplicationNameLabelName ]
133+ Expect (applicationLabelExists ).To (BeFalse ())
134+ Expect (imageRepository .ObjectMeta .Labels [ComponentNameLabelName ]).To (Equal (component .Name ))
135+ Expect (imageRepository .Spec .Image .Visibility ).To (Equal (expectedVisibility ))
136+ Expect (imageRepository .ObjectMeta .OwnerReferences [0 ].UID ).To (Equal (component .UID ))
137+ Expect (imageRepository .ObjectMeta .Annotations [updateComponentAnnotationName ]).To (BeEmpty ())
138+
139+ component = getComponent (resourceImageProvisionKey )
140+ Expect (component .Annotations [ImageAnnotationName ]).To (BeEmpty ())
141+ Expect (component .Spec .ContainerImage ).ToNot (BeEmpty ())
142+
143+ deleteImageRepository (imageRepositoryWithoutApplicationName )
144+ })
145+
107146 It ("should accept deprecated true value for repository options" , func () {
108147 expectedVisibility := imagerepositoryv1alpha1 .ImageVisibility ("public" )
109148 createComponent (componentConfig {
110- ComponentKey : resourceImageProvisionKey ,
149+ ComponentKey : resourceImageProvisionKey ,
150+ ComponentApplication : defaultComponentApplication ,
111151 Annotations : map [string ]string {
112152 GenerateImageAnnotationName : "true" ,
113153 },
@@ -163,7 +203,7 @@ var _ = Describe("Component image controller", func() {
163203 })
164204
165205 It ("should do nothing if generate annotation is not set" , func () {
166- createComponent (componentConfig {ComponentKey : resourceImageErrorKey })
206+ createComponent (componentConfig {ComponentKey : resourceImageErrorKey , ComponentApplication : defaultComponentApplication })
167207
168208 time .Sleep (ensureTimeout )
169209 waitComponentAnnotationGone (resourceImageErrorKey , GenerateImageAnnotationName )
0 commit comments