@@ -88,6 +88,11 @@ func mergeInputs[T any]() (*T, error) {
8888 fmt .Println (string (data ))
8989 }
9090
91+ data , err = transformAllOverrideModeForNodeSet (data )
92+ if err != nil {
93+ return nil , fmt .Errorf ("error transforming node specs: %w" , err )
94+ }
95+
9196 decoder := toml .NewDecoder (strings .NewReader (string (data )))
9297 decoder .DisallowUnknownFields ()
9398
@@ -141,6 +146,41 @@ func validate(s interface{}) error {
141146 return nil
142147}
143148
149+ // transformAllOverrideModeForNodeSet we need this function so the test logic can be the same in both "each" and "all" override modes
150+ // we can't do UnmarshalTOML or UnmarshalText because our TOML library do not support it
151+ func transformAllOverrideModeForNodeSet (data []byte ) ([]byte , error ) {
152+ var config map [string ]interface {}
153+ if err := toml .Unmarshal (data , & config ); err != nil {
154+ return nil , err
155+ }
156+ nodeset , ok := config ["nodeset" ].(map [string ]interface {})
157+ if ! ok {
158+ return data , nil
159+ }
160+ if nodeset ["override_mode" ] != "all" {
161+ return data , nil
162+ }
163+ nodes , ok := nodeset ["nodes" ].(int64 )
164+ if ! ok || nodes <= 0 {
165+ return nil , fmt .Errorf ("invalid nodes count" )
166+ }
167+ specs , ok := nodeset ["node_specs" ].([]interface {})
168+ if ! ok || len (specs ) == 0 {
169+ return nil , fmt .Errorf ("node_specs must be provided" )
170+ }
171+ firstSpec := specs [0 ].(map [string ]interface {})
172+ expanded := make ([]interface {}, nodes )
173+ for i := range expanded {
174+ newSpec := make (map [string ]interface {})
175+ for k , v := range firstSpec {
176+ newSpec [k ] = v
177+ }
178+ expanded [i ] = newSpec
179+ }
180+ nodeset ["node_specs" ] = expanded
181+ return toml .Marshal (config )
182+ }
183+
144184func Load [X any ](t * testing.T ) (* X , error ) {
145185 input , err := mergeInputs [X ]()
146186 if err != nil {
0 commit comments