Skip to content

Commit 3ab7fc7

Browse files
authored
Merge pull request #1922 from madhu-pillai/bump_ignition_3.5
Stablize Ignition spec 3.5
2 parents 4a8f9be + df18924 commit 3ab7fc7

File tree

185 files changed

+5727
-100
lines changed

Some content is hidden

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

185 files changed

+5727
-100
lines changed

config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
package config
1616

1717
import (
18-
exp "github.com/coreos/ignition/v2/config/v3_5_experimental"
19-
types_exp "github.com/coreos/ignition/v2/config/v3_5_experimental/types"
18+
exp "github.com/coreos/ignition/v2/config/v3_6_experimental"
19+
types_exp "github.com/coreos/ignition/v2/config/v3_6_experimental/types"
2020

2121
"github.com/coreos/vcontext/report"
2222
)

config/config_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import (
2525
v3_2 "github.com/coreos/ignition/v2/config/v3_2/types"
2626
v3_3 "github.com/coreos/ignition/v2/config/v3_3/types"
2727
v3_4 "github.com/coreos/ignition/v2/config/v3_4/types"
28-
v3_5 "github.com/coreos/ignition/v2/config/v3_5_experimental/types"
28+
v3_5 "github.com/coreos/ignition/v2/config/v3_5/types"
29+
v3_6 "github.com/coreos/ignition/v2/config/v3_6_experimental/types"
2930
)
3031

3132
type typeSet map[reflect.Type]struct{}
@@ -274,6 +275,7 @@ func TestConfigStructure(t *testing.T) {
274275
reflect.TypeOf(v3_3.Config{}),
275276
reflect.TypeOf(v3_4.Config{}),
276277
reflect.TypeOf(v3_5.Config{}),
278+
reflect.TypeOf(v3_6.Config{}),
277279
}
278280

