@@ -60,6 +60,18 @@ var _ = Describe("Readiness", func() {
6060 map [string ]interface {}{
6161 "name" : "string" ,
6262 "replicas" : "integer" ,
63+ "deployment" : map [string ]interface {}{
64+ "includeAnnotations" : "boolean | default=false" ,
65+ "annotations" : map [string ]interface {}{
66+ "app" : "string | default=nginx" ,
67+ },
68+ },
69+ "service" : map [string ]interface {}{
70+ "includeAnnotations" : "boolean | default=true" ,
71+ "annotations" : map [string ]interface {}{
72+ "app" : "string | default=service" ,
73+ },
74+ },
6375 },
6476 nil ,
6577 ),
@@ -69,6 +81,8 @@ var _ = Describe("Readiness", func() {
6981 "kind" : "Deployment" ,
7082 "metadata" : map [string ]interface {}{
7183 "name" : "${schema.spec.name}" ,
84+ "annotations" : `${schema.spec.deployment.includeAnnotations == true
85+ ? schema.spec.deployment.annotations : null}` ,
7286 },
7387 "spec" : map [string ]interface {}{
7488 "replicas" : "${schema.spec.replicas}" ,
@@ -105,6 +119,8 @@ var _ = Describe("Readiness", func() {
105119 "kind" : "Service" ,
106120 "metadata" : map [string ]interface {}{
107121 "name" : "${deployment.metadata.name}" ,
122+ "annotations" : `${schema.spec.service.includeAnnotations == true
123+ ? schema.spec.service.annotations : null}` ,
108124 },
109125 "spec" : map [string ]interface {}{
110126 "selector" : map [string ]interface {}{
@@ -172,6 +188,16 @@ var _ = Describe("Readiness", func() {
172188 "spec" : map [string ]interface {}{
173189 "name" : name ,
174190 "replicas" : replicas ,
191+ "deployment" : map [string ]interface {}{
192+ "includeAnnotations" : false ,
193+ "annotations" : map [string ]interface {}{},
194+ },
195+ "service" : map [string ]interface {}{
196+ "includeAnnotations" : true ,
197+ "annotations" : map [string ]interface {}{
198+ "app" : "service" ,
199+ },
200+ },
175201 },
176202 },
177203 }
@@ -198,6 +224,7 @@ var _ = Describe("Readiness", func() {
198224 // Verify deployment specs
199225 g .Expect (deployment .Spec .Template .Spec .Containers ).To (HaveLen (1 ))
200226 g .Expect (* deployment .Spec .Replicas ).To (Equal (int32 (replicas )))
227+ g .Expect (deployment .Annotations ).To (HaveLen (0 ))
201228 }, 20 * time .Second , time .Second ).Should (Succeed ())
202229
203230 // Verify Service is not created yet
@@ -223,13 +250,18 @@ var _ = Describe("Readiness", func() {
223250 }
224251 Expect (env .Client .Status ().Update (ctx , deployment )).To (Succeed ())
225252
253+ service := & corev1.Service {}
226254 // Verify Service is created now
227255 Eventually (func (g Gomega ) {
228256 err := env .Client .Get (ctx , types.NamespacedName {
229257 Name : name ,
230258 Namespace : namespace ,
231- }, & corev1. Service {} )
259+ }, service )
232260 g .Expect (err ).ToNot (HaveOccurred ())
261+
262+ // validate service spec
263+ Expect (service .Annotations ).To (HaveLen (1 ))
264+ Expect (service .Annotations ["app" ]).To (Equal ("service" ))
233265 }, 20 * time .Second , time .Second ).Should (Succeed ())
234266
235267 // Delete instance
0 commit comments