@@ -27,6 +27,7 @@ import (
27
27
"github.com/coreos/ign-converter/translate/v32tov31"
28
28
"github.com/coreos/ign-converter/translate/v33tov32"
29
29
"github.com/coreos/ign-converter/translate/v34tov33"
30
+ "github.com/coreos/ign-converter/translate/v35tov34"
30
31
ign2error "github.com/coreos/ignition/config/shared/errors"
31
32
ign2 "github.com/coreos/ignition/config/v2_2"
32
33
ign2types "github.com/coreos/ignition/config/v2_2/types"
@@ -39,11 +40,13 @@ import (
39
40
ign3_2types "github.com/coreos/ignition/v2/config/v3_2/types"
40
41
translate3_3 "github.com/coreos/ignition/v2/config/v3_3/translate"
41
42
ign3_3types "github.com/coreos/ignition/v2/config/v3_3/types"
43
+ translate3_4 "github.com/coreos/ignition/v2/config/v3_4/translate"
44
+ ign3_4types "github.com/coreos/ignition/v2/config/v3_4/types"
42
45
43
- ign3 "github.com/coreos/ignition/v2/config/v3_4 "
44
- ign3_4 "github.com/coreos/ignition/v2/config/v3_4 "
45
- translate3 "github.com/coreos/ignition/v2/config/v3_4 /translate"
46
- ign3types "github.com/coreos/ignition/v2/config/v3_4 /types"
46
+ ign3 "github.com/coreos/ignition/v2/config/v3_5 "
47
+ ign3_5 "github.com/coreos/ignition/v2/config/v3_5 "
48
+ translate3 "github.com/coreos/ignition/v2/config/v3_5 /translate"
49
+ ign3types "github.com/coreos/ignition/v2/config/v3_5 /types"
47
50
validate3 "github.com/coreos/ignition/v2/config/validate"
48
51
"github.com/ghodss/yaml"
49
52
"github.com/vincent-petithory/dataurl"
@@ -266,10 +269,9 @@ func WriteTerminationError(err error) {
266
269
klog .Fatal (msg )
267
270
}
268
271
269
- // ConvertRawExtIgnitionToV3 ensures that the Ignition config in
270
- // the RawExtension is spec v3.2, or translates to it.
271
- func ConvertRawExtIgnitionToV3_4 (inRawExtIgn * runtime.RawExtension ) (runtime.RawExtension , error ) {
272
-
272
+ // ConvertRawExtIgnitionToV3_5 ensures that the Ignition config in
273
+ // the RawExtension is spec v3.5, or translates to it.
274
+ func ConvertRawExtIgnitionToV3_5 (inRawExtIgn * runtime.RawExtension ) (runtime.RawExtension , error ) {
273
275
// Parse the raw extension to the MCO's current internal ignition version
274
276
ignCfgV3 , err := IgnParseWrapper (inRawExtIgn .Raw )
275
277
if err != nil {
@@ -289,10 +291,41 @@ func ConvertRawExtIgnitionToV3_4(inRawExtIgn *runtime.RawExtension) (runtime.Raw
289
291
return outRawExt , nil
290
292
}
291
293
294
+ // ConvertRawExtIgnitionToV3_4 ensures that the Ignition config in
295
+ // the RawExtension is spec v3.4, or translates to it.
296
+ func ConvertRawExtIgnitionToV3_4 (inRawExtIgn * runtime.RawExtension ) (runtime.RawExtension , error ) {
297
+ rawExt , err := ConvertRawExtIgnitionToV3_5 (inRawExtIgn )
298
+ if err != nil {
299
+ return runtime.RawExtension {}, err
300
+ }
301
+
302
+ ignCfgV3 , rptV3 , errV3 := ign3 .Parse (rawExt .Raw )
303
+ if errV3 != nil || rptV3 .IsFatal () {
304
+ return runtime.RawExtension {}, fmt .Errorf ("parsing Ignition config failed with error: %w\n Report: %v" , errV3 , rptV3 )
305
+ }
306
+
307
+ // TODO(jkyros): someday we should write a recursive chain-downconverter, but until then,
308
+ // we're going to do it the hard way
309
+ ignCfgV33 , err := convertIgnition35to34 (ignCfgV3 )
310
+ if err != nil {
311
+ return runtime.RawExtension {}, err
312
+ }
313
+
314
+ outIgnV33 , err := json .Marshal (ignCfgV33 )
315
+ if err != nil {
316
+ return runtime.RawExtension {}, fmt .Errorf ("failed to marshal converted config: %w" , err )
317
+ }
318
+
319
+ outRawExt := runtime.RawExtension {}
320
+ outRawExt .Raw = outIgnV33
321
+
322
+ return outRawExt , nil
323
+ }
324
+
292
325
// ConvertRawExtIgnitionToV3_3 ensures that the Ignition config in
293
326
// the RawExtension is spec v3.3, or translates to it.
294
327
func ConvertRawExtIgnitionToV3_3 (inRawExtIgn * runtime.RawExtension ) (runtime.RawExtension , error ) {
295
- rawExt , err := ConvertRawExtIgnitionToV3_4 (inRawExtIgn )
328
+ rawExt , err := ConvertRawExtIgnitionToV3_5 (inRawExtIgn )
296
329
if err != nil {
297
330
return runtime.RawExtension {}, err
298
331
}
@@ -304,7 +337,12 @@ func ConvertRawExtIgnitionToV3_3(inRawExtIgn *runtime.RawExtension) (runtime.Raw
304
337
305
338
// TODO(jkyros): someday we should write a recursive chain-downconverter, but until then,
306
339
// we're going to do it the hard way
307
- ignCfgV33 , err := convertIgnition34to33 (ignCfgV3 )
340
+ ignCfgV34 , err := convertIgnition35to34 (ignCfgV3 )
341
+ if err != nil {
342
+ return runtime.RawExtension {}, err
343
+ }
344
+
345
+ ignCfgV33 , err := convertIgnition34to33 (ignCfgV34 )
308
346
if err != nil {
309
347
return runtime.RawExtension {}, err
310
348
}
@@ -320,10 +358,10 @@ func ConvertRawExtIgnitionToV3_3(inRawExtIgn *runtime.RawExtension) (runtime.Raw
320
358
return outRawExt , nil
321
359
}
322
360
323
- // ConvertRawExtIgnitionToV3_3 ensures that the Ignition config in
324
- // the RawExtension is spec v3.3 , or translates to it.
361
+ // ConvertRawExtIgnitionToV3_2 ensures that the Ignition config in
362
+ // the RawExtension is spec v3.2 , or translates to it.
325
363
func ConvertRawExtIgnitionToV3_2 (inRawExtIgn * runtime.RawExtension ) (runtime.RawExtension , error ) {
326
- rawExt , err := ConvertRawExtIgnitionToV3_4 (inRawExtIgn )
364
+ rawExt , err := ConvertRawExtIgnitionToV3_5 (inRawExtIgn )
327
365
if err != nil {
328
366
return runtime.RawExtension {}, err
329
367
}
@@ -335,7 +373,12 @@ func ConvertRawExtIgnitionToV3_2(inRawExtIgn *runtime.RawExtension) (runtime.Raw
335
373
336
374
// TODO(jkyros): someday we should write a recursive chain-downconverter, but until then,
337
375
// we're going to do it the hard way
338
- ignCfgV33 , err := convertIgnition34to33 (ignCfgV3 )
376
+ ignCfgV34 , err := convertIgnition35to34 (ignCfgV3 )
377
+ if err != nil {
378
+ return runtime.RawExtension {}, err
379
+ }
380
+
381
+ ignCfgV33 , err := convertIgnition34to33 (ignCfgV34 )
339
382
if err != nil {
340
383
return runtime.RawExtension {}, err
341
384
}
@@ -359,7 +402,7 @@ func ConvertRawExtIgnitionToV3_2(inRawExtIgn *runtime.RawExtension) (runtime.Raw
359
402
// ConvertRawExtIgnitionToV3_1 ensures that the Ignition config in
360
403
// the RawExtension is spec v3.1, or translates to it.
361
404
func ConvertRawExtIgnitionToV3_1 (inRawExtIgn * runtime.RawExtension ) (runtime.RawExtension , error ) {
362
- rawExt , err := ConvertRawExtIgnitionToV3_4 (inRawExtIgn )
405
+ rawExt , err := ConvertRawExtIgnitionToV3_5 (inRawExtIgn )
363
406
if err != nil {
364
407
return runtime.RawExtension {}, err
365
408
}
@@ -371,7 +414,12 @@ func ConvertRawExtIgnitionToV3_1(inRawExtIgn *runtime.RawExtension) (runtime.Raw
371
414
372
415
// TODO(jkyros): someday we should write a recursive chain-downconverter, but until then,
373
416
// we're going to do it the hard way
374
- ignCfgV33 , err := convertIgnition34to33 (ignCfgV3 )
417
+ ignCfgV34 , err := convertIgnition35to34 (ignCfgV3 )
418
+ if err != nil {
419
+ return runtime.RawExtension {}, err
420
+ }
421
+
422
+ ignCfgV33 , err := convertIgnition34to33 (ignCfgV34 )
375
423
if err != nil {
376
424
return runtime.RawExtension {}, err
377
425
}
@@ -405,7 +453,7 @@ func ConvertRawExtIgnitionToV2_2(inRawExtIgn *runtime.RawExtension) (runtime.Raw
405
453
return runtime.RawExtension {}, fmt .Errorf ("parsing Ignition config spec v3.2 failed with error: %w\n Report: %v" , err , rpt )
406
454
}
407
455
408
- converted2 , err := convertIgnition34to22 (ignCfg )
456
+ converted2 , err := convertIgnition35to22 (ignCfg )
409
457
if err != nil {
410
458
return runtime.RawExtension {}, fmt .Errorf ("failed to convert config from spec v3.2 to v2.2: %w" , err )
411
459
}
@@ -421,8 +469,8 @@ func ConvertRawExtIgnitionToV2_2(inRawExtIgn *runtime.RawExtension) (runtime.Raw
421
469
return outRawExt , nil
422
470
}
423
471
424
- // convertIgnition2to3 takes an ignition spec v2.2 config and returns a v3.2 config
425
- func convertIgnition22to34 (ign2config ign2types.Config ) (ign3types.Config , error ) {
472
+ // convertIgnition2to3 takes an ignition spec v2.2 config and returns a v3.5 config
473
+ func convertIgnition22to35 (ign2config ign2types.Config ) (ign3types.Config , error ) {
426
474
// only support writing to root file system
427
475
fsMap := map [string ]string {
428
476
"root" : "/" ,
@@ -434,18 +482,24 @@ func convertIgnition22to34(ign2config ign2types.Config) (ign3types.Config, error
434
482
if err != nil {
435
483
return ign3types.Config {}, fmt .Errorf ("unable to convert Ignition spec v2 config to v3: %w" , err )
436
484
}
437
- // Workaround to get a v3.4 config as output
438
- converted3 := translate3 .Translate (translate3_3 .Translate (translate3_2 .Translate (translate3_1 .Translate (ign3_0config ))))
485
+ // Workaround to get a v3.5 config as output
486
+ converted3 := translate3 .Translate (translate3_4 . Translate ( translate3_3 .Translate (translate3_2 .Translate (translate3_1 .Translate (ign3_0config ) ))))
439
487
440
488
klog .V (4 ).Infof ("Successfully translated Ignition spec v2 config to Ignition spec v3 config: %v" , converted3 )
441
489
return converted3 , nil
442
490
}
443
491
444
- // convertIgnition3to2 takes an ignition spec v3.2 config and returns a v2.2 config
445
- func convertIgnition34to22 (ign3config ign3types.Config ) (ign2types.Config , error ) {
492
+ // convertIgnition3to2 takes an ignition spec v3.5 config and returns a v2.2 config
493
+ func convertIgnition35to22 (ign3config ign3types.Config ) (ign2types.Config , error ) {
446
494
447
495
// TODO(jkyros): that recursive down-converter is looking like a better idea all the time
448
- converted33 , err := convertIgnition34to33 (ign3config )
496
+
497
+ converted34 , err := convertIgnition35to34 (ign3config )
498
+ if err != nil {
499
+ return ign2types.Config {}, fmt .Errorf ("unable to convert Ignition spec v3 config to v2: %w" , err )
500
+ }
501
+
502
+ converted33 , err := convertIgnition34to33 (converted34 )
449
503
if err != nil {
450
504
return ign2types.Config {}, fmt .Errorf ("unable to convert Ignition spec v3 config to v2: %w" , err )
451
505
}
@@ -464,24 +518,35 @@ func convertIgnition34to22(ign3config ign3types.Config) (ign2types.Config, error
464
518
return converted2 , nil
465
519
}
466
520
467
- // convertIgnition34to33 takes an ignition spec v3.4config and returns a v3.3 config
468
- func convertIgnition34to33 (ign3config ign3types.Config ) (ign3_3types.Config , error ) {
521
+ // convertIgnition35to34 takes an ignition spec v3.5 config and returns a v3.4 config
522
+ func convertIgnition35to34 (ign3config ign3types.Config ) (ign3_4types.Config , error ) {
523
+ converted34 , err := v35tov34 .Translate (ign3config )
524
+ if err != nil {
525
+ return ign3_4types.Config {}, fmt .Errorf ("unable to convert Ignition spec v3.5 config to v3.4: %w" , err )
526
+ }
527
+ klog .V (4 ).Infof ("Successfully translated Ignition spec v3.5 config to Ignition spec v3.4 config: %v" , converted34 )
528
+
529
+ return converted34 , nil
530
+ }
531
+
532
+ // convertIgnition34to33 takes an ignition spec v3.4 config and returns a v3.3 config
533
+ func convertIgnition34to33 (ign3config ign3_4types.Config ) (ign3_3types.Config , error ) {
469
534
converted33 , err := v34tov33 .Translate (ign3config )
470
535
if err != nil {
471
- return ign3_3types.Config {}, fmt .Errorf ("unable to convert Ignition spec v3_2 config to v3_1 : %w" , err )
536
+ return ign3_3types.Config {}, fmt .Errorf ("unable to convert Ignition spec v3.2 config to v3.1 : %w" , err )
472
537
}
473
- klog .V (4 ).Infof ("Successfully translated Ignition spec v3_2 config to Ignition spec v3_1 config: %v" , converted33 )
538
+ klog .V (4 ).Infof ("Successfully translated Ignition spec v3.2 config to Ignition spec v3.1 config: %v" , converted33 )
474
539
475
540
return converted33 , nil
476
541
}
477
542
478
- // convertIgnition33to32 takes an ignition spec v3.3config and returns a v3.2 config
543
+ // convertIgnition33to32 takes an ignition spec v3.3 config and returns a v3.2 config
479
544
func convertIgnition33to32 (ign3config ign3_3types.Config ) (ign3_2types.Config , error ) {
480
545
converted32 , err := v33tov32 .Translate (ign3config )
481
546
if err != nil {
482
- return ign3_2types.Config {}, fmt .Errorf ("unable to convert Ignition spec v3_2 config to v3_1 : %w" , err )
547
+ return ign3_2types.Config {}, fmt .Errorf ("unable to convert Ignition spec v3.3 config to v3.2 : %w" , err )
483
548
}
484
- klog .V (4 ).Infof ("Successfully translated Ignition spec v3_2 config to Ignition spec v3_1 config: %v" , converted32 )
549
+ klog .V (4 ).Infof ("Successfully translated Ignition spec v3.3 config to Ignition spec v3.2 config: %v" , converted32 )
485
550
486
551
return converted32 , nil
487
552
}
@@ -490,9 +555,9 @@ func convertIgnition33to32(ign3config ign3_3types.Config) (ign3_2types.Config, e
490
555
func convertIgnition32to31 (ign3config ign3_2types.Config ) (ign3_1types.Config , error ) {
491
556
converted31 , err := v32tov31 .Translate (ign3config )
492
557
if err != nil {
493
- return ign3_1types.Config {}, fmt .Errorf ("unable to convert Ignition spec v3_2 config to v3_1 : %w" , err )
558
+ return ign3_1types.Config {}, fmt .Errorf ("unable to convert Ignition spec v3.2 config to v3.1 : %w" , err )
494
559
}
495
- klog .V (4 ).Infof ("Successfully translated Ignition spec v3_2 config to Ignition spec v3_1 config: %v" , converted31 )
560
+ klog .V (4 ).Infof ("Successfully translated Ignition spec v3.2 config to Ignition spec v3.1 config: %v" , converted31 )
496
561
497
562
return converted31 , nil
498
563
}
@@ -681,7 +746,7 @@ func SupportedExtensions() map[string][]string {
681
746
// a V2 or V3 Config or an error. This wrapper is necessary since V2 and V3 use different parsers.
682
747
func IgnParseWrapper (rawIgn []byte ) (interface {}, error ) {
683
748
// ParseCompatibleVersion will parse any config <= N to version N
684
- ignCfgV3 , rptV3 , errV3 := ign3_4 .ParseCompatibleVersion (rawIgn )
749
+ ignCfgV3 , rptV3 , errV3 := ign3_5 .ParseCompatibleVersion (rawIgn )
685
750
if errV3 == nil && ! rptV3 .IsFatal () {
686
751
return ignCfgV3 , nil
687
752
}
@@ -690,7 +755,7 @@ func IgnParseWrapper(rawIgn []byte) (interface{}, error) {
690
755
// ErrInvalidVersion ("I can't parse it to find out what it is"), but our old 3.2 logic didn't, so this is here to make sure
691
756
// our error message for invalid version is still helpful.
692
757
if errV3 .Error () == ign3error .ErrInvalidVersion .Error () {
693
- return ign3types.Config {}, fmt .Errorf ("parsing Ignition config failed: invalid version. Supported spec versions: 2.2, 3.0, 3.1, 3.2, 3.3, 3.4" )
758
+ return ign3types.Config {}, fmt .Errorf ("parsing Ignition config failed: invalid version. Supported spec versions: 2.2, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5 " )
694
759
}
695
760
696
761
if errV3 .Error () == ign3error .ErrUnknownVersion .Error () {
@@ -701,7 +766,7 @@ func IgnParseWrapper(rawIgn []byte) (interface{}, error) {
701
766
702
767
// If the error is still UnknownVersion it's not a 3.3/3.2/3.1/3.0 or 2.x config, thus unsupported
703
768
if errV2 .Error () == ign2error .ErrUnknownVersion .Error () {
704
- return ign3types.Config {}, fmt .Errorf ("parsing Ignition config failed: unknown version. Supported spec versions: 2.2, 3.0, 3.1, 3.2, 3.3, 3.4" )
769
+ return ign3types.Config {}, fmt .Errorf ("parsing Ignition config failed: unknown version. Supported spec versions: 2.2, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5 " )
705
770
}
706
771
return ign3types.Config {}, fmt .Errorf ("parsing Ignition spec v2 failed with error: %v\n Report: %v" , errV2 , rptV2 )
707
772
}
@@ -725,7 +790,7 @@ func ParseAndConvertConfig(rawIgn []byte) (ign3types.Config, error) {
725
790
if err != nil {
726
791
return ign3types.Config {}, err
727
792
}
728
- convertedIgnV3 , err := convertIgnition22to34 (ignconfv2 )
793
+ convertedIgnV3 , err := convertIgnition22to35 (ignconfv2 )
729
794
if err != nil {
730
795
return ign3types.Config {}, fmt .Errorf ("failed to convert Ignition config spec v2 to v3: %w" , err )
731
796
}
@@ -930,8 +995,8 @@ func TranspileCoreOSConfigToIgn(files, units []string) (*ign3types.Config, error
930
995
return nil , fmt .Errorf ("failed to transpile config to Ignition config %w\n Translation set: %v" , err , tSet )
931
996
}
932
997
// TODO(jkyros): do we keep just...adding translations forever as we add more versions? :)
933
- ign3_2config := translate3 .Translate (translate3_3 .Translate (translate3_2 .Translate (translate3_1 .Translate (ign3_0config ))))
934
- outConfig = ign3 .Merge (outConfig , ign3_2config )
998
+ ign3Config := translate3 .Translate (translate3_4 . Translate ( translate3_3 .Translate (translate3_2 .Translate (translate3_1 .Translate (ign3_0config ) ))))
999
+ outConfig = ign3 .Merge (outConfig , ign3Config )
935
1000
}
936
1001
937
1002
for _ , contents := range units {
@@ -947,8 +1012,8 @@ func TranspileCoreOSConfigToIgn(files, units []string) (*ign3types.Config, error
947
1012
if err != nil {
948
1013
return nil , fmt .Errorf ("failed to transpile config to Ignition config %w\n Translation set: %v" , err , tSet )
949
1014
}
950
- ign3_2config := translate3 .Translate (translate3_3 .Translate (translate3_2 .Translate (translate3_1 .Translate (ign3_0config ))))
951
- outConfig = ign3 .Merge (outConfig , ign3_2config )
1015
+ ign3Config := translate3 .Translate (translate3_4 . Translate ( translate3_3 .Translate (translate3_2 .Translate (translate3_1 .Translate (ign3_0config ) ))))
1016
+ outConfig = ign3 .Merge (outConfig , ign3Config )
952
1017
}
953
1018
954
1019
return & outConfig , nil
0 commit comments