From 87e2d0c5887af56685ae39b7d7d1f22f15164ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Ravier?= Date: Fri, 20 Sep 2024 10:29:26 +0200 Subject: [PATCH] config/v3_6_experimental: adapt for new experimental spec --- config/v3_6_experimental/config.go | 12 ++++---- config/v3_6_experimental/config_test.go | 18 ++++++++---- .../v3_6_experimental/translate/translate.go | 28 ++----------------- .../translate/translate_test.go | 2 +- config/v3_6_experimental/types/config.go | 5 ++-- config/v3_6_experimental/types/schema.go | 2 +- 6 files changed, 26 insertions(+), 41 deletions(-) diff --git a/config/v3_6_experimental/config.go b/config/v3_6_experimental/config.go index d6f8645bb..e67b08bab 100644 --- a/config/v3_6_experimental/config.go +++ b/config/v3_6_experimental/config.go @@ -12,15 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v3_5 +package v3_6_experimental import ( "github.com/coreos/ignition/v2/config/merge" "github.com/coreos/ignition/v2/config/shared/errors" "github.com/coreos/ignition/v2/config/util" - prev "github.com/coreos/ignition/v2/config/v3_4" - "github.com/coreos/ignition/v2/config/v3_5/translate" - "github.com/coreos/ignition/v2/config/v3_5/types" + prev "github.com/coreos/ignition/v2/config/v3_5" + "github.com/coreos/ignition/v2/config/v3_6_experimental/translate" + "github.com/coreos/ignition/v2/config/v3_6_experimental/types" "github.com/coreos/ignition/v2/config/validate" "github.com/coreos/go-semver/semver" @@ -58,8 +58,8 @@ func Parse(rawConfig []byte) (types.Config, report.Report, error) { return config, rpt, nil } -// ParseCompatibleVersion parses the raw config of version 3.5.0 or -// lesser into a 3.5 types.Config struct and generates a report of any errors, +// ParseCompatibleVersion parses the raw config of version 3.5.0-experimental or +// lesser into a 3.5-exp types.Config struct and generates a report of any errors, // warnings, info, and deprecations it encountered func ParseCompatibleVersion(raw []byte) (types.Config, report.Report, error) { version, rpt, err := util.GetConfigVersion(raw) diff --git a/config/v3_6_experimental/config_test.go b/config/v3_6_experimental/config_test.go index 9786befc3..8ba561631 100644 --- a/config/v3_6_experimental/config_test.go +++ b/config/v3_6_experimental/config_test.go @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v3_5 +package v3_6_experimental import ( "testing" "github.com/coreos/ignition/v2/config/shared/errors" - "github.com/coreos/ignition/v2/config/v3_5/types" + "github.com/coreos/ignition/v2/config/v3_6_experimental/types" "github.com/stretchr/testify/assert" ) @@ -85,7 +85,7 @@ func TestParse(t *testing.T) { }, { in: in{config: []byte(`{"ignition": {"version": "3.5.0"}}`)}, - out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}}, + out: out{err: errors.ErrUnknownVersion}, }, { in: in{config: []byte(`{"ignition": {"version": "2.0.0-experimental"}}`)}, @@ -135,6 +135,10 @@ func TestParse(t *testing.T) { in: in{config: []byte(`{"ignition": {"version": "3.5.0-experimental"}}`)}, out: out{err: errors.ErrUnknownVersion}, }, + { + in: in{config: []byte(`{"ignition": {"version": "3.6.0-experimental"}}`)}, + out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}}, + }, { in: in{config: []byte(`{"ignition": {"version": "2.0.0"},}`)}, out: out{err: errors.ErrInvalid}, @@ -152,7 +156,7 @@ func TestParse(t *testing.T) { out: out{err: errors.ErrEmpty}, }, { - in: in{config: []byte(`{"ignition": {"version": "3.5.0"}, "storage": {"filesystems": [{"format": "ext4", "label": "zzzzzzzzzzzzzzzzzzzzzzzzzzz"}]}}`)}, + in: in{config: []byte(`{"ignition": {"version": "3.6.0-experimental"}, "storage": {"filesystems": [{"format": "ext4", "label": "zzzzzzzzzzzzzzzzzzzzzzzzzzz"}]}}`)}, out: out{err: errors.ErrInvalid}, }, } @@ -187,6 +191,10 @@ func TestParse(t *testing.T) { }, { in: in{config: []byte(`{"ignition": {"version": "3.6.0-experimental"}}`)}, + out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}}, + }, + { + in: in{config: []byte(`{"ignition": {"version": "3.6.0"}}`)}, out: out{err: errors.ErrUnknownVersion}, }, { @@ -202,7 +210,7 @@ func TestParse(t *testing.T) { out: out{err: errors.ErrInvalid}, }, { - in: in{config: []byte(`{"ignition": {"version": "3.5.0"}, "storage": {"filesystems": [{"format": "ext4", "label": "zzzzzzzzzzzzzzzzzzzzzzzzzzz"}]}}`)}, + in: in{config: []byte(`{"ignition": {"version": "3.6.0-experimental"}, "storage": {"filesystems": [{"format": "ext4", "label": "zzzzzzzzzzzzzzzzzzzzzzzzzzz"}]}}`)}, out: out{err: errors.ErrInvalid}, }, } diff --git a/config/v3_6_experimental/translate/translate.go b/config/v3_6_experimental/translate/translate.go index bc13973fc..bf3f11e98 100644 --- a/config/v3_6_experimental/translate/translate.go +++ b/config/v3_6_experimental/translate/translate.go @@ -16,8 +16,8 @@ package translate import ( "github.com/coreos/ignition/v2/config/translate" - old_types "github.com/coreos/ignition/v2/config/v3_4/types" - "github.com/coreos/ignition/v2/config/v3_5/types" + old_types "github.com/coreos/ignition/v2/config/v3_5/types" + "github.com/coreos/ignition/v2/config/v3_6_experimental/types" ) func translateIgnition(old old_types.Ignition) (ret types.Ignition) { @@ -27,33 +27,9 @@ func translateIgnition(old old_types.Ignition) (ret types.Ignition) { return } -func translateLuks(old old_types.Luks) (ret types.Luks) { - tr := translate.NewTranslator() - tr.AddCustomTranslator(translateTang) - tr.Translate(&old.Clevis, &ret.Clevis) - tr.Translate(&old.Device, &ret.Device) - tr.Translate(&old.KeyFile, &ret.KeyFile) - tr.Translate(&old.Label, &ret.Label) - tr.Translate(&old.Name, &ret.Name) - tr.Translate(&old.OpenOptions, &ret.OpenOptions) - tr.Translate(&old.Options, &ret.Options) - tr.Translate(&old.Discard, &ret.Discard) - tr.Translate(&old.UUID, &ret.UUID) - tr.Translate(&old.WipeVolume, &ret.WipeVolume) - return -} - -func translateTang(old old_types.Tang) (ret types.Tang) { - tr := translate.NewTranslator() - tr.Translate(&old.Thumbprint, &ret.Thumbprint) - tr.Translate(&old.URL, &ret.URL) - return -} - func Translate(old old_types.Config) (ret types.Config) { tr := translate.NewTranslator() tr.AddCustomTranslator(translateIgnition) - tr.AddCustomTranslator(translateLuks) tr.Translate(&old, &ret) return } diff --git a/config/v3_6_experimental/translate/translate_test.go b/config/v3_6_experimental/translate/translate_test.go index 7896facc1..fc9e3de55 100644 --- a/config/v3_6_experimental/translate/translate_test.go +++ b/config/v3_6_experimental/translate/translate_test.go @@ -19,7 +19,7 @@ import ( "testing" "github.com/coreos/ignition/v2/config/util" - old "github.com/coreos/ignition/v2/config/v3_4/types" + old "github.com/coreos/ignition/v2/config/v3_5/types" ) // Check that we have valid translators for the complete config struct diff --git a/config/v3_6_experimental/types/config.go b/config/v3_6_experimental/types/config.go index 659657b63..9428b0bb2 100644 --- a/config/v3_6_experimental/types/config.go +++ b/config/v3_6_experimental/types/config.go @@ -25,8 +25,9 @@ import ( var ( MaxVersion = semver.Version{ - Major: 3, - Minor: 5, + Major: 3, + Minor: 6, + PreRelease: "experimental", } ) diff --git a/config/v3_6_experimental/types/schema.go b/config/v3_6_experimental/types/schema.go index 6c8c42f57..c652d666d 100644 --- a/config/v3_6_experimental/types/schema.go +++ b/config/v3_6_experimental/types/schema.go @@ -1,6 +1,6 @@ package types -// generated by "schematyper --package=types config/v3_5/schema/ignition.json -o config/v3_5/types/schema.go --root-type=Config" -- DO NOT EDIT +// generated by "schematyper --package=types config/v3_6_experimental/schema/ignition.json -o config/v3_6_experimental/types/schema.go --root-type=Config" -- DO NOT EDIT type Cex struct { Enabled *bool `json:"enabled,omitempty"`