Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platform/conf: add Butane config support #318

Merged
merged 8 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- kola tests `cl.cgroupv1` and `kubeadm.*.*.cgroupv1.base` that test functionality with cgroupv1 ([#298](https://github.com/flatcar-linux/mantle/pull/298))
- Added private network support to qemu-unpriv platform ([#307](https://github.com/flatcar-linux/mantle/pull/307))
- Ignition v3 support and tests ([#301](https://github.com/flatcar-linux/mantle/pull/301), [#311](https://github.com/flatcar-linux/mantle/pull/311))
- Butane config support ([#318](https://github.com/flatcar-linux/mantle/pull/318))

### Changed
- removed `packet` occurrences in favor of `equinixmetal` ([#277](https://github.com/flatcar-linux/mantle/pull/277))
Expand Down
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ require (
github.com/Azure/go-autorest/autorest/azure/auth v0.5.8
github.com/Microsoft/azure-vhd-utils v0.0.0-20210818134022-97083698b75f
github.com/aws/aws-sdk-go v1.42.41
github.com/coreos/butane v0.14.1-0.20220401164106-6b5239299226
github.com/coreos/coreos-cloudinit v1.11.0
github.com/coreos/go-iptables v0.5.0
github.com/coreos/go-omaha v0.0.0-20170526203809-f8acb2d7b76c
github.com/coreos/go-semver v0.3.0
github.com/coreos/ignition/v2 v2.13.0
github.com/coreos/ioprogress v0.0.0-20151023204047-4637e494fd9b
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f
github.com/digitalocean/godo v1.45.0
github.com/flatcar-linux/container-linux-config-transpiler v0.9.3-0.20220208152502-6e8303479682
github.com/flatcar-linux/ignition v0.36.2-0.20220221101037-de4e6cc9bbba
github.com/flatcar-linux/ignition/v2 v2.2.1-0.20220311122140-cb95c51122f5
github.com/godbus/dbus v0.0.0-20181025153459-66d97aec3384
github.com/golang/protobuf v1.5.2
github.com/gophercloud/gophercloud v0.0.0-20180817041643-185230dfbd12
Expand All @@ -28,7 +29,7 @@ require (
github.com/pin/tftp v2.1.0+incompatible
github.com/spf13/cobra v1.1.3
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.7.1
github.com/ulikunitz/xz v0.5.10
github.com/vincent-petithory/dataurl v1.0.0
github.com/vishvananda/netlink v1.1.1-0.20210330154013-f5de75959ad5
Expand Down Expand Up @@ -61,10 +62,11 @@ require (
github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/coreos/go-json v0.0.0-20211020211907-c63f628265de // indirect
github.com/clarketm/json v1.17.1 // indirect
github.com/coreos/go-json v0.0.0-20220325222439-31b2177291ae // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/coreos/vcontext v0.0.0-20211021162308-f1dbbca7bef4 // indirect
github.com/coreos/vcontext v0.0.0-20220326205524-7fcaf69e7050 // indirect
github.com/coreos/yaml v0.0.0-20141224210557-6b16a5714269 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
Expand Down
20 changes: 12 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/clarketm/json v1.14.1/go.mod h1:ynr2LRfb0fQU34l07csRNBTcivjySLLiY1YzQqKVfdo=
github.com/clarketm/json v1.17.1 h1:U1IxjqJkJ7bRK4L6dyphmoO840P6bdhPdbbLySourqI=
github.com/clarketm/json v1.17.1/go.mod h1:ynr2LRfb0fQU34l07csRNBTcivjySLLiY1YzQqKVfdo=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
Expand All @@ -116,13 +118,16 @@ github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoC
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOiXqcou5a3rIlMc7oJbMQkeLk0VQJ7zgqY=
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/butane v0.14.1-0.20220401164106-6b5239299226 h1:bFC7LN8ltkYe5xPHj/fQ4qRGbKlYy0VXimkbp7ZNjP8=
github.com/coreos/butane v0.14.1-0.20220401164106-6b5239299226/go.mod h1:Q5DcBsHDckEZ7IgQSb1MvvkNc50dpoT1lOHdGWwCRjY=
github.com/coreos/coreos-cloudinit v1.11.0 h1:qSLLJPaK4zavsL3ii02F2+v3P9I7JcaOW73s5+UKfw8=
github.com/coreos/coreos-cloudinit v1.11.0/go.mod h1:hV3swhSwq+bRX5apuk57gG+3fsQacgbrZVxjPTqo0zo=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-iptables v0.5.0 h1:mw6SAibtHKZcNzAsOxjoHIG0gy5YFHhypWSSNc6EjbQ=
github.com/coreos/go-iptables v0.5.0/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU=
github.com/coreos/go-json v0.0.0-20211020211907-c63f628265de h1:qZvNu52Tv7Jfbgxdw3ONHf0BK9UpuSxi9FA9Y+qU5VU=
github.com/coreos/go-json v0.0.0-20211020211907-c63f628265de/go.mod h1:lryFBkhadOfv8Jue2Vr/f/Yviw8h1DQPQojbXqEChY0=
github.com/coreos/go-json v0.0.0-20220325222439-31b2177291ae h1:NS9LsAvb9JOCPbAgembZCQvAg0FOhQj/p6SCmWRvTRU=
github.com/coreos/go-json v0.0.0-20220325222439-31b2177291ae/go.mod h1:lryFBkhadOfv8Jue2Vr/f/Yviw8h1DQPQojbXqEChY0=
github.com/coreos/go-omaha v0.0.0-20170526203809-f8acb2d7b76c h1:n9z1rkyYf+OGow4mvjFHhsLxS8wLnoD0SHqDeF2/en8=
github.com/coreos/go-omaha v0.0.0-20170526203809-f8acb2d7b76c/go.mod h1:IU76HHVFspEz6YCsXufWBCTPBPbL86JSct4XvXfZPMA=
github.com/coreos/go-semver v0.1.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
Expand All @@ -135,12 +140,15 @@ github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7
github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/ignition/v2 v2.13.0 h1:1ouW+d0nOuPUbLjxxOCnC+dWQxynr8Mt5exqJoCD7b4=
github.com/coreos/ignition/v2 v2.13.0/go.mod h1:HO1HWYWcvAIbHu6xewoKxPGBTyZ32FLwGIuipw5d63o=
github.com/coreos/ioprogress v0.0.0-20151023204047-4637e494fd9b h1:mpeSDqY0vMUyJmazX0p62MrHtgwlmOf7Y8rqOYL1cmc=
github.com/coreos/ioprogress v0.0.0-20151023204047-4637e494fd9b/go.mod h1:JIWRG8HSwVYUrjdR/JsFg7DEby0nhQcWFPIQvXJyih8=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/vcontext v0.0.0-20211021162308-f1dbbca7bef4 h1:pfSsrvbjUFGINaPGy0mm2QKQKTdq7IcbUa+nQwsz2UM=
github.com/coreos/vcontext v0.0.0-20211021162308-f1dbbca7bef4/go.mod h1:HckqHnP/HI41vS0bfVjJ20u6jD0biI5+68QwZm5Xb9U=
github.com/coreos/vcontext v0.0.0-20220326205524-7fcaf69e7050 h1:Je4Sor/M7mqtqardljqFVNzDtOd2GQtUDFMXu8HKQb4=
github.com/coreos/vcontext v0.0.0-20220326205524-7fcaf69e7050/go.mod h1:HckqHnP/HI41vS0bfVjJ20u6jD0biI5+68QwZm5Xb9U=
github.com/coreos/yaml v0.0.0-20141224210557-6b16a5714269 h1:/1sjrpK5Mb6IwyFOKd+u7321tXfNAsj0Ci8CivZmSlo=
github.com/coreos/yaml v0.0.0-20141224210557-6b16a5714269/go.mod h1:Bl1D/T9QJhVdu6eFoLrGxN90+admDLGaLz2HXH/VzDc=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
Expand Down Expand Up @@ -170,13 +178,9 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/flatcar-linux/container-linux-config-transpiler v0.9.3-0.20220208152502-6e8303479682 h1:CiIJbwa0iC52LGviALcCtpnLpNa2hYXEdM64xFgALa0=
github.com/flatcar-linux/container-linux-config-transpiler v0.9.3-0.20220208152502-6e8303479682/go.mod h1:AGVTulMzeIKwurV9ExYH3UiokET1Ur65g+EIeRDMwzM=
github.com/flatcar-linux/ign-converter v0.1.1-0.20220311112608-f121a881f370/go.mod h1:t/kcw0CQ/uKMCyZwDAzuwMO3CShxaimEJhQzLGCsb3Y=
github.com/flatcar-linux/ignition v0.36.1/go.mod h1:0jS5n4AopgOdwgi7QDo5MFgkMx/fQUDYjuxlGJC1Txg=
github.com/flatcar-linux/ignition v0.36.2-0.20220221101037-de4e6cc9bbba h1:HiTCL7737Hi944kXfLN8ReGoJtAiibGIsCk3MGlYy9M=
github.com/flatcar-linux/ignition v0.36.2-0.20220221101037-de4e6cc9bbba/go.mod h1:JzHCIdCu9dy0xtezyBit/aOY4QIlJ12UYU6nXNPnnRE=
github.com/flatcar-linux/ignition/v2 v2.2.1-0.20220302150437-ce14e51676e9/go.mod h1:n076OVuGbg6f+j3YYoxFCjRyMU2hxsx6Q4Gy0xwO7cM=
github.com/flatcar-linux/ignition/v2 v2.2.1-0.20220311122140-cb95c51122f5 h1:k7xpW9MfyAxjsoA0HW6nnHlQnlNlPrPhHPNuT4uf7Xo=
github.com/flatcar-linux/ignition/v2 v2.2.1-0.20220311122140-cb95c51122f5/go.mod h1:C0FynALB9lic4GBqxCuNqUqfZlny9rySbFx0VVXy7uU=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/form3tech-oss/jwt-go v3.2.5+incompatible h1:/l4kBbb4/vGSsdtB5nUe8L7B9mImVMaBPw9L/0TBHU8=
Expand Down Expand Up @@ -451,8 +455,9 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
Expand Down Expand Up @@ -526,7 +531,6 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U=
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
go4.org v0.0.0-20160314031811-03efcb870d84/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE=
go4.org v0.0.0-20200104003542-c7e774b10ea0/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE=
go4.org v0.0.0-20201209231011-d4a079459e60 h1:iqAGo78tVOJXELHQFRjR6TMwItrvXH4hrGJ32I/NFF8=
go4.org v0.0.0-20201209231011-d4a079459e60/go.mod h1:CIiUVy99QCPfoE13bO4EZaz5GZMZXMSBGhxRdsvzbkg=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand Down
14 changes: 6 additions & 8 deletions kola/tests/ignition/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ func init() {
Name: "cl.ignition.kargs",
Run: check,
ClusterSize: 1,
UserData: conf.Ignition(`{
"ignition": {
"version": "3.3.0"
},
"kernelArguments": {
"shouldExist": ["quiet"]
}
}`),
UserData: conf.Butane(`---
variant: flatcar
version: 1.0.0
kernel_arguments:
should_exist:
- quiet`),
MinVersion: semver.Version{Major: 3185},
// The additional reboot causes a large waiting time
// and it's enough to test this on QEMU
Expand Down
35 changes: 13 additions & 22 deletions kola/tests/ignition/luks.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,19 @@ func init() {
ClusterSize: 1,
Distros: []string{"cl"},
MinVersion: semver.Version{Major: 3185},
UserData: conf.Ignition(`{
"ignition": {"version": "3.2.0"},
"storage": {
"luks": [{
"name": "data",
"device": "/dev/disk/by-partlabel/USR-B"
}],
"filesystems": [{
"path": "/var/lib/data",
"device": "/dev/disk/by-id/dm-name-data",
"format": "ext4",
"label": "DATA"
}]
},
"systemd": {
"units": [{
"name": "var-lib-data.mount",
"enabled": true,
"contents": "[Mount]\nWhat=/dev/disk/by-label/DATA\nWhere=/var/lib/data\nType=ext4\n\n[Install]\nWantedBy=local-fs.target"
}]
}
}`),
UserData: conf.Butane(`---
variant: flatcar
version: 1.0.0
storage:
luks:
- name: data
device: /dev/disk/by-partlabel/USR-B
filesystems:
- path: /var/lib/data
device: /dev/disk/by-id/dm-name-data
format: ext4
label: DATA
with_mount_unit: true`),
})
}

Expand Down
63 changes: 52 additions & 11 deletions platform/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,19 @@ import (
"reflect"
"strings"

butane "github.com/coreos/butane/config"
"github.com/coreos/butane/config/common"
cci "github.com/coreos/coreos-cloudinit/config"
ign3err "github.com/coreos/ignition/v2/config/shared/errors"
v3 "github.com/coreos/ignition/v2/config/v3_0"
v3types "github.com/coreos/ignition/v2/config/v3_0/types"
v31 "github.com/coreos/ignition/v2/config/v3_1"
v31types "github.com/coreos/ignition/v2/config/v3_1/types"
v32 "github.com/coreos/ignition/v2/config/v3_2"
v32types "github.com/coreos/ignition/v2/config/v3_2/types"
v33 "github.com/coreos/ignition/v2/config/v3_3"
v33types "github.com/coreos/ignition/v2/config/v3_3/types"
ign3validate "github.com/coreos/ignition/v2/config/validate"
"github.com/coreos/pkg/capnslog"
ct "github.com/flatcar-linux/container-linux-config-transpiler/config"
ignerr "github.com/flatcar-linux/ignition/config/shared/errors"
Expand All @@ -38,16 +50,6 @@ import (
v23 "github.com/flatcar-linux/ignition/config/v2_3"
v23types "github.com/flatcar-linux/ignition/config/v2_3/types"
ignvalidate "github.com/flatcar-linux/ignition/config/validate"
ign3err "github.com/flatcar-linux/ignition/v2/config/shared/errors"
v3 "github.com/flatcar-linux/ignition/v2/config/v3_0"
v3types "github.com/flatcar-linux/ignition/v2/config/v3_0/types"
v31 "github.com/flatcar-linux/ignition/v2/config/v3_1"
v31types "github.com/flatcar-linux/ignition/v2/config/v3_1/types"
v32 "github.com/flatcar-linux/ignition/v2/config/v3_2"
v32types "github.com/flatcar-linux/ignition/v2/config/v3_2/types"
v33 "github.com/flatcar-linux/ignition/v2/config/v3_3"
v33types "github.com/flatcar-linux/ignition/v2/config/v3_3/types"
ign3validate "github.com/flatcar-linux/ignition/v2/config/validate"
"github.com/vincent-petithory/dataurl"
"golang.org/x/crypto/ssh/agent"
)
Expand All @@ -60,6 +62,7 @@ const (
kindIgnition
kindContainerLinuxConfig
kindScript
kindButane
)

var plog = capnslog.NewPackageLogger("github.com/flatcar-linux/mantle", "platform/conf")
Expand Down Expand Up @@ -115,6 +118,13 @@ func CloudConfig(data string) *UserData {
}
}

func Butane(data string) *UserData {
return &UserData{
kind: kindButane,
data: data,
}
}

func Script(data string) *UserData {
return &UserData{
kind: kindScript,
Expand Down Expand Up @@ -170,7 +180,7 @@ func (u *UserData) AddKey(key agent.Key) *UserData {
}

func (u *UserData) IsIgnitionCompatible() bool {
return u.kind == kindIgnition || u.kind == kindContainerLinuxConfig
return u.kind == kindIgnition || u.kind == kindContainerLinuxConfig || u.kind == kindButane
}

// Render parses userdata and returns a new Conf. It returns an error if the
Expand Down Expand Up @@ -299,6 +309,37 @@ func (u *UserData) Render(ctPlatform string) (*Conf, error) {
}

c.ignitionV23 = &ignc
case kindButane:
// CLC translation is done in two steps:
// * Parsing the data
// * Converting the CLC parsed data to Ignition types (bound to the Ignition spec version)
// Butane is a bit different, so we convert data directly to Ignition3.3.0 bytes, butane will
// take care itself to parse the variant / version of the config to do the right translation with an Ignition
// version >= 3.3.0
ignc, report, err := butane.TranslateBytes([]byte(u.data), common.TranslateBytesOptions{})
if err != nil {
return nil, fmt.Errorf("converting Butane to Ignition: %w", err)
}

if report.IsFatal() {
return nil, fmt.Errorf("converting Butane to Ignition: %s", report.String())
}

if len(report.Entries) > 0 {
plog.Warningf("parsing Butane config: %s", report.String())
}

// Doing that allows to benefit from existing Ignition mechanism:
// CopyKeys, AddSystemdUnit, etc.
u.data = string(ignc)

// for consistency.
u.kind = kindIgnition

// Config is now considered as an Ignition configuration.
if err := renderIgnition(); err != nil {
return nil, err
}
default:
panic("invalid kind")
}
Expand Down
1 change: 1 addition & 0 deletions platform/conf/conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func TestConfCopyKey(t *testing.T) {
Ignition(`{ "ignition": { "version": "3.3.0" } }`),
Ignition(`{ "ignitionVersion": 1 }`),
CloudConfig("#cloud-config"),
Butane("variant: flatcar\nversion: 1.0.0"),
}

for i, tt := range tests {
Expand Down
27 changes: 27 additions & 0 deletions vendor/github.com/clarketm/json/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions vendor/github.com/clarketm/json/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading