Skip to content

Commit d4375a6

Browse files
prestistclaude
andcommitted
translate: allow special mode bits in v34tov33 translation
Previously, the v34tov33 translator would error if special mode bits (setuid/setgid/sticky) were present in file or directory modes. This prevented down-translation of valid v3.4 configs. The translator already had the correct logic to mask out special mode bits during translation (since v3.3 doesn't support them), but the validation was preventing that code from running. This fix removes the validation checks and allows the translation to proceed, with special mode bits being masked out as intended. Fixes #61 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 40beacd commit d4375a6

2 files changed

Lines changed: 9 additions & 18 deletions

File tree

translate/v34tov33/v34tov33.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,6 @@ func recursiveIsOk(v reflect.Value) error {
138138
if len(luks.OpenOptions) > 0 {
139139
return fmt.Errorf("Invalid input config: luks openOptions is not supported in spec v3.3")
140140
}
141-
case t == reflect.TypeOf(old_types.FileEmbedded1{}):
142-
f := v.Interface().(old_types.FileEmbedded1)
143-
// 3.3 does not support special mode bits in files
144-
if f.Mode != nil && (*f.Mode&07000) != 0 {
145-
return fmt.Errorf("Invalid input config: special mode bits are not supported in spec v3.3")
146-
}
147-
case t == reflect.TypeOf(old_types.DirectoryEmbedded1{}):
148-
d := v.Interface().(old_types.DirectoryEmbedded1)
149-
// 3.3 does not support special mode bits in directories
150-
if d.Mode != nil && (*d.Mode&07000) != 0 {
151-
return fmt.Errorf("Invalid input config: special mode bits are not supported in spec v3.3")
152-
}
153141
case t == reflect.TypeOf(old_types.Resource{}):
154142
resource := v.Interface().(old_types.Resource)
155143
// 3.3 does not support arn: scheme for s3

translate_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,7 +2401,8 @@ func TestTranslate3_4to3_3(t *testing.T) {
24012401
})
24022402
assert.Error(t, err)
24032403

2404-
_, err = v34tov33.Translate(types3_4.Config{
2404+
// Test that special mode bits are correctly masked out during translation
2405+
res, err = v34tov33.Translate(types3_4.Config{
24052406
Ignition: types3_4.Ignition{
24062407
Version: "3.4.0",
24072408
},
@@ -2419,10 +2420,11 @@ func TestTranslate3_4to3_3(t *testing.T) {
24192420
},
24202421
},
24212422
})
2423+
assert.NoError(t, err)
2424+
// Verify that special mode bits were masked out (01777 -> 0777)
2425+
assert.Equal(t, util.IntP(0777), res.Storage.Files[0].Mode)
24222426

2423-
assert.Error(t, err)
2424-
2425-
_, err = v34tov33.Translate(types3_4.Config{
2427+
res, err = v34tov33.Translate(types3_4.Config{
24262428
Ignition: types3_4.Ignition{
24272429
Version: "3.4.0",
24282430
},
@@ -2446,8 +2448,9 @@ func TestTranslate3_4to3_3(t *testing.T) {
24462448
},
24472449
},
24482450
})
2449-
2450-
assert.Error(t, err)
2451+
assert.NoError(t, err)
2452+
// Verify that special mode bits were masked out (01777 -> 0777)
2453+
assert.Equal(t, util.IntP(0777), res.Storage.Directories[0].Mode)
24512454

24522455
_, err = v34tov33.Translate(types3_4.Config{
24532456
Ignition: types3_4.Ignition{

0 commit comments

Comments
 (0)