Skip to content

Commit

Permalink
temp: ignition patch
Browse files Browse the repository at this point in the history
  • Loading branch information
tuunit committed Nov 4, 2024
1 parent eaea93e commit a1f9981
Show file tree
Hide file tree
Showing 23 changed files with 1,465 additions and 1,080 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
From 09a77afae8ede189033837888062553ff18e7290 Mon Sep 17 00:00:00 2001
From 358dc41cf8f2f44b5b89ab10552683d3fa396792 Mon Sep 17 00:00:00 2001
From: Mathieu Tortuyaux <[email protected]>
Date: Mon, 26 Sep 2022 12:12:04 +0200
Subject: [PATCH 02/20] config: add ignition translation
Subject: [PATCH 02/22] config: add ignition translation

it's a merge from flatcar/ign-converter

Signed-off-by: Mathieu Tortuyaux <[email protected]>
---
build | 2 +-
config/util/translate.go | 166 +++
config/v24tov31/v24tov31.go | 729 +++++++++++++
config/v24tov31/v24tov31_test.go | 1692 ++++++++++++++++++++++++++++++
3 files changed, 2587 insertions(+)
4 files changed, 2588 insertions(+), 1 deletion(-)
create mode 100644 config/util/translate.go
create mode 100644 config/v24tov31/v24tov31.go
create mode 100644 config/v24tov31/v24tov31_test.go

diff --git a/build b/build
index 4a50527c..5abdcf5f 100755
--- a/build
+++ b/build
@@ -5,7 +5,7 @@ set -eu
export GO111MODULE=on

NAME="ignition"
-ORG_PATH="github.com/coreos"
+ORG_PATH="github.com/flatcar"
REPO_PATH="${ORG_PATH}/${NAME}/v2"
GLDFLAGS=${GLDFLAGS:-}
export GOFLAGS=-mod=vendor
diff --git a/config/util/translate.go b/config/util/translate.go
new file mode 100644
index 00000000..347d148c
Expand Down Expand Up @@ -2621,5 +2635,5 @@ index 00000000..e81f6bed
+ }
+}
--
2.44.2
2.43.0

Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
From b736afa1321345564c6ef6675a980b3187a085b1 Mon Sep 17 00:00:00 2001
From 2b2d5e325a944050f17cd82a15cf766419c4a015 Mon Sep 17 00:00:00 2001
From: Mathieu Tortuyaux <[email protected]>
Date: Thu, 24 Oct 2024 10:19:08 +0200
Subject: [PATCH 03/20] mod: add flatcar/[email protected]
Date: Fri, 7 Jun 2024 09:09:18 +0200
Subject: [PATCH 03/22] mod: add flatcar/[email protected]

it's required for Ignition conversion.

Signed-off-by: Mathieu Tortuyaux <[email protected]>
---
go.mod | 4 ++++
1 file changed, 4 insertions(+)
go.mod | 3 +++
1 file changed, 3 insertions(+)