279281
for _, configType := range configs {

config/merge/merge_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919

2020
"github.com/coreos/ignition/v2/config/util"
2121
v3_2 "github.com/coreos/ignition/v2/config/v3_2/types"
22-
"github.com/coreos/ignition/v2/config/v3_5_experimental/types"
22+
"github.com/coreos/ignition/v2/config/v3_6_experimental/types"
2323

2424
"github.com/coreos/vcontext/path"
2525
"github.com/stretchr/testify/assert"

config/v3_5/config.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
15+
package v3_5
16+
17+
import (
18+
"github.com/coreos/ignition/v2/config/merge"
19+
"github.com/coreos/ignition/v2/config/shared/errors"
20+
"github.com/coreos/ignition/v2/config/util"
21+
prev "github.com/coreos/ignition/v2/config/v3_4"
22+
"github.com/coreos/ignition/v2/config/v3_5/translate"
23+
"github.com/coreos/ignition/v2/config/v3_5/types"
24+
"github.com/coreos/ignition/v2/config/validate"
25+
26+
"github.com/coreos/go-semver/semver"
27+
"github.com/coreos/vcontext/report"
28+
)
29+
30+
func Merge(parent, child types.Config) types.Config {
31+
res, _ := merge.MergeStructTranscribe(parent, child)
32+
return res.(types.Config)
33+
}
34+
35+
// Parse parses the raw config into a types.Config struct and generates a report of any
36+
// errors, warnings, info, and deprecations it encountered
37+
func Parse(rawConfig []byte) (types.Config, report.Report, error) {
38+
if len(rawConfig) == 0 {
39+
return types.Config{}, report.Report{}, errors.ErrEmpty
40+
}
41+
42+
var config types.Config
43+
if rpt, err := util.HandleParseErrors(rawConfig, &config); err != nil {
44+
return types.Config{}, rpt, err
45+
}
46+
47+
version, err := semver.NewVersion(config.Ignition.Version)
48+
49+
if err != nil || *version != types.MaxVersion {
50+
return types.Config{}, report.Report{}, errors.ErrUnknownVersion
51+
}
52+
53+
rpt := validate.ValidateWithContext(config, rawConfig)
54+
if rpt.IsFatal() {
55+
return types.Config{}, rpt, errors.ErrInvalid
56+
}
57+
58+
return config, rpt, nil
59+
}
60+
61+
// ParseCompatibleVersion parses the raw config of version 3.5.0 or
62+
// lesser into a 3.5 types.Config struct and generates a report of any errors,
63+
// warnings, info, and deprecations it encountered
64+
func ParseCompatibleVersion(raw []byte) (types.Config, report.Report, error) {
65+
version, rpt, err := util.GetConfigVersion(raw)
66+
if err != nil {
67+
return types.Config{}, rpt, err
68+
}
69+
70+
if version == types.MaxVersion {
71+
return Parse(raw)
72+
}
73+
prevCfg, r, err := prev.ParseCompatibleVersion(raw)
74+
if err != nil {
75+
return types.Config{}, r, err
76+
}
77+
return translate.Translate(prevCfg), r, nil
78+
}

config/v3_5_experimental/config_test.go renamed to config/v3_5/config_test.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package v3_5_experimental
15+
package v3_5
1616

1717
import (
1818
"testing"
1919

2020
"github.com/coreos/ignition/v2/config/shared/errors"
21-
"github.com/coreos/ignition/v2/config/v3_5_experimental/types"
21+
"github.com/coreos/ignition/v2/config/v3_5/types"
2222
"github.com/stretchr/testify/assert"
2323
)
2424

@@ -83,6 +83,10 @@ func TestParse(t *testing.T) {
8383
in: in{config: []byte(`{"ignition": {"version": "3.4.0"}}`)},
8484
out: out{err: errors.ErrUnknownVersion},
8585
},
86+
{
87+
in: in{config: []byte(`{"ignition": {"version": "3.5.0"}}`)},
88+
out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}},
89+
},
8690
{
8791
in: in{config: []byte(`{"ignition": {"version": "2.0.0-experimental"}}`)},
8892
out: out{err: errors.ErrUnknownVersion},
@@ -129,7 +133,7 @@ func TestParse(t *testing.T) {
129133
},
130134
{
131135
in: in{config: []byte(`{"ignition": {"version": "3.5.0-experimental"}}`)},
132-
out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}},
136+
out: out{err: errors.ErrUnknownVersion},
133137
},
134138
{
135139
in: in{config: []byte(`{"ignition": {"version": "2.0.0"},}`)},
@@ -148,7 +152,7 @@ func TestParse(t *testing.T) {
148152
out: out{err: errors.ErrEmpty},
149153
},
150154
{
151-
in: in{config: []byte(`{"ignition": {"version": "3.5.0-experimental"}, "storage": {"filesystems": [{"format": "ext4", "label": "zzzzzzzzzzzzzzzzzzzzzzzzzzz"}]}}`)},
155+
in: in{config: []byte(`{"ignition": {"version": "3.5.0"}, "storage": {"filesystems": [{"format": "ext4", "label": "zzzzzzzzzzzzzzzzzzzzzzzzzzz"}]}}`)},
152156
out: out{err: errors.ErrInvalid},
153157
},
154158
}
@@ -178,15 +182,15 @@ func TestParse(t *testing.T) {
178182
out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}},
179183
},
180184
{
181-
in: in{config: []byte(`{"ignition": {"version": "3.5.0-experimental"}}`)},
185+
in: in{config: []byte(`{"ignition": {"version": "3.5.0"}}`)},
182186
out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}},
183187
},
184188
{
185-
in: in{config: []byte(`{"ignition": {"version": "3.5.0"}}`)},
189+
in: in{config: []byte(`{"ignition": {"version": "3.6.0-experimental"}}`)},
186190
out: out{err: errors.ErrUnknownVersion},
187191
},
188192
{
189-
in: in{config: []byte(`{"ignition": {"version": "3.6.0"}}`)},
193+
in: in{config: []byte(`{"ignition": {"version": "3.7.0"}}`)},
190194
out: out{err: errors.ErrUnknownVersion},
191195
},
192196
{
@@ -198,7 +202,7 @@ func TestParse(t *testing.T) {
198202
out: out{err: errors.ErrInvalid},
199203
},
200204
{
201-
in: in{config: []byte(`{"ignition": {"version": "3.5.0-experimental"}, "storage": {"filesystems": [{"format": "ext4", "label": "zzzzzzzzzzzzzzzzzzzzzzzzzzz"}]}}`)},
205+
in: in{config: []byte(`{"ignition": {"version": "3.5.0"}, "storage": {"filesystems": [{"format": "ext4", "label": "zzzzzzzzzzzzzzzzzzzzzzzzzzz"}]}}`)},
202206
out: out{err: errors.ErrInvalid},
203207
},
204208
}
File renamed without changes.

config/v3_5_experimental/translate/translate.go renamed to config/v3_5/translate/translate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package translate
1717
import (
1818
"github.com/coreos/ignition/v2/config/translate"
1919
old_types "github.com/coreos/ignition/v2/config/v3_4/types"
20-
"github.com/coreos/ignition/v2/config/v3_5_experimental/types"
20+
"github.com/coreos/ignition/v2/config/v3_5/types"
2121
)
2222

2323
func translateIgnition(old old_types.Ignition) (ret types.Ignition) {
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)