@@ -53,7 +53,9 @@ func TestPod_Generate(t *testing.T) {
5353 Labels : map [string ]string {
5454 "foo" : "bar" ,
5555 },
56- Annotations : map [string ]string {},
56+ Annotations : map [string ]string {
57+ "app" : "production" ,
58+ },
5759 },
5860 TypeMeta : metav1.TypeMeta {
5961 Kind : "Pod" ,
@@ -71,6 +73,9 @@ func TestPod_Generate(t *testing.T) {
7173 "labels" : common.MapStr {
7274 "foo" : "bar" ,
7375 },
76+ "annotations" : common.MapStr {
77+ "app" : "production" ,
78+ },
7479 "namespace" : "default" ,
7580 "node" : common.MapStr {
7681 "name" : "testnode" ,
@@ -87,7 +92,9 @@ func TestPod_Generate(t *testing.T) {
8792 Labels : map [string ]string {
8893 "foo" : "bar" ,
8994 },
90- Annotations : map [string ]string {},
95+ Annotations : map [string ]string {
96+ "app" : "production" ,
97+ },
9198 OwnerReferences : []metav1.OwnerReference {
9299 {
93100 APIVersion : "apps" ,
@@ -121,12 +128,19 @@ func TestPod_Generate(t *testing.T) {
121128 "labels" : common.MapStr {
122129 "foo" : "bar" ,
123130 },
131+ "annotations" : common.MapStr {
132+ "app" : "production" ,
133+ },
124134 },
125135 },
126136 }
127137
128- cfg := common .NewConfig ()
129- metagen := NewPodMetadataGenerator (cfg , nil , nil , nil )
138+ config , err := common .NewConfigFrom (map [string ]interface {}{
139+ "include_annotations" : []string {"app" },
140+ })
141+ assert .Nil (t , err )
142+
143+ metagen := NewPodMetadataGenerator (config , nil , nil , nil )
130144 for _ , test := range tests {
131145 t .Run (test .name , func (t * testing.T ) {
132146 assert .Equal (t , test .output , metagen .Generate (test .input ))
@@ -154,7 +168,9 @@ func TestPod_GenerateFromName(t *testing.T) {
154168 Labels : map [string ]string {
155169 "foo" : "bar" ,
156170 },
157- Annotations : map [string ]string {},
171+ Annotations : map [string ]string {
172+ "app" : "production" ,
173+ },
158174 },
159175 TypeMeta : metav1.TypeMeta {
160176 Kind : "Pod" ,
@@ -176,6 +192,9 @@ func TestPod_GenerateFromName(t *testing.T) {
176192 "labels" : common.MapStr {
177193 "foo" : "bar" ,
178194 },
195+ "annotations" : common.MapStr {
196+ "app" : "production" ,
197+ },
179198 },
180199 },
181200 {
@@ -188,7 +207,9 @@ func TestPod_GenerateFromName(t *testing.T) {
188207 Labels : map [string ]string {
189208 "foo" : "bar" ,
190209 },
191- Annotations : map [string ]string {},
210+ Annotations : map [string ]string {
211+ "app" : "production" ,
212+ },
192213 OwnerReferences : []metav1.OwnerReference {
193214 {
194215 APIVersion : "apps" ,
@@ -222,15 +243,21 @@ func TestPod_GenerateFromName(t *testing.T) {
222243 "labels" : common.MapStr {
223244 "foo" : "bar" ,
224245 },
246+ "annotations" : common.MapStr {
247+ "app" : "production" ,
248+ },
225249 },
226250 },
227251 }
228252
229253 for _ , test := range tests {
230- cfg := common .NewConfig ()
254+ config , err := common .NewConfigFrom (map [string ]interface {}{
255+ "include_annotations" : []string {"app" },
256+ })
257+ assert .Nil (t , err )
231258 pods := cache .NewStore (cache .MetaNamespaceKeyFunc )
232259 pods .Add (test .input )
233- metagen := NewPodMetadataGenerator (cfg , pods , nil , nil )
260+ metagen := NewPodMetadataGenerator (config , pods , nil , nil )
234261
235262 accessor , err := meta .Accessor (test .input )
236263 require .Nil (t , err )
@@ -262,7 +289,9 @@ func TestPod_GenerateWithNodeNamespace(t *testing.T) {
262289 Labels : map [string ]string {
263290 "foo" : "bar" ,
264291 },
265- Annotations : map [string ]string {},
292+ Annotations : map [string ]string {
293+ "app" : "production" ,
294+ },
266295 },
267296 TypeMeta : metav1.TypeMeta {
268297 Kind : "Pod" ,
@@ -320,24 +349,30 @@ func TestPod_GenerateWithNodeNamespace(t *testing.T) {
320349 "labels" : common.MapStr {
321350 "foo" : "bar" ,
322351 },
352+ "annotations" : common.MapStr {
353+ "app" : "production" ,
354+ },
323355 },
324356 },
325357 }
326358
327359 for _ , test := range tests {
328- cfg := common .NewConfig ()
360+ config , err := common .NewConfigFrom (map [string ]interface {}{
361+ "include_annotations" : []string {"app" },
362+ })
363+ assert .Nil (t , err )
329364 pods := cache .NewStore (cache .MetaNamespaceKeyFunc )
330365 pods .Add (test .input )
331366
332367 nodes := cache .NewStore (cache .MetaNamespaceKeyFunc )
333368 nodes .Add (test .node )
334- nodeMeta := NewNodeMetadataGenerator (cfg , nodes )
369+ nodeMeta := NewNodeMetadataGenerator (config , nodes )
335370
336371 namespaces := cache .NewStore (cache .MetaNamespaceKeyFunc )
337372 namespaces .Add (test .namespace )
338- nsMeta := NewNamespaceMetadataGenerator (cfg , namespaces )
373+ nsMeta := NewNamespaceMetadataGenerator (config , namespaces )
339374
340- metagen := NewPodMetadataGenerator (cfg , pods , nodeMeta , nsMeta )
375+ metagen := NewPodMetadataGenerator (config , pods , nodeMeta , nsMeta )
341376 t .Run (test .name , func (t * testing.T ) {
342377 assert .Equal (t , test .output , metagen .Generate (test .input ))
343378 })
0 commit comments