diff --git a/go.mod b/go.mod
index a22b3edb..11ea000e 100644
index a22b3edb..69f63ef7 100644
--- a/go.mod
+++ b/go.mod
@@ -11,6 +11,7 @@ require (
Expand All @@ -32,14 +32,6 @@ index a22b3edb..11ea000e 100644
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
@@ -53,6 +56,7 @@ require (
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
+ go4.org v0.0.0-20160314031811-03efcb870d84 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/text v0.19.0 // indirect
--
2.44.2
2.43.0

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 3bd24e98f80056f32de366e87b754e3313138e25 Mon Sep 17 00:00:00 2001
From a38cd1605b977de8804978a2a6c9631633dd4a4d Mon Sep 17 00:00:00 2001
From: Mathieu Tortuyaux <[email protected]>
Date: Thu, 24 Oct 2024 10:19:25 +0200
Subject: [PATCH 04/20] sum: go mod tidy
Date: Fri, 7 Jun 2024 09:09:50 +0200
Subject: [PATCH 04/22] sum: go mod tidy

Signed-off-by: Mathieu Tortuyaux <[email protected]>
---
Expand Down Expand Up @@ -143,5 +143,5 @@ index 556ebeec..d79ae2e0 100644
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
--
2.44.2
2.43.0

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From c051ca72c703700943c79d28b154e460ecb23db1 Mon Sep 17 00:00:00 2001
From c4630f9868f10116355373d5a24b006f191811fa Mon Sep 17 00:00:00 2001
From: Mathieu Tortuyaux <[email protected]>
Date: Thu, 24 Oct 2024 10:19:43 +0200
Subject: [PATCH 05/20] vendor: go mod vendor
Date: Fri, 7 Jun 2024 09:10:35 +0200
Subject: [PATCH 05/22] vendor: go mod vendor

Signed-off-by: Mathieu Tortuyaux <[email protected]>
---
Expand Down Expand Up @@ -155,8 +155,8 @@ Signed-off-by: Mathieu Tortuyaux <[email protected]>
vendor/go4.org/AUTHORS | 8 +
vendor/go4.org/LICENSE | 202 +++
vendor/go4.org/errorutil/highlight.go | 58 +
vendor/modules.txt | 30 +
151 files changed, 15850 insertions(+)
vendor/modules.txt | 32 +-
151 files changed, 15851 insertions(+), 1 deletion(-)
create mode 100644 vendor/github.com/ajeddeloh/go-json/README
create mode 100644 vendor/github.com/ajeddeloh/go-json/decode.go
create mode 100644 vendor/github.com/ajeddeloh/go-json/encode.go
Expand Down Expand Up @@ -17029,7 +17029,7 @@ index 00000000..1b1efb0f
+ return
+}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 0d4a188c..8ffe2ea7 100644
index 0d4a188c..57536b55 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -36,6 +36,9 @@ cloud.google.com/go/storage
Expand Down Expand Up @@ -17080,16 +17080,19 @@ index 0d4a188c..8ffe2ea7 100644
# github.com/go-logr/logr v1.4.1
## explicit; go 1.18
github.com/go-logr/logr
@@ -264,6 +291,9 @@ go.opentelemetry.io/otel/metric/noop
@@ -264,8 +291,11 @@ go.opentelemetry.io/otel/metric/noop
## explicit; go 1.20
go.opentelemetry.io/otel/trace
go.opentelemetry.io/otel/trace/embedded
+# go4.org v0.0.0-20160314031811-03efcb870d84
+## explicit
+go4.org/errorutil
# golang.org/x/crypto v0.28.0
## explicit; go 1.20
-## explicit; go 1.20
+## explicit; go 1.18
golang.org/x/crypto/chacha20
golang.org/x/crypto/chacha20poly1305
golang.org/x/crypto/cryptobyte
--
2.44.2
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
From 2c91043cc1181596c363341ee5b974808b6cc44d Mon Sep 17 00:00:00 2001
From: Mathieu Tortuyaux <[email protected]>
Date: Wed, 25 May 2022 10:20:09 +0200
Subject: [PATCH 06/22] config/v3_5: convert ignition 2.x to 3.x

if the version of ignition is 2.x we convert it to 3.x using
ign-converter.

it should support any 2.x version (or at the least the last 2 releases)

Signed-off-by: Mathieu Tortuyaux <[email protected]>
---
config/v3_6_experimental/config.go | 37 ++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)

diff --git a/config/v3_6_experimental/config.go b/config/v3_6_experimental/config.go
index 3be26cae..ea367663 100644
--- a/config/v3_6_experimental/config.go
+++ b/config/v3_6_experimental/config.go
@@ -15,9 +15,14 @@
package v3_6_experimental

