Skip to content

Commit 33a18ea

Browse files
committed
Bump ignition version to v3.6
Bump ignition version to v3.6 and add the v36tov35 translater. Signed-off-by: Fangge Jin <fjin@redhat.com>
1 parent 2f77307 commit 33a18ea

59 files changed

Lines changed: 2801 additions & 300 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

go.mod

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
module github.com/coreos/ign-converter
22

3-
go 1.18
3+
go 1.24.0
44

55
replace github.com/coreos/ign-converter/translate/v34tov35 => ./translate/v35tov34
66

77
require (
88
github.com/clarketm/json v1.17.1
99
github.com/coreos/ignition v0.35.0
10-
github.com/coreos/ignition/v2 v2.20.0
11-
github.com/stretchr/testify v1.9.0
10+
github.com/coreos/ignition/v2 v2.26.0
11+
github.com/stretchr/testify v1.11.1
1212
)
1313

1414
require (
1515
github.com/ajeddeloh/go-json v0.0.0-20200220154158-5ae607161559 // indirect
16-
github.com/aws/aws-sdk-go v1.55.5 // indirect
16+
github.com/aws/aws-sdk-go-v2 v1.41.1 // indirect
1717
github.com/coreos/go-json v0.0.0-20230131223807-18775e0fb4fb // indirect
1818
github.com/coreos/go-semver v0.3.1 // indirect
1919
github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 // indirect
20-
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
20+
github.com/coreos/go-systemd/v22 v22.6.0 // indirect
2121
github.com/coreos/vcontext v0.0.0-20230201181013-d72178a18687 // indirect
22-
github.com/davecgh/go-spew v1.1.1 // indirect
23-
github.com/pmezard/go-difflib v1.0.0 // indirect
22+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
23+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
2424
github.com/vincent-petithory/dataurl v1.0.0 // indirect
2525
go4.org v0.0.0-20200104003542-c7e774b10ea0 // indirect
2626
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github.com/ajeddeloh/go-json v0.0.0-20200220154158-5ae607161559 h1:4SPQljF/GJ8Q+QlCWMWxRBepub4DresnOm4eI2ebFGc=
22
github.com/ajeddeloh/go-json v0.0.0-20200220154158-5ae607161559/go.mod h1:otnto4/Icqn88WCcM4bhIJNSgsh9VLBuspyyCfvof9c=
3-
github.com/aws/aws-sdk-go v1.55.5 h1:KKUZBfBoyqy5d3swXyiC7Q76ic40rYcbqH7qjh59kzU=
4-
github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
3+
github.com/aws/aws-sdk-go-v2 v1.41.1 h1:ABlyEARCDLN034NhxlRUSZr4l71mh+T5KAeGh6cerhU=
4+
github.com/aws/aws-sdk-go-v2 v1.41.1/go.mod h1:MayyLB8y+buD9hZqkCW3kX1AKq07Y5pXxtgB+rRFhz0=
55
github.com/clarketm/json v1.17.1 h1:U1IxjqJkJ7bRK4L6dyphmoO840P6bdhPdbbLySourqI=
66
github.com/clarketm/json v1.17.1/go.mod h1:ynr2LRfb0fQU34l07csRNBTcivjySLLiY1YzQqKVfdo=
77
github.com/coreos/go-json v0.0.0-20230131223807-18775e0fb4fb h1:rmqyI19j3Z/74bIRhuC59RB442rXUazKNueVpfJPxg4=
@@ -10,21 +10,20 @@ github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr
1010
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
1111
github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 h1:3jFq2xL4ZajGK4aZY8jz+DAF0FHjI51BXjjSwCzS1Dk=
1212
github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
13-
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
14-
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
13+
github.com/coreos/go-systemd/v22 v22.6.0 h1:aGVa/v8B7hpb0TKl0MWoAavPDmHvobFe5R5zn0bCJWo=
14+
github.com/coreos/go-systemd/v22 v22.6.0/go.mod h1:iG+pp635Fo7ZmV/j14KUcmEyWF+0X7Lua8rrTWzYgWU=
1515
github.com/coreos/ignition v0.35.0 h1:UFodoYq1mOPrbEjtxIsZbThcDyQwAI1owczRDqWmKkQ=
1616
github.com/coreos/ignition v0.35.0/go.mod h1:WJQapxzEn9DE0ryxsGvm8QnBajm/XsS/PkrDqSpz+bA=
17-
github.com/coreos/ignition/v2 v2.20.0 h1:xQjrxhCbcSKpqrN2hOQavAc1rx0GOf6qh2QCauScwPU=
18-
github.com/coreos/ignition/v2 v2.20.0/go.mod h1:l7EpXNWA7jBXmjUMvnVBlrrj+LX2wA/PAyD9kstwFDQ=
17+
github.com/coreos/ignition/v2 v2.26.0 h1:Db4IO5ydZOMnJYINgbPuXlwAH1ul0/V71h20iKyBi6k=
18+
github.com/coreos/ignition/v2 v2.26.0/go.mod h1:2f48nEXqnh1BU69Yq3lIWDvaYFSFQVZoFB7rB7wz7DY=
1919
github.com/coreos/vcontext v0.0.0-20230201181013-d72178a18687 h1:uSmlDgJGbUB0bwQBcZomBTottKwEDF5fF8UjSwKSzWM=
2020
github.com/coreos/vcontext v0.0.0-20230201181013-d72178a18687/go.mod h1:Salmysdw7DAVuobBW/LwsKKgpyCPHUhjyJoMJD+ZJiI=
21-
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
22-
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
23-
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
24-
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
25-
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
26-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
27-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
21+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
22+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
23+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
24+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
25+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
26+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
2827
github.com/vincent-petithory/dataurl v1.0.0 h1:cXw+kPto8NLuJtlMsI152irrVw9fRDX8AbShPRpg2CI=
2928
github.com/vincent-petithory/dataurl v1.0.0/go.mod h1:FHafX5vmDzyP+1CQATJn7WFKc9CvnvxyvZy6I1MrG/U=
3029
go4.org v0.0.0-20200104003542-c7e774b10ea0 h1:M6XsnQeLwG+rHQ+/rrGh3puBI3WZEy9TBWmf2H+enQA=

translate/v36tov35/v36tov35.go

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
// Copyright 2020 Red Hat, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
package v36tov35
15+
16+
import (
17+
"fmt"
18+
"reflect"
19+
20+
"github.com/coreos/ignition/config/util"
21+
"github.com/coreos/ignition/v2/config/translate"
22+
"github.com/coreos/ignition/v2/config/v3_5/types"
23+
24+
old_types "github.com/coreos/ignition/v2/config/v3_6/types"
25+
"github.com/coreos/ignition/v2/config/validate"
26+
)
27+
28+
// Copy of github.com/coreos/ignition/v2/config/v3_5/translate/translate.go
29+
// with the types & old_types imports reversed (the referenced file translates
30+
// from 3.6 -> 3.5 but as a result only touches fields that are understood by
31+
// the 3.5 spec).
32+
func translateFileEmbedded1(old old_types.FileEmbedded1) (ret types.FileEmbedded1) {
33+
tr := translate.NewTranslator()
34+
tr.Translate(&old.Append, &ret.Append)
35+
tr.Translate(&old.Contents, &ret.Contents)
36+
if old.Mode != nil {
37+
// Since fixing #2024 we now have to mask for the stabilized specs
38+
// to reduce security risks of applying permissions that were not applied
39+
// before the fix was implemented.
40+
// We support the special mode bits for specs >=3.6.0, so if
41+
// the user provides special mode bits in an Ignition config
42+
// with the version < 3.6.0, then we need to explicitly mask
43+
// those bits out during translation.
44+
ret.Mode = util.IntToPtr(*old.Mode & ^07000)
45+
}
46+
return
47+
}
48+
49+
func translateDirectoryEmbedded1(old old_types.DirectoryEmbedded1) (ret types.DirectoryEmbedded1) {
50+
if old.Mode != nil {
51+
// Since fixing #2024 we now have to mask for the stabilized specs
52+
// to reduce security risks of applying permissions that were not applied
53+
// before the fix was implemented.
54+
// We support the special mode bits for specs >=3.6.0, so if
55+
// the user provides special mode bits in an Ignition config
56+
// with the version < 3.6.0, then we need to explicitly mask
57+
// those bits out during translation.
58+
ret.Mode = util.IntToPtr(*old.Mode & ^07000)
59+
}
60+
return
61+
}
62+
func translateIgnition(old old_types.Ignition) (ret types.Ignition) {
63+
// use a new translator so we don't recurse infinitely
64+
translate.NewTranslator().Translate(&old, &ret)
65+
ret.Version = types.MaxVersion.String()
66+
return
67+
}
68+
69+
func translateConfig(old old_types.Config) (ret types.Config) {
70+
tr := translate.NewTranslator()
71+
tr.AddCustomTranslator(translateIgnition)
72+
tr.AddCustomTranslator(translateDirectoryEmbedded1)
73+
tr.AddCustomTranslator(translateFileEmbedded1)
74+
tr.Translate(&old, &ret)
75+
return
76+
}
77+
78+
// end copied Ignition v3_6/translate block
79+
80+
// Translate translates Ignition spec config v3.6 to spec v3.5
81+
func Translate(cfg old_types.Config) (types.Config, error) {
82+
rpt := validate.ValidateWithContext(cfg, nil)
83+
if rpt.IsFatal() {
84+
return types.Config{}, fmt.Errorf("invalid input config:\n%s", rpt.String())
85+
}
86+
87+
err := checkValue(reflect.ValueOf(cfg))
88+
if err != nil {
89+
return types.Config{}, err
90+
}
91+
92+
res := translateConfig(cfg)
93+
94+
// Sanity check the returned config
95+
oldrpt := validate.ValidateWithContext(res, nil)
96+
if oldrpt.IsFatal() {
97+
return types.Config{}, fmt.Errorf("converted spec has unexpected fatal error:\n%s", oldrpt.String())
98+
}
99+
return res, nil
100+
}
101+
102+
func checkValue(v reflect.Value) error {
103+
if !v.IsValid() {
104+
return nil
105+
}
106+
107+
// v3.6 introduced arbitrary custom clevis pin support
108+
if v.Type() == reflect.TypeOf(old_types.ClevisCustom{}) {
109+
// Check if Pin field is set
110+
pinField := v.FieldByName("Pin")
111+
if pinField.IsValid() && !pinField.IsNil() {
112+
pinValue := pinField.Elem().String()
113+
// v3.5 only supports tpm2, tang, and sss
114+
if pinValue != "tpm2" && pinValue != "tang" && pinValue != "sss" {
115+
return fmt.Errorf("invalid input config: arbitrary custom clevis pin '%s' is not supported in spec v3.5", pinValue)
116+
}
117+
}
118+
}
119+
120+
// Recursively check nested structures
121+
switch v.Kind() {
122+
case reflect.Struct:
123+
for i := 0; i < v.NumField(); i++ {
124+
err := checkValue(v.Field(i))
125+
if err != nil {
126+
return err
127+
}
128+
}
129+
case reflect.Slice, reflect.Array:
130+
for i := 0; i < v.Len(); i++ {
131+
err := checkValue(v.Index(i))
132+
if err != nil {
133+
return err
134+
}
135+
}
136+
case reflect.Ptr:
137+
if !v.IsNil() {
138+
err := checkValue(v.Elem())
139+
if err != nil {
140+
return err
141+
}
142+
}
143+
}
144+
145+
return nil
146+
}
File renamed without changes.
File renamed without changes.

vendor/github.com/aws/aws-sdk-go/aws/arn/arn.go renamed to vendor/github.com/aws/aws-sdk-go-v2/aws/arn/arn.go

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/coreos/go-systemd/v22/unit/deserialize.go

Lines changed: 16 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/coreos/go-systemd/v22/unit/doc.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/coreos/go-systemd/v22/unit/option.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/coreos/go-systemd/v22/unit/serialize.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)