@@ -363,6 +363,101 @@ func Test_flattenNodeAffinity(t *testing.T) {
363363 }
364364}
365365
366+ func Test_flattenPriceAdjustmentConfiguration (t * testing.T ) {
367+ tt := []struct {
368+ name string
369+ input * sdk.NodetemplatesV1PriceAdjustmentConfiguration
370+ want []map [string ]any
371+ }{
372+ {
373+ name : "nil input returns nil" ,
374+ input : nil ,
375+ want : nil ,
376+ },
377+ {
378+ name : "empty configuration" ,
379+ input : & sdk.NodetemplatesV1PriceAdjustmentConfiguration {},
380+ want : []map [string ]any {{}},
381+ },
382+ {
383+ name : "configuration with adjustments" ,
384+ input : & sdk.NodetemplatesV1PriceAdjustmentConfiguration {
385+ InstanceTypeAdjustments : & map [string ]string {
386+ "r7a.xlarge" : "1.0" ,
387+ "r7i.xlarge" : "1.20" ,
388+ "c6a.xlarge" : "0.90" ,
389+ },
390+ },
391+ want : []map [string ]any {
392+ {
393+ FieldNodeTemplateInstanceTypeAdjustments : map [string ]string {
394+ "r7a.xlarge" : "1.0" ,
395+ "r7i.xlarge" : "1.20" ,
396+ "c6a.xlarge" : "0.90" ,
397+ },
398+ },
399+ },
400+ },
401+ }
402+
403+ for _ , tc := range tt {
404+ t .Run (tc .name , func (t * testing.T ) {
405+ r := require .New (t )
406+ got := flattenPriceAdjustmentConfiguration (tc .input )
407+ r .Equal (tc .want , got )
408+ })
409+ }
410+ }
411+
412+ func Test_toPriceAdjustmentConfiguration (t * testing.T ) {
413+ tt := []struct {
414+ name string
415+ input map [string ]any
416+ want * sdk.NodetemplatesV1PriceAdjustmentConfiguration
417+ }{
418+ {
419+ name : "nil input returns nil" ,
420+ input : nil ,
421+ want : nil ,
422+ },
423+ {
424+ name : "empty map returns empty configuration" ,
425+ input : map [string ]any {},
426+ want : & sdk.NodetemplatesV1PriceAdjustmentConfiguration {},
427+ },
428+ {
429+ name : "map with adjustments" ,
430+ input : map [string ]any {
431+ FieldNodeTemplateInstanceTypeAdjustments : map [string ]any {
432+ "r7a.xlarge" : "1.0" ,
433+ "r7i.xlarge" : "1.20" ,
434+ },
435+ },
436+ want : & sdk.NodetemplatesV1PriceAdjustmentConfiguration {
437+ InstanceTypeAdjustments : & map [string ]string {
438+ "r7a.xlarge" : "1.0" ,
439+ "r7i.xlarge" : "1.20" ,
440+ },
441+ },
442+ },
443+ {
444+ name : "empty adjustments map" ,
445+ input : map [string ]any {
446+ FieldNodeTemplateInstanceTypeAdjustments : map [string ]any {},
447+ },
448+ want : & sdk.NodetemplatesV1PriceAdjustmentConfiguration {},
449+ },
450+ }
451+
452+ for _ , tc := range tt {
453+ t .Run (tc .name , func (t * testing.T ) {
454+ r := require .New (t )
455+ got := toPriceAdjustmentConfiguration (tc .input )
456+ r .Equal (tc .want , got )
457+ })
458+ }
459+ }
460+
366461func TestNodeTemplateResourceReadContextEmptyList (t * testing.T ) {
367462 r := require .New (t )
368463 mockctrl := gomock .NewController (t )
@@ -699,6 +794,11 @@ func TestAccEKS_ResourceNodeTemplate_basic(t *testing.T) {
699794 resource .TestCheckResourceAttr (resourceName , "edge_location_ids.#" , "2" ),
700795 resource .TestCheckResourceAttrSet (resourceName , "edge_location_ids.0" ),
701796 resource .TestCheckResourceAttrSet (resourceName , "edge_location_ids.1" ),
797+ resource .TestCheckResourceAttr (resourceName , "price_adjustment_configuration.#" , "1" ),
798+ resource .TestCheckResourceAttr (resourceName , "price_adjustment_configuration.0.instance_type_adjustments.%" , "3" ),
799+ resource .TestCheckResourceAttr (resourceName , "price_adjustment_configuration.0.instance_type_adjustments.m5.xlarge" , "1.0" ),
800+ resource .TestCheckResourceAttr (resourceName , "price_adjustment_configuration.0.instance_type_adjustments.m5.2xlarge" , "1.10" ),
801+ resource .TestCheckResourceAttr (resourceName , "price_adjustment_configuration.0.instance_type_adjustments.c5.xlarge" , "0.95" ),
702802 ),
703803 },
704804 {
@@ -781,6 +881,10 @@ func TestAccEKS_ResourceNodeTemplate_basic(t *testing.T) {
781881 resource .TestCheckResourceAttr (resourceName , "gpu.0.enable_time_sharing" , "false" ),
782882 resource .TestCheckResourceAttr (resourceName , "edge_location_ids.#" , "1" ),
783883 resource .TestCheckResourceAttrSet (resourceName , "edge_location_ids.0" ),
884+ resource .TestCheckResourceAttr (resourceName , "price_adjustment_configuration.#" , "1" ),
885+ resource .TestCheckResourceAttr (resourceName , "price_adjustment_configuration.0.instance_type_adjustments.%" , "2" ),
886+ resource .TestCheckResourceAttr (resourceName , "price_adjustment_configuration.0.instance_type_adjustments.m5.xlarge" , "1.05" ),
887+ resource .TestCheckResourceAttr (resourceName , "price_adjustment_configuration.0.instance_type_adjustments.r5.xlarge" , "0.90" ),
784888 ),
785889 },
786890 },
@@ -830,6 +934,14 @@ func testAccNodeTemplateConfig(rName, clusterName string) string {
830934
831935 edge_location_ids = [castai_edge_location.test_1.id, castai_edge_location.test_2.id]
832936
937+ price_adjustment_configuration {
938+ instance_type_adjustments = {
939+ "m5.xlarge" = "1.0"
940+ "m5.2xlarge" = "1.10"
941+ "c5.xlarge" = "0.95"
942+ }
943+ }
944+
833945 constraints {
834946 fallback_restore_rate_seconds = 1800
835947 spot = true
@@ -973,6 +1085,13 @@ func testNodeTemplateUpdated(rName, clusterName string) string {
9731085
9741086 edge_location_ids = [castai_edge_location.test_2.id]
9751087
1088+ price_adjustment_configuration {
1089+ instance_type_adjustments = {
1090+ "m5.xlarge" = "1.05"
1091+ "r5.xlarge" = "0.90"
1092+ }
1093+ }
1094+
9761095 constraints {
9771096 use_spot_fallbacks = true
9781097 spot = true
0 commit comments