import (
+ "encoding/json"
+ "fmt"
+
+ "github.com/flatcar/ignition/config/v2_4"
"github.com/flatcar/ignition/v2/config/merge"
"github.com/flatcar/ignition/v2/config/shared/errors"
"github.com/flatcar/ignition/v2/config/util"
+ "github.com/flatcar/ignition/v2/config/v24tov31"
prev "github.com/flatcar/ignition/v2/config/v3_5"
"github.com/flatcar/ignition/v2/config/v3_6_experimental/translate"
"github.com/flatcar/ignition/v2/config/v3_6_experimental/types"
@@ -67,6 +72,38 @@ func ParseCompatibleVersion(raw []byte) (types.Config, report.Report, error) {
return types.Config{}, rpt, err
}

+ // if the version is 2.x or 1.x, we
+ // convert it to 3.1
+ if version.Major != 3 {
+ // Parse should fallback on every 2.x supported version
+ cfg, _, err := v2_4.Parse(raw)
+ if err != nil || rpt.IsFatal() {
+ return types.Config{}, report.Report{}, fmt.Errorf("unable to parse 2.x ignition: %w", err)
+ }
+
+ /*
+ map[string]string{} is required by the ign-converter
+ Ignition Spec 3 will mount filesystems at the mountpoint specified by path when running.
+ Filesystems no longer have the name field and files, links, and directories no longer specify the filesystem by name.
+ This means to translate filesystems (with the exception of root),
+ you must also provide a mapping of filesystem name to absolute path, e.g.
+ ```
+ map[string]string{"var": "/var"}
+ ```
+ */
+ newCfg, err := v24tov31.Translate(cfg, map[string]string{})
+ if err != nil {
+ return types.Config{}, report.Report{}, fmt.Errorf("unable to translate 2.x ignition to 3.1: %w", err)
+
+ }
+
+ // update raw in place to continue with the 3.x logic
+ raw, err = json.Marshal(newCfg)
+ if err != nil {
+ return types.Config{}, report.Report{}, fmt.Errorf("unable to render JSON: %w", err)
+ }
+ }
+
if version == types.MaxVersion {
return Parse(raw)
}
--
2.43.0

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 2f5a68dc1c780e1e8647951e1e15c78d569b6ac4 Mon Sep 17 00:00:00 2001
From 20010d9ad2ac1f9ffad7c1615deaacf0fc27d245 Mon Sep 17 00:00:00 2001
From: Mathieu Tortuyaux <[email protected]>
Date: Mon, 19 Feb 2024 18:12:22 +0100
Subject: [PATCH 07/20] internal/prv/cmdline: backport flatcar patch
Subject: [PATCH 07/22] internal/prv/cmdline: backport flatcar patch

this patch provides backward compatibility for various config
key
Expand Down Expand Up @@ -36,5 +36,5 @@ index 30203bff..86a5cb79 100644
}

--
2.44.2
2.43.0

Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
From 41e66c950879d3b1cddd2a80a48dbd3bf35413f4 Mon Sep 17 00:00:00 2001
From b349dcbf3563c7b9c71858be1a3f582e26b269e7 Mon Sep 17 00:00:00 2001
From: Mathieu Tortuyaux <[email protected]>
Date: Tue, 20 Feb 2024 10:02:28 +0100
Subject: [PATCH 08/20] provider/qemu: apply fw_cfg patch
Subject: [PATCH 08/22] provider/qemu: apply fw_cfg patch

we support both CoreOS and Flatcar fw_cfg path to ensure compatiblity

Signed-off-by: Mathieu Tortuyaux <[email protected]>
---
internal/providers/qemu/qemu_fwcfg.go | 118 ++++++++++++++------------
1 file changed, 63 insertions(+), 55 deletions(-)
internal/providers/qemu/qemu_fwcfg.go | 120 ++++++++++++++------------
1 file changed, 64 insertions(+), 56 deletions(-)

