@@ -62,6 +62,7 @@ func TestMapDataSourceFields(t *testing.T) {
6262 Protected : new (true ),
6363 Scope : new ("scope "),
6464 Config : & iaas.ImageConfig {
65+ Architecture : new ("x86 "),
6566 BootMenu : new (true ),
6667 CdromBus : * iaas .NewNullableString (new ("cdrom_bus ")),
6768 DiskBus : * iaas .NewNullableString (new ("disk_bus ")),
@@ -97,6 +98,7 @@ func TestMapDataSourceFields(t *testing.T) {
9798 Protected : types .BoolValue (true ),
9899 Scope : types .StringValue ("scope" ),
99100 Config : types .ObjectValueMust (configTypes , map [string ]attr.Value {
101+ "architecture" : types .StringValue ("x86" ),
100102 "boot_menu" : types .BoolValue (true ),
101103 "cdrom_bus" : types .StringValue ("cdrom_bus" ),
102104 "disk_bus" : types .StringValue ("disk_bus" ),
@@ -206,14 +208,16 @@ func TestImageMatchesFilter(t *testing.T) {
206208 OperatingSystemVersion : * iaas .NewNullableString (new ("22.04 ")),
207209 Uefi : new (true ),
208210 SecureBoot : new (true ),
211+ Architecture : new ("x86 "),
209212 },
210213 },
211214 filter : & Filter {
212- OS : types .StringValue ("linux" ),
213- Distro : types .StringValue ("ubuntu" ),
214- Version : types .StringValue ("22.04" ),
215- UEFI : types .BoolValue (true ),
216- SecureBoot : types .BoolValue (true ),
215+ OS : types .StringValue ("linux" ),
216+ Distro : types .StringValue ("ubuntu" ),
217+ Version : types .StringValue ("22.04" ),
218+ UEFI : types .BoolValue (true ),
219+ SecureBoot : types .BoolValue (true ),
220+ Architecture : types .StringValue ("x86" ),
217221 },
218222 expected : true ,
219223 },
@@ -313,6 +317,66 @@ func TestImageMatchesFilter(t *testing.T) {
313317 },
314318 expected : false ,
315319 },
320+ {
321+ name : "Architecture match x86" ,
322+ img : & iaas.Image {
323+ Config : & iaas.ImageConfig {
324+ Architecture : new ("x86 "),
325+ },
326+ },
327+ filter : & Filter {
328+ Architecture : types .StringValue ("x86" ),
329+ },
330+ expected : true ,
331+ },
332+ {
333+ name : "Architecture match arm64" ,
334+ img : & iaas.Image {
335+ Config : & iaas.ImageConfig {
336+ Architecture : new ("arm64 "),
337+ },
338+ },
339+ filter : & Filter {
340+ Architecture : types .StringValue ("arm64" ),
341+ },
342+ expected : true ,
343+ },
344+ {
345+ name : "Architecture mismatch" ,
346+ img : & iaas.Image {
347+ Config : & iaas.ImageConfig {
348+ Architecture : new ("arm64 "),
349+ },
350+ },
351+ filter : & Filter {
352+ Architecture : types .StringValue ("x86" ),
353+ },
354+ expected : false ,
355+ },
356+ {
357+ name : "Architecture filter set but image has nil architecture" ,
358+ img : & iaas.Image {
359+ Config : & iaas.ImageConfig {
360+ Architecture : nil ,
361+ },
362+ },
363+ filter : & Filter {
364+ Architecture : types .StringValue ("x86" ),
365+ },
366+ expected : false ,
367+ },
368+ {
369+ name : "Architecture filter null skip check" ,
370+ img : & iaas.Image {
371+ Config : & iaas.ImageConfig {
372+ Architecture : new ("arm64 "),
373+ },
374+ },
375+ filter : & Filter {
376+ Architecture : types .StringNull (),
377+ },
378+ expected : true ,
379+ },
316380 {
317381 name : "partial filter match - only distro set and match" ,
318382 img : & iaas.Image {
@@ -358,14 +422,16 @@ func TestImageMatchesFilter(t *testing.T) {
358422 OperatingSystemVersion : * iaas .NewNullableString (new ("22.04 ")),
359423 Uefi : new (false ),
360424 SecureBoot : new (false ),
425+ Architecture : new ("x86 "),
361426 },
362427 },
363428 filter : & Filter {
364- OS : types .StringNull (),
365- Distro : types .StringNull (),
366- Version : types .StringNull (),
367- UEFI : types .BoolNull (),
368- SecureBoot : types .BoolNull (),
429+ OS : types .StringNull (),
430+ Distro : types .StringNull (),
431+ Version : types .StringNull (),
432+ UEFI : types .BoolNull (),
433+ SecureBoot : types .BoolNull (),
434+ Architecture : types .StringNull (),
369435 },
370436 expected : true ,
371437 },
@@ -378,14 +444,16 @@ func TestImageMatchesFilter(t *testing.T) {
378444 OperatingSystemVersion : * iaas .NewNullableString (nil ),
379445 Uefi : nil ,
380446 SecureBoot : nil ,
447+ Architecture : nil ,
381448 },
382449 },
383450 filter : & Filter {
384- OS : types .StringValue ("linux" ),
385- Distro : types .StringValue ("ubuntu" ),
386- Version : types .StringValue ("22.04" ),
387- UEFI : types .BoolValue (true ),
388- SecureBoot : types .BoolValue (true ),
451+ OS : types .StringValue ("linux" ),
452+ Distro : types .StringValue ("ubuntu" ),
453+ Version : types .StringValue ("22.04" ),
454+ UEFI : types .BoolValue (true ),
455+ SecureBoot : types .BoolValue (true ),
456+ Architecture : types .StringValue ("x86" ),
389457 },
390458 expected : false ,
391459 },
0 commit comments