diff --git a/internal/providers/qemu/qemu_fwcfg.go b/internal/providers/qemu/qemu_fwcfg.go
index 389ec119..cab9c476 100644
index 389ec119..e233865a 100644
--- a/internal/providers/qemu/qemu_fwcfg.go
+++ b/internal/providers/qemu/qemu_fwcfg.go
@@ -29,6 +29,7 @@ import (
@@ -29,7 +29,8 @@ import (
"strings"
"time"

- "github.com/flatcar/ignition/v2/config/v3_6_experimental/types"
+ iErrors "github.com/flatcar/ignition/v2/config/shared/errors"
"github.com/flatcar/ignition/v2/config/v3_6_experimental/types"
+ "github.com/flatcar/ignition/v2/config/v3_5_experimental/types"
"github.com/flatcar/ignition/v2/internal/distro"
"github.com/flatcar/ignition/v2/internal/platform"
"github.com/flatcar/ignition/v2/internal/providers/util"
@@ -38,9 +39,11 @@ import (
"github.com/coreos/vcontext/report"
)
Expand Down Expand Up @@ -159,5 +161,5 @@ index 389ec119..cab9c476 100644
+
}
--
2.44.2
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From 3563a694333cec6b5d48e3b24d58460369d72337 Mon Sep 17 00:00:00 2001
From: Mathieu Tortuyaux <[email protected]>
Date: Thu, 2 Sep 2021 11:03:17 +0200
Subject: [PATCH 09/22] config/3_5/test: add ignition 2.x test cases

Signed-off-by: Mathieu Tortuyaux <[email protected]>
---
config/v3_5/config_test.go | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

diff --git a/config/v3_5/config_test.go b/config/v3_5/config_test.go
index 425eb544..88e5d2d6 100644
--- a/config/v3_5/config_test.go
+++ b/config/v3_5/config_test.go
@@ -161,6 +161,26 @@ func TestParse(t *testing.T) {
in in
out out
}{
+ {
+ in: in{config: []byte(`{"ignition": {"version": "2.0.0"}}`)},
+ out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}},
+ },
+ {
+ in: in{config: []byte(`{"ignition": {"version": "2.1.0"}}`)},
+ out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}},
+ },
+ {
+ in: in{config: []byte(`{"ignition": {"version": "2.2.0"}}`)},
+ out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}},
+ },
+ {
+ in: in{config: []byte(`{"ignition": {"version": "2.3.0"}}`)},
+ out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}},
+ },
+ {
+ in: in{config: []byte(`{"ignition": {"version": "2.4.0"}}`)},
+ out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}},
+ },
{
in: in{config: []byte(`{"ignition": {"version": "3.0.0"}}`)},
out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}},
--
2.43.0

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From c64bfd1cfa7992396609ad55b1e3dba29ce4026c Mon Sep 17 00:00:00 2001
From a10e49004615f119d63dc1bf2c751489529465b3 Mon Sep 17 00:00:00 2001
From: Mathieu Tortuyaux <[email protected]>
Date: Wed, 22 Sep 2021 14:53:49 +0200
Subject: [PATCH 10/20] internal/disk/fs: ignore fs format mismatches for the
Subject: [PATCH 10/22] internal/disk/fs: ignore fs format mismatches for the
OEM partition

As soon as the OEM partition's filesystem format changes, all users
Expand Down Expand Up @@ -35,5 +35,5 @@ index c575ced4..fefd1fff 100644
(fs.UUID == nil || canonicalizeFilesystemUUID(info.Type, info.UUID) == canonicalizeFilesystemUUID(fileSystemFormat, *fs.UUID)) {
s.Logger.Info("filesystem at %q is already correctly formatted. Skipping mkfs...", fs.Device)
--
2.44.2
2.43.0

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 0bcc2592c3809a86c7649cd667bd481e5526af2e Mon Sep 17 00:00:00 2001
From 30f317e5abb48225a74b2114355a21d871f20f35 Mon Sep 17 00:00:00 2001
From: Mathieu Tortuyaux <[email protected]>
Date: Tue, 20 Feb 2024 10:12:02 +0100
Subject: [PATCH 11/20] VMware: Fix guestinfo.*.config.data and *.config.url
Subject: [PATCH 11/22] VMware: Fix guestinfo.*.config.data and *.config.url
variables
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Expand Down Expand Up @@ -164,5 +164,5 @@ index 597c33fd..3680a4cd 100644

func delConfig(f *resource.Fetcher) error {
--
2.44.2
2.43.0

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 6f4ae547913ed6be8801ec17fd91f3ce0769d34e Mon Sep 17 00:00:00 2001
From cf0edd978eff88798571e19856e874fd877eed90 Mon Sep 17 00:00:00 2001
From: Mathieu Tortuyaux <[email protected]>
Date: Wed, 2 Feb 2022 13:27:18 +0100
Subject: [PATCH 12/20] config/version: handle configuration version 1
Subject: [PATCH 12/22] config/version: handle configuration version 1

version 2 should be able to translate configuration version 1 but the `GetConfigVersion`
was not able to detect version 1 configuration since for this particular
Expand Down Expand Up @@ -49,5 +49,5 @@ index 3b9bb22f..f81056fa 100644
return semver.Version{}, report.Report{}, errors.ErrInvalidVersion
}
--
2.44.2
2.43.0

Loading

0 comments on commit a1f9981

Please sign in to comment.