diff --git a/base/v0_7_exp/schema.go b/base/v0_7_exp/schema.go index ecdeff1e..464dd8c7 100644 --- a/base/v0_7_exp/schema.go +++ b/base/v0_7_exp/schema.go @@ -210,6 +210,8 @@ type Resource struct { Inline *string `yaml:"inline"` // Added, not in ignition spec Local *string `yaml:"local"` // Added, not in ignition spec Verification Verification `yaml:"verification"` + InlineButane *string `yaml:"inline_butane"` // Added, not in ignition spec + LocalButane *string `yaml:"local_butane"` // Added, not in ignition spec } type SSHAuthorizedKey string diff --git a/base/v0_7_exp/translate_test.go b/base/v0_7_exp/tests/translate_test.go similarity index 87% rename from base/v0_7_exp/translate_test.go rename to base/v0_7_exp/tests/translate_test.go index 0433fad3..e776e1ae 100644 --- a/base/v0_7_exp/translate_test.go +++ b/base/v0_7_exp/tests/translate_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License.) -package v0_7_exp +package tests import ( "fmt" @@ -25,6 +25,8 @@ import ( "testing" baseutil "github.com/coreos/butane/base/util" + "github.com/coreos/butane/base/v0_7_exp" + _ "github.com/coreos/butane/config" "github.com/coreos/butane/config/common" confutil "github.com/coreos/butane/config/util" "github.com/coreos/butane/translate" @@ -80,14 +82,14 @@ func TestTranslateFile(t *testing.T) { } tests := []struct { - in File + in v0_7_exp.File out types.File exceptions []translate.Translation report string options common.TranslateOptions }{ { - File{}, + v0_7_exp.File{}, types.File{}, nil, "", @@ -96,41 +98,41 @@ func TestTranslateFile(t *testing.T) { { // contains invalid (by the validator's definition) combinations of fields, // but the translator doesn't care and we can check they all get translated at once - File{ + v0_7_exp.File{ Path: "/foo", - Group: NodeGroup{ + Group: v0_7_exp.NodeGroup{ ID: util.IntToPtr(1), Name: util.StrToPtr("foobar"), }, - User: NodeUser{ + User: v0_7_exp.NodeUser{ ID: util.IntToPtr(1), Name: util.StrToPtr("bazquux"), }, Mode: util.IntToPtr(420), - Append: []Resource{ + Append: []v0_7_exp.Resource{ { Source: util.StrToPtr("http://example/com"), Compression: util.StrToPtr("gzip"), - HTTPHeaders: HTTPHeaders{ - HTTPHeader{ + HTTPHeaders: v0_7_exp.HTTPHeaders{ + v0_7_exp.HTTPHeader{ Name: "Header", Value: util.StrToPtr("this isn't validated"), }, }, - Verification: Verification{ + Verification: v0_7_exp.Verification{ Hash: util.StrToPtr("this isn't validated"), }, }, { Inline: util.StrToPtr("hello"), Compression: util.StrToPtr("gzip"), - HTTPHeaders: HTTPHeaders{ - HTTPHeader{ + HTTPHeaders: v0_7_exp.HTTPHeaders{ + v0_7_exp.HTTPHeader{ Name: "Header", Value: util.StrToPtr("this isn't validated"), }, }, - Verification: Verification{ + Verification: v0_7_exp.Verification{ Hash: util.StrToPtr("this isn't validated"), }, }, @@ -139,16 +141,16 @@ func TestTranslateFile(t *testing.T) { }, }, Overwrite: util.BoolToPtr(true), - Contents: Resource{ + Contents: v0_7_exp.Resource{ Source: util.StrToPtr("http://example/com"), Compression: util.StrToPtr("gzip"), - HTTPHeaders: HTTPHeaders{ - HTTPHeader{ + HTTPHeaders: v0_7_exp.HTTPHeaders{ + v0_7_exp.HTTPHeader{ Name: "Header", Value: util.StrToPtr("this isn't validated"), }, }, - Verification: Verification{ + Verification: v0_7_exp.Verification{ Hash: util.StrToPtr("this isn't validated"), }, }, @@ -284,9 +286,9 @@ func TestTranslateFile(t *testing.T) { }, // inline file contents { - File{ + v0_7_exp.File{ Path: "/foo", - Contents: Resource{ + Contents: v0_7_exp.Resource{ // String is too short for auto gzip compression Inline: util.StrToPtr("xyzzy"), }, @@ -317,9 +319,9 @@ func TestTranslateFile(t *testing.T) { }, // local file contents { - File{ + v0_7_exp.File{ Path: "/foo", - Contents: Resource{ + Contents: v0_7_exp.Resource{ Local: util.StrToPtr("file-1"), }, }, @@ -351,9 +353,9 @@ func TestTranslateFile(t *testing.T) { }, // local file in subdirectory { - File{ + v0_7_exp.File{ Path: "/foo", - Contents: Resource{ + Contents: v0_7_exp.Resource{ Local: util.StrToPtr("subdir/file-4"), }, }, @@ -385,9 +387,9 @@ func TestTranslateFile(t *testing.T) { }, // filesDir not specified { - File{ + v0_7_exp.File{ Path: "/foo", - Contents: Resource{ + Contents: v0_7_exp.Resource{ Local: util.StrToPtr("file-1"), }, }, @@ -402,9 +404,9 @@ func TestTranslateFile(t *testing.T) { }, // attempted directory traversal { - File{ + v0_7_exp.File{ Path: "/foo", - Contents: Resource{ + Contents: v0_7_exp.Resource{ Local: util.StrToPtr("../file-1"), }, }, @@ -421,9 +423,9 @@ func TestTranslateFile(t *testing.T) { }, // attempted inclusion of nonexistent file { - File{ + v0_7_exp.File{ Path: "/foo", - Contents: Resource{ + Contents: v0_7_exp.Resource{ Local: util.StrToPtr("file-missing"), }, }, @@ -440,13 +442,13 @@ func TestTranslateFile(t *testing.T) { }, // inline and local automatic file encoding { - File{ + v0_7_exp.File{ Path: "/foo", - Contents: Resource{ + Contents: v0_7_exp.Resource{ // gzip Inline: util.StrToPtr(zzz), }, - Append: []Resource{ + Append: []v0_7_exp.Resource{ { // gzip Local: util.StrToPtr("file-2"), @@ -553,9 +555,9 @@ func TestTranslateFile(t *testing.T) { }, // Test disable automatic gzip compression { - File{ + v0_7_exp.File{ Path: "/foo", - Contents: Resource{ + Contents: v0_7_exp.Resource{ Inline: util.StrToPtr(zzz), }, }, @@ -589,7 +591,7 @@ func TestTranslateFile(t *testing.T) { for i, test := range tests { t.Run(fmt.Sprintf("translate %d", i), func(t *testing.T) { - actual, translations, r := translateFile(test.in, test.options) + actual, translations, r := v0_7_exp.TranslateFile(test.in, test.options) r = confutil.TranslateReportPaths(r, translations) baseutil.VerifyReport(t, test.in, r) assert.Equal(t, test.out, actual, "translation mismatch") @@ -603,23 +605,23 @@ func TestTranslateFile(t *testing.T) { // TestTranslateDirectory tests translating the ct storage.directories.[i] entries to ignition storage.directories.[i] entires. func TestTranslateDirectory(t *testing.T) { tests := []struct { - in Directory + in v0_7_exp.Directory out types.Directory }{ { - Directory{}, + v0_7_exp.Directory{}, types.Directory{}, }, { // contains invalid (by the validator's definition) combinations of fields, // but the translator doesn't care and we can check they all get translated at once - Directory{ + v0_7_exp.Directory{ Path: "/foo", - Group: NodeGroup{ + Group: v0_7_exp.NodeGroup{ ID: util.IntToPtr(1), Name: util.StrToPtr("foobar"), }, - User: NodeUser{ + User: v0_7_exp.NodeUser{ ID: util.IntToPtr(1), Name: util.StrToPtr("bazquux"), }, @@ -648,7 +650,7 @@ func TestTranslateDirectory(t *testing.T) { for i, test := range tests { t.Run(fmt.Sprintf("translate %d", i), func(t *testing.T) { - actual, translations, r := translateDirectory(test.in, common.TranslateOptions{}) + actual, translations, r := v0_7_exp.TranslateDirectory(test.in, common.TranslateOptions{}) r = confutil.TranslateReportPaths(r, translations) baseutil.VerifyReport(t, test.in, r) assert.Equal(t, test.out, actual, "translation mismatch") @@ -661,23 +663,23 @@ func TestTranslateDirectory(t *testing.T) { // TestTranslateLink tests translating the ct storage.links.[i] entries to ignition storage.links.[i] entires. func TestTranslateLink(t *testing.T) { tests := []struct { - in Link + in v0_7_exp.Link out types.Link }{ { - Link{}, + v0_7_exp.Link{}, types.Link{}, }, { // contains invalid (by the validator's definition) combinations of fields, // but the translator doesn't care and we can check they all get translated at once - Link{ + v0_7_exp.Link{ Path: "/foo", - Group: NodeGroup{ + Group: v0_7_exp.NodeGroup{ ID: util.IntToPtr(1), Name: util.StrToPtr("foobar"), }, - User: NodeUser{ + User: v0_7_exp.NodeUser{ ID: util.IntToPtr(1), Name: util.StrToPtr("bazquux"), }, @@ -708,7 +710,7 @@ func TestTranslateLink(t *testing.T) { for i, test := range tests { t.Run(fmt.Sprintf("translate %d", i), func(t *testing.T) { - actual, translations, r := translateLink(test.in, common.TranslateOptions{}) + actual, translations, r := v0_7_exp.TranslateLink(test.in, common.TranslateOptions{}) r = confutil.TranslateReportPaths(r, translations) baseutil.VerifyReport(t, test.in, r) assert.Equal(t, test.out, actual, "translation mismatch") @@ -721,17 +723,17 @@ func TestTranslateLink(t *testing.T) { // TestTranslateFilesystem tests translating the butane storage.filesystems.[i] entries to ignition storage.filesystems.[i] entries. func TestTranslateFilesystem(t *testing.T) { tests := []struct { - in Filesystem + in v0_7_exp.Filesystem out types.Filesystem }{ { - Filesystem{}, + v0_7_exp.Filesystem{}, types.Filesystem{}, }, { // contains invalid (by the validator's definition) combinations of fields, // but the translator doesn't care and we can check they all get translated at once - Filesystem{ + v0_7_exp.Filesystem{ Device: "/foo", Format: util.StrToPtr("/bar"), Label: util.StrToPtr("/baz"), @@ -759,9 +761,9 @@ func TestTranslateFilesystem(t *testing.T) { t.Run(fmt.Sprintf("translate %d", i), func(t *testing.T) { // Filesystem doesn't have a custom translator, so embed in a // complete config - in := Config{ - Storage: Storage{ - Filesystems: []Filesystem{test.in}, + in := v0_7_exp.Config{ + Storage: v0_7_exp.Storage{ + Filesystems: []v0_7_exp.Filesystem{test.in}, }, } expected := []types.Filesystem{test.out} @@ -788,14 +790,14 @@ func TestTranslateFilesystem(t *testing.T) { // TestTranslateMountUnit tests the Butane storage.filesystems.[i].with_mount_unit flag. func TestTranslateMountUnit(t *testing.T) { tests := []struct { - in Config + in v0_7_exp.Config out types.Config }{ // local mount with options, overridden enabled flag { - Config{ - Storage: Storage{ - Filesystems: []Filesystem{ + v0_7_exp.Config{ + Storage: v0_7_exp.Storage{ + Filesystems: []v0_7_exp.Filesystem{ { Device: "/dev/disk/by-label/foo", Format: util.StrToPtr("ext4"), @@ -805,8 +807,8 @@ func TestTranslateMountUnit(t *testing.T) { }, }, }, - Systemd: Systemd{ - Units: []Unit{ + Systemd: v0_7_exp.Systemd{ + Units: []v0_7_exp.Unit{ { Name: "var-lib-containers.mount", Enabled: util.BoolToPtr(false), @@ -853,9 +855,9 @@ RequiredBy=local-fs.target`), }, // remote mount with options { - Config{ - Storage: Storage{ - Filesystems: []Filesystem{ + v0_7_exp.Config{ + Storage: v0_7_exp.Storage{ + Filesystems: []v0_7_exp.Filesystem{ { Device: "/dev/mapper/foo-bar", Format: util.StrToPtr("ext4"), @@ -864,12 +866,12 @@ RequiredBy=local-fs.target`), WithMountUnit: util.BoolToPtr(true), }, }, - Luks: []Luks{ + Luks: []v0_7_exp.Luks{ { Name: "foo-bar", Device: util.StrToPtr("/dev/bar"), - Clevis: Clevis{ - Tang: []Tang{ + Clevis: v0_7_exp.Clevis{ + Tang: []v0_7_exp.Tang{ { URL: "http://example.com", }, @@ -931,9 +933,9 @@ RequiredBy=remote-fs.target`), }, // local mount, no options { - Config{ - Storage: Storage{ - Filesystems: []Filesystem{ + v0_7_exp.Config{ + Storage: v0_7_exp.Storage{ + Filesystems: []v0_7_exp.Filesystem{ { Device: "/dev/disk/by-label/foo", Format: util.StrToPtr("ext4"), @@ -980,9 +982,9 @@ RequiredBy=local-fs.target`), }, // remote mount, no options { - Config{ - Storage: Storage{ - Filesystems: []Filesystem{ + v0_7_exp.Config{ + Storage: v0_7_exp.Storage{ + Filesystems: []v0_7_exp.Filesystem{ { Device: "/dev/mapper/foo-bar", Format: util.StrToPtr("ext4"), @@ -990,12 +992,12 @@ RequiredBy=local-fs.target`), WithMountUnit: util.BoolToPtr(true), }, }, - Luks: []Luks{ + Luks: []v0_7_exp.Luks{ { Name: "foo-bar", Device: util.StrToPtr("/dev/bar"), - Clevis: Clevis{ - Tang: []Tang{ + Clevis: v0_7_exp.Clevis{ + Tang: []v0_7_exp.Tang{ { URL: "http://example.com", }, @@ -1056,9 +1058,9 @@ RequiredBy=remote-fs.target`), }, // overridden mount unit { - Config{ - Storage: Storage{ - Filesystems: []Filesystem{ + v0_7_exp.Config{ + Storage: v0_7_exp.Storage{ + Filesystems: []v0_7_exp.Filesystem{ { Device: "/dev/disk/by-label/foo", Format: util.StrToPtr("ext4"), @@ -1067,8 +1069,8 @@ RequiredBy=remote-fs.target`), }, }, }, - Systemd: Systemd{ - Units: []Unit{ + Systemd: v0_7_exp.Systemd{ + Units: []v0_7_exp.Unit{ { Name: "var-lib-containers.mount", Contents: util.StrToPtr("[Service]\nExecStart=/bin/false\n"), @@ -1102,9 +1104,9 @@ RequiredBy=remote-fs.target`), }, // swap, no options { - Config{ - Storage: Storage{ - Filesystems: []Filesystem{ + v0_7_exp.Config{ + Storage: v0_7_exp.Storage{ + Filesystems: []v0_7_exp.Filesystem{ { Device: "/dev/disk/by-label/foo", Format: util.StrToPtr("swap"), @@ -1143,9 +1145,9 @@ RequiredBy=swap.target`), }, // swap with options { - Config{ - Storage: Storage{ - Filesystems: []Filesystem{ + v0_7_exp.Config{ + Storage: v0_7_exp.Storage{ + Filesystems: []v0_7_exp.Filesystem{ { Device: "/dev/disk/by-label/foo", Format: util.StrToPtr("swap"), @@ -1207,10 +1209,10 @@ func TestTranslateTree(t *testing.T) { dirFiles map[string]os.FileMode // relative path -> mode dirLinks map[string]string // relative path -> target dirSockets []string // relative path - inTrees []Tree - inFiles []File - inDirs []Directory - inLinks []Link + inTrees []v0_7_exp.Tree + inFiles []v0_7_exp.File + inDirs []v0_7_exp.Directory + inLinks []v0_7_exp.Link outFiles []types.File outLinks []types.Link report string @@ -1235,7 +1237,7 @@ func TestTranslateTree(t *testing.T) { "tree/subdir/link": "../file", "tree/subdir/overridden-link": "../file", }, - inTrees: []Tree{ + inTrees: []v0_7_exp.Tree{ { Local: "tree", }, @@ -1244,26 +1246,26 @@ func TestTranslateTree(t *testing.T) { Path: util.StrToPtr("/etc"), }, }, - inFiles: []File{ + inFiles: []v0_7_exp.File{ { Path: "/overridden", Mode: util.IntToPtr(0600), - User: NodeUser{ + User: v0_7_exp.NodeUser{ Name: util.StrToPtr("bovik"), }, }, { Path: "/overridden-executable", Mode: util.IntToPtr(0600), - User: NodeUser{ + User: v0_7_exp.NodeUser{ Name: util.StrToPtr("bovik"), }, }, }, - inLinks: []Link{ + inLinks: []v0_7_exp.Link{ { Path: "/subdir/overridden-link", - User: NodeUser{ + User: v0_7_exp.NodeUser{ Name: util.StrToPtr("bovik"), }, }, @@ -1409,7 +1411,7 @@ func TestTranslateTree(t *testing.T) { dirLinks: map[string]string{ "tree/subdir/link": "../file", }, - inTrees: []Tree{ + inTrees: []v0_7_exp.Tree{ { Local: "tree", }, @@ -1473,7 +1475,7 @@ func TestTranslateTree(t *testing.T) { "tree13/tree-link": "file", // set up for tree/tree collision "tree14/tree-link": "file", }, - inTrees: []Tree{ + inTrees: []v0_7_exp.Tree{ { Local: "tree0", }, @@ -1523,10 +1525,10 @@ func TestTranslateTree(t *testing.T) { Local: "tree15", }, }, - inFiles: []File{ + inFiles: []v0_7_exp.File{ { Path: "/file", - Contents: Resource{ + Contents: v0_7_exp.Resource{ Source: util.StrToPtr("data:,foo"), }, }, @@ -1534,12 +1536,12 @@ func TestTranslateTree(t *testing.T) { Path: "/file-partial", }, }, - inDirs: []Directory{ + inDirs: []v0_7_exp.Directory{ { Path: "/directory", }, }, - inLinks: []Link{ + inLinks: []v0_7_exp.Link{ { Path: "/link", Target: util.StrToPtr("file"), @@ -1563,7 +1565,7 @@ func TestTranslateTree(t *testing.T) { }, // files-dir escape { - inTrees: []Tree{ + inTrees: []v0_7_exp.Tree{ { Local: "../escape", }, @@ -1573,7 +1575,7 @@ func TestTranslateTree(t *testing.T) { // no files-dir { options: &common.TranslateOptions{}, - inTrees: []Tree{ + inTrees: []v0_7_exp.Tree{ { Local: "tree", }, @@ -1585,7 +1587,7 @@ func TestTranslateTree(t *testing.T) { dirSockets: []string{ "tree/socket", }, - inTrees: []Tree{ + inTrees: []v0_7_exp.Tree{ { Local: "tree", }, @@ -1608,7 +1610,7 @@ func TestTranslateTree(t *testing.T) { dirFiles: map[string]os.FileMode{ "tree/file": 0000, }, - inTrees: []Tree{ + inTrees: []v0_7_exp.Tree{ { Local: "tree", }, @@ -1632,7 +1634,7 @@ func TestTranslateTree(t *testing.T) { dirFiles: map[string]os.FileMode{ "tree": 0600, }, - inTrees: []Tree{ + inTrees: []v0_7_exp.Tree{ { Local: "tree", }, @@ -1702,8 +1704,8 @@ func TestTranslateTree(t *testing.T) { defer listener.Close() } - config := Config{ - Storage: Storage{ + config := v0_7_exp.Config{ + Storage: v0_7_exp.Storage{ Files: test.inFiles, Directories: test.inDirs, Links: test.inLinks, @@ -1738,24 +1740,24 @@ func TestTranslateTree(t *testing.T) { // It ensures that the version is set as well. func TestTranslateIgnition(t *testing.T) { tests := []struct { - in Ignition + in v0_7_exp.Ignition out types.Ignition }{ { - Ignition{}, + v0_7_exp.Ignition{}, types.Ignition{ Version: "3.6.0-experimental", }, }, { - Ignition{ - Config: IgnitionConfig{ - Merge: []Resource{ + v0_7_exp.Ignition{ + Config: v0_7_exp.IgnitionConfig{ + Merge: []v0_7_exp.Resource{ { Inline: util.StrToPtr("xyzzy"), }, }, - Replace: Resource{ + Replace: v0_7_exp.Resource{ Inline: util.StrToPtr("xyzzy"), }, }, @@ -1777,8 +1779,51 @@ func TestTranslateIgnition(t *testing.T) { }, }, { - Ignition{ - Proxy: Proxy{ + v0_7_exp.Ignition{ + Config: v0_7_exp.IgnitionConfig{ + Merge: []v0_7_exp.Resource{ + { + InlineButane: util.StrToPtr(` + variant: fcos + version: 1.6.0 + storage: + links: + - path: /etc/localtime + target: ../usr/share/zoneinfo/Europe/Paris + `), + }, + }, + Replace: v0_7_exp.Resource{ + InlineButane: util.StrToPtr(` + variant: fcos + version: 1.6.0 + storage: + links: + - path: /etc/localtime + target: ../usr/share/zoneinfo/Europe/Paris + `), + }, + }, + }, + types.Ignition{ + Version: "3.6.0-experimental", + Config: types.IgnitionConfig{ + Merge: []types.Resource{ + { + Source: util.StrToPtr("data:;base64,eyJpZ25pdGlvbiI6eyJ2ZXJzaW9uIjoiMy41LjAifSwic3RvcmFnZSI6eyJsaW5rcyI6W3sicGF0aCI6Ii9ldGMvbG9jYWx0aW1lIiwidGFyZ2V0IjoiLi4vdXNyL3NoYXJlL3pvbmVpbmZvL0V1cm9wZS9QYXJpcyJ9XX19"), + Compression: util.StrToPtr(""), + }, + }, + Replace: types.Resource{ + Source: util.StrToPtr("data:;base64,eyJpZ25pdGlvbiI6eyJ2ZXJzaW9uIjoiMy41LjAifSwic3RvcmFnZSI6eyJsaW5rcyI6W3sicGF0aCI6Ii9ldGMvbG9jYWx0aW1lIiwidGFyZ2V0IjoiLi4vdXNyL3NoYXJlL3pvbmVpbmZvL0V1cm9wZS9QYXJpcyJ9XX19"), + Compression: util.StrToPtr(""), + }, + }, + }, + }, + { + v0_7_exp.Ignition{ + Proxy: v0_7_exp.Proxy{ HTTPProxy: util.StrToPtr("https://example.com:8080"), NoProxy: []string{"example.com"}, }, @@ -1792,10 +1837,10 @@ func TestTranslateIgnition(t *testing.T) { }, }, { - Ignition{ - Security: Security{ - TLS: TLS{ - CertificateAuthorities: []Resource{ + v0_7_exp.Ignition{ + Security: v0_7_exp.Security{ + TLS: v0_7_exp.TLS{ + CertificateAuthorities: []v0_7_exp.Resource{ { Inline: util.StrToPtr("xyzzy"), }, @@ -1820,7 +1865,7 @@ func TestTranslateIgnition(t *testing.T) { } for i, test := range tests { t.Run(fmt.Sprintf("translate %d", i), func(t *testing.T) { - actual, translations, r := translateIgnition(test.in, common.TranslateOptions{}) + actual, translations, r := v0_7_exp.TranslateIgnition(test.in, common.TranslateOptions{}) r = confutil.TranslateReportPaths(r, translations) baseutil.VerifyReport(t, test.in, r) assert.Equal(t, test.out, actual, "translation mismatch") @@ -1840,16 +1885,16 @@ func TestTranslateIgnition(t *testing.T) { // KernelArguments do not use a custom translation function (it utilizes the MergeP2 functionality) so pass an entire config func TestTranslateKernelArguments(t *testing.T) { tests := []struct { - in Config + in v0_7_exp.Config out types.Config }{ { - Config{ - KernelArguments: KernelArguments{ - ShouldExist: []KernelArgument{ + v0_7_exp.Config{ + KernelArguments: v0_7_exp.KernelArguments{ + ShouldExist: []v0_7_exp.KernelArgument{ "foo", }, - ShouldNotExist: []KernelArgument{ + ShouldNotExist: []v0_7_exp.KernelArgument{ "bar", }, }, @@ -1884,25 +1929,25 @@ func TestTranslateKernelArguments(t *testing.T) { // TestTranslateLuks test translating the butane storage.luks.clevis.tang.[i] arguments to ignition storage.luks.clevis.tang.[i] entries. func TestTranslateTang(t *testing.T) { tests := []struct { - in Config + in v0_7_exp.Config out types.Config }{ // Luks with tang and all options set, returns a valid ignition config with the same options { - Config{ - Storage: Storage{ - Filesystems: []Filesystem{ + v0_7_exp.Config{ + Storage: v0_7_exp.Storage{ + Filesystems: []v0_7_exp.Filesystem{ { Device: "/dev/mapper/foo-bar", Path: util.StrToPtr("/var/lib/containers"), }, }, - Luks: []Luks{ + Luks: []v0_7_exp.Luks{ { Name: "foo-bar", Device: util.StrToPtr("/dev/bar"), - Clevis: Clevis{ - Tang: []Tang{ + Clevis: v0_7_exp.Clevis{ + Tang: []v0_7_exp.Tang{ { URL: "http://example.com", Thumbprint: util.StrToPtr("xyzzy"), @@ -1987,7 +2032,7 @@ func TestTranslateSSHAuthorizedKey(t *testing.T) { tests := []struct { name string - in PasswdUser + in v0_7_exp.PasswdUser out types.PasswdUser translations []translate.Translation report string @@ -1995,7 +2040,7 @@ func TestTranslateSSHAuthorizedKey(t *testing.T) { }{ { "empty user", - PasswdUser{}, + v0_7_exp.PasswdUser{}, types.PasswdUser{}, []translate.Translation{}, "", @@ -2003,7 +2048,7 @@ func TestTranslateSSHAuthorizedKey(t *testing.T) { }, { "valid inline keys", - PasswdUser{SSHAuthorizedKeys: []SSHAuthorizedKey{SSHAuthorizedKey(sshKeyInline)}}, + v0_7_exp.PasswdUser{SSHAuthorizedKeys: []v0_7_exp.SSHAuthorizedKey{v0_7_exp.SSHAuthorizedKey(sshKeyInline)}}, types.PasswdUser{SSHAuthorizedKeys: []types.SSHAuthorizedKey{types.SSHAuthorizedKey(sshKeyInline)}}, []translate.Translation{ {From: path.New("yaml", "ssh_authorized_keys"), To: path.New("json", "sshAuthorizedKeys")}, @@ -2014,7 +2059,7 @@ func TestTranslateSSHAuthorizedKey(t *testing.T) { }, { "valid local keys", - PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyFileName}}, + v0_7_exp.PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyFileName}}, types.PasswdUser{SSHAuthorizedKeys: []types.SSHAuthorizedKey{types.SSHAuthorizedKey(sshKey1)}}, []translate.Translation{ {From: path.New("yaml", "ssh_authorized_keys_local"), To: path.New("json", "sshAuthorizedKeys")}, @@ -2025,7 +2070,7 @@ func TestTranslateSSHAuthorizedKey(t *testing.T) { }, { "valid local keys with multiple keys per file", - PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyMultipleKeysFileName}}, + v0_7_exp.PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyMultipleKeysFileName}}, types.PasswdUser{SSHAuthorizedKeys: []types.SSHAuthorizedKey{ types.SSHAuthorizedKey(sshKey2), types.SSHAuthorizedKey("#comment"), @@ -2042,7 +2087,7 @@ func TestTranslateSSHAuthorizedKey(t *testing.T) { }, { "valid multiple local key files", - PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyFileName, sshKeyMultipleKeysFileName}}, + v0_7_exp.PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyFileName, sshKeyMultipleKeysFileName}}, types.PasswdUser{SSHAuthorizedKeys: []types.SSHAuthorizedKey{ types.SSHAuthorizedKey(sshKey1), types.SSHAuthorizedKey(sshKey2), @@ -2061,7 +2106,7 @@ func TestTranslateSSHAuthorizedKey(t *testing.T) { }, { "valid local and inline keys", - PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyFileName}, SSHAuthorizedKeys: []SSHAuthorizedKey{SSHAuthorizedKey(sshKeyInline)}}, + v0_7_exp.PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyFileName}, SSHAuthorizedKeys: []v0_7_exp.SSHAuthorizedKey{v0_7_exp.SSHAuthorizedKey(sshKeyInline)}}, types.PasswdUser{SSHAuthorizedKeys: []types.SSHAuthorizedKey{types.SSHAuthorizedKey(sshKeyInline), types.SSHAuthorizedKey(sshKey1)}}, []translate.Translation{ {From: path.New("yaml", "ssh_authorized_keys_local"), To: path.New("json", "sshAuthorizedKeys")}, @@ -2073,7 +2118,7 @@ func TestTranslateSSHAuthorizedKey(t *testing.T) { }, { "valid local keys with multiple keys per file and inline keys", - PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyMultipleKeysFileName}, SSHAuthorizedKeys: []SSHAuthorizedKey{SSHAuthorizedKey(sshKeyInline)}}, + v0_7_exp.PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyMultipleKeysFileName}, SSHAuthorizedKeys: []v0_7_exp.SSHAuthorizedKey{v0_7_exp.SSHAuthorizedKey(sshKeyInline)}}, types.PasswdUser{SSHAuthorizedKeys: []types.SSHAuthorizedKey{ types.SSHAuthorizedKey(sshKeyInline), types.SSHAuthorizedKey(sshKey2), @@ -2092,7 +2137,7 @@ func TestTranslateSSHAuthorizedKey(t *testing.T) { }, { "valid empty local file", - PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyEmptyFileName}}, + v0_7_exp.PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyEmptyFileName}}, types.PasswdUser{}, []translate.Translation{ {From: path.New("yaml", "ssh_authorized_keys_local"), To: path.New("json", "sshAuthorizedKeys")}, @@ -2102,7 +2147,7 @@ func TestTranslateSSHAuthorizedKey(t *testing.T) { }, { "valid blank local file", - PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyBlankFileName}}, + v0_7_exp.PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyBlankFileName}}, types.PasswdUser{SSHAuthorizedKeys: []types.SSHAuthorizedKey{types.SSHAuthorizedKey("\t")}}, []translate.Translation{ {From: path.New("yaml", "ssh_authorized_keys_local"), To: path.New("json", "sshAuthorizedKeys")}, @@ -2113,7 +2158,7 @@ func TestTranslateSSHAuthorizedKey(t *testing.T) { }, { "valid Windows style line endings in local file", - PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyWindowsLineEndingsFileName}}, + v0_7_exp.PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyWindowsLineEndingsFileName}}, types.PasswdUser{SSHAuthorizedKeys: []types.SSHAuthorizedKey{ types.SSHAuthorizedKey(sshKey1), types.SSHAuthorizedKey("#comment"), @@ -2128,7 +2173,7 @@ func TestTranslateSSHAuthorizedKey(t *testing.T) { }, { "missing local file", - PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyNonExistingFileName}}, + v0_7_exp.PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyNonExistingFileName}}, types.PasswdUser{}, []translate.Translation{ {From: path.New("yaml", "ssh_authorized_keys_local"), To: path.New("json", "sshAuthorizedKeys")}, @@ -2138,7 +2183,7 @@ func TestTranslateSSHAuthorizedKey(t *testing.T) { }, { "missing embed directory", - PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyFileName}}, + v0_7_exp.PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyFileName}}, types.PasswdUser{}, []translate.Translation{ {From: path.New("yaml", "ssh_authorized_keys_local"), To: path.New("json", "sshAuthorizedKeys")}, @@ -2148,7 +2193,7 @@ func TestTranslateSSHAuthorizedKey(t *testing.T) { }, { "wrong embed directory", - PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyFileName}}, + v0_7_exp.PasswdUser{SSHAuthorizedKeysLocal: []string{sshKeyFileName}}, types.PasswdUser{}, []translate.Translation{ {From: path.New("yaml", "ssh_authorized_keys_local"), To: path.New("json", "sshAuthorizedKeys")}, @@ -2160,7 +2205,7 @@ func TestTranslateSSHAuthorizedKey(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - actual, translations, r := translatePasswdUser(test.in, common.TranslateOptions{FilesDir: test.fileDir}) + actual, translations, r := v0_7_exp.TranslatePasswdUser(test.in, common.TranslateOptions{FilesDir: test.fileDir}) r = confutil.TranslateReportPaths(r, translations) baseutil.VerifyReport(t, test.in, r) assert.Equal(t, test.out, actual, "translation mismatch") @@ -2194,7 +2239,7 @@ func TestTranslateUnitLocal(t *testing.T) { tests := []struct { name string - in Unit + in v0_7_exp.Unit out types.Unit translations []translate.Translation report string @@ -2202,7 +2247,7 @@ func TestTranslateUnitLocal(t *testing.T) { }{ { "empty unit", - Unit{}, + v0_7_exp.Unit{}, types.Unit{}, []translate.Translation{}, "", @@ -2210,7 +2255,7 @@ func TestTranslateUnitLocal(t *testing.T) { }, { "valid contents", - Unit{Contents: &unitDefinitionInline, Name: unitName}, + v0_7_exp.Unit{Contents: &unitDefinitionInline, Name: unitName}, types.Unit{Contents: &unitDefinitionInline, Name: unitName}, []translate.Translation{}, "", @@ -2218,7 +2263,7 @@ func TestTranslateUnitLocal(t *testing.T) { }, { "valid contents_local", - Unit{ContentsLocal: &unitName, Name: unitName}, + v0_7_exp.Unit{ContentsLocal: &unitName, Name: unitName}, types.Unit{Contents: &unitDefinitionFile, Name: unitName}, []translate.Translation{ {From: path.New("yaml", "contents_local"), To: path.New("json", "contents")}, @@ -2228,7 +2273,7 @@ func TestTranslateUnitLocal(t *testing.T) { }, { "non existing contents_local file name", - Unit{ContentsLocal: &unitNonExistingFileName, Name: unitName}, + v0_7_exp.Unit{ContentsLocal: &unitNonExistingFileName, Name: unitName}, types.Unit{Name: unitName}, []translate.Translation{}, "error at $.contents_local: open " + filepath.Join(unitDir, unitNonExistingFileName) + ": " + osNotFound + "\n", @@ -2236,7 +2281,7 @@ func TestTranslateUnitLocal(t *testing.T) { }, { "valid empty contents_local file", - Unit{ContentsLocal: &unitEmptyFileName, Name: unitName}, + v0_7_exp.Unit{ContentsLocal: &unitEmptyFileName, Name: unitName}, types.Unit{Contents: &unitEmptyDefinition, Name: unitName}, []translate.Translation{ {From: path.New("yaml", "contents_local"), To: path.New("json", "contents")}, @@ -2246,7 +2291,7 @@ func TestTranslateUnitLocal(t *testing.T) { }, { "missing embed directory", - Unit{ContentsLocal: &unitName, Name: unitName}, + v0_7_exp.Unit{ContentsLocal: &unitName, Name: unitName}, types.Unit{Name: unitName}, []translate.Translation{}, "error at $.contents_local: " + common.ErrNoFilesDir.Error() + "\n", @@ -2254,7 +2299,7 @@ func TestTranslateUnitLocal(t *testing.T) { }, { "wrong embed directory", - Unit{ContentsLocal: &unitName, Name: unitName}, + v0_7_exp.Unit{ContentsLocal: &unitName, Name: unitName}, types.Unit{Name: unitName}, []translate.Translation{}, "error at $.contents_local: open " + filepath.Join(randomDir, unitName) + ": " + osNotFound + "\n", @@ -2262,7 +2307,7 @@ func TestTranslateUnitLocal(t *testing.T) { }, { "empty dropin unit", - Unit{Name: dropinName, Dropins: nil}, + v0_7_exp.Unit{Name: dropinName, Dropins: nil}, types.Unit{Name: dropinName, Dropins: nil}, []translate.Translation{}, "", @@ -2270,7 +2315,7 @@ func TestTranslateUnitLocal(t *testing.T) { }, { "valid dropin contents", - Unit{Dropins: []Dropin{{Name: dropinName, Contents: &unitDefinitionInline}}, Name: unitName}, + v0_7_exp.Unit{Dropins: []v0_7_exp.Dropin{{Name: dropinName, Contents: &unitDefinitionInline}}, Name: unitName}, types.Unit{Dropins: []types.Dropin{{Name: dropinName, Contents: &unitDefinitionInline}}, Name: unitName}, []translate.Translation{}, "", @@ -2278,7 +2323,7 @@ func TestTranslateUnitLocal(t *testing.T) { }, { "valid dropin contents_local", - Unit{Dropins: []Dropin{{Name: dropinName, ContentsLocal: &unitName}}, Name: unitName}, + v0_7_exp.Unit{Dropins: []v0_7_exp.Dropin{{Name: dropinName, ContentsLocal: &unitName}}, Name: unitName}, types.Unit{Dropins: []types.Dropin{{Name: dropinName, Contents: &unitDefinitionFile}}, Name: unitName}, []translate.Translation{ {From: path.New("yaml", "dropins", 0, "contents_local"), To: path.New("json", "dropins", 0, "contents")}, @@ -2288,7 +2333,7 @@ func TestTranslateUnitLocal(t *testing.T) { }, { "non existing dropin contents_local file name", - Unit{Dropins: []Dropin{{Name: dropinName, ContentsLocal: &unitNonExistingFileName}}, Name: unitName}, + v0_7_exp.Unit{Dropins: []v0_7_exp.Dropin{{Name: dropinName, ContentsLocal: &unitNonExistingFileName}}, Name: unitName}, types.Unit{Dropins: []types.Dropin{{Name: dropinName}}, Name: unitName}, []translate.Translation{}, "error at $.dropins.0.contents_local: open " + filepath.Join(unitDir, unitNonExistingFileName) + ": " + osNotFound + "\n", @@ -2296,7 +2341,7 @@ func TestTranslateUnitLocal(t *testing.T) { }, { "valid empty dropin contents_local file", - Unit{Dropins: []Dropin{{Name: dropinName, ContentsLocal: &unitEmptyFileName}}, Name: unitName}, + v0_7_exp.Unit{Dropins: []v0_7_exp.Dropin{{Name: dropinName, ContentsLocal: &unitEmptyFileName}}, Name: unitName}, types.Unit{Dropins: []types.Dropin{{Name: dropinName, Contents: &unitEmptyDefinition}}, Name: unitName}, []translate.Translation{ {From: path.New("yaml", "dropins", 0, "contents_local"), To: path.New("json", "dropins", 0, "contents")}, @@ -2306,7 +2351,7 @@ func TestTranslateUnitLocal(t *testing.T) { }, { "missing embed directory for dropin", - Unit{Dropins: []Dropin{{Name: dropinName, ContentsLocal: &unitName}}, Name: unitName}, + v0_7_exp.Unit{Dropins: []v0_7_exp.Dropin{{Name: dropinName, ContentsLocal: &unitName}}, Name: unitName}, types.Unit{Dropins: []types.Dropin{{Name: dropinName}}, Name: unitName}, []translate.Translation{}, "error at $.dropins.0.contents_local: " + common.ErrNoFilesDir.Error() + "\n", @@ -2314,7 +2359,7 @@ func TestTranslateUnitLocal(t *testing.T) { }, { "wrong embed directory for dropin", - Unit{Dropins: []Dropin{{Name: dropinName, ContentsLocal: &unitName}}, Name: unitName}, + v0_7_exp.Unit{Dropins: []v0_7_exp.Dropin{{Name: dropinName, ContentsLocal: &unitName}}, Name: unitName}, types.Unit{Dropins: []types.Dropin{{Name: dropinName}}, Name: unitName}, []translate.Translation{}, "error at $.dropins.0.contents_local: open " + filepath.Join(randomDir, unitName) + ": " + osNotFound + "\n", @@ -2324,7 +2369,7 @@ func TestTranslateUnitLocal(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - actual, translations, r := translateUnit(test.in, common.TranslateOptions{FilesDir: test.fileDir}) + actual, translations, r := v0_7_exp.TranslateUnit(test.in, common.TranslateOptions{FilesDir: test.fileDir}) r = confutil.TranslateReportPaths(r, translations) baseutil.VerifyReport(t, test.in, r) assert.Equal(t, test.out, actual, "translation mismatch") @@ -2339,11 +2384,11 @@ func TestTranslateUnitLocal(t *testing.T) { // tested since it uses the Ignition translation code which has its own set of tests. func TestToIgn3_6(t *testing.T) { tests := []struct { - in Config + in v0_7_exp.Config out types.Config }{ { - Config{}, + v0_7_exp.Config{}, types.Config{ Ignition: types.Ignition{ Version: "3.6.0-experimental", diff --git a/base/v0_7_exp/validate_test.go b/base/v0_7_exp/tests/validate_test.go similarity index 88% rename from base/v0_7_exp/validate_test.go rename to base/v0_7_exp/tests/validate_test.go index aacb3b29..7cf9f500 100644 --- a/base/v0_7_exp/validate_test.go +++ b/base/v0_7_exp/tests/validate_test.go @@ -12,13 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License.) -package v0_7_exp +package tests import ( "fmt" "testing" baseutil "github.com/coreos/butane/base/util" + "github.com/coreos/butane/base/v0_7_exp" "github.com/coreos/butane/config/common" "github.com/coreos/ignition/v2/config/util" @@ -30,7 +31,7 @@ import ( // TestValidateResource tests that multiple sources (i.e. urls and inline) are not allowed but zero or one sources are func TestValidateResource(t *testing.T) { tests := []struct { - in Resource + in v0_7_exp.Resource out error errPath path.ContextPath }{ @@ -39,10 +40,10 @@ func TestValidateResource(t *testing.T) { { // contains invalid (by the validator's definition) combinations of fields, // but the translator doesn't care and we can check they all get translated at once - Resource{ + v0_7_exp.Resource{ Source: util.StrToPtr("http://example/com"), Compression: util.StrToPtr("gzip"), - Verification: Verification{ + Verification: v0_7_exp.Verification{ Hash: util.StrToPtr("this isn't validated"), }, }, @@ -51,10 +52,10 @@ func TestValidateResource(t *testing.T) { }, // inline specified { - Resource{ + v0_7_exp.Resource{ Inline: util.StrToPtr("hello"), Compression: util.StrToPtr("gzip"), - Verification: Verification{ + Verification: v0_7_exp.Verification{ Hash: util.StrToPtr("this isn't validated"), }, }, @@ -63,10 +64,10 @@ func TestValidateResource(t *testing.T) { }, // local specified { - Resource{ + v0_7_exp.Resource{ Local: util.StrToPtr("hello"), Compression: util.StrToPtr("gzip"), - Verification: Verification{ + Verification: v0_7_exp.Verification{ Hash: util.StrToPtr("this isn't validated"), }, }, @@ -75,11 +76,11 @@ func TestValidateResource(t *testing.T) { }, // source + inline, invalid { - Resource{ + v0_7_exp.Resource{ Source: util.StrToPtr("data:,hello"), Inline: util.StrToPtr("hello"), Compression: util.StrToPtr("gzip"), - Verification: Verification{ + Verification: v0_7_exp.Verification{ Hash: util.StrToPtr("this isn't validated"), }, }, @@ -88,11 +89,11 @@ func TestValidateResource(t *testing.T) { }, // source + local, invalid { - Resource{ + v0_7_exp.Resource{ Source: util.StrToPtr("data:,hello"), Local: util.StrToPtr("hello"), Compression: util.StrToPtr("gzip"), - Verification: Verification{ + Verification: v0_7_exp.Verification{ Hash: util.StrToPtr("this isn't validated"), }, }, @@ -101,11 +102,11 @@ func TestValidateResource(t *testing.T) { }, // inline + local, invalid { - Resource{ + v0_7_exp.Resource{ Inline: util.StrToPtr("hello"), Local: util.StrToPtr("hello"), Compression: util.StrToPtr("gzip"), - Verification: Verification{ + Verification: v0_7_exp.Verification{ Hash: util.StrToPtr("this isn't validated"), }, }, @@ -114,12 +115,12 @@ func TestValidateResource(t *testing.T) { }, // source + inline + local, invalid { - Resource{ + v0_7_exp.Resource{ Source: util.StrToPtr("data:,hello"), Inline: util.StrToPtr("hello"), Local: util.StrToPtr("hello"), Compression: util.StrToPtr("gzip"), - Verification: Verification{ + Verification: v0_7_exp.Verification{ Hash: util.StrToPtr("this isn't validated"), }, }, @@ -141,11 +142,11 @@ func TestValidateResource(t *testing.T) { func TestValidateTree(t *testing.T) { tests := []struct { - in Tree + in v0_7_exp.Tree out error }{ { - in: Tree{}, + in: v0_7_exp.Tree{}, out: common.ErrTreeNoLocal, }, } @@ -163,21 +164,21 @@ func TestValidateTree(t *testing.T) { func TestValidateFileMode(t *testing.T) { fileTests := []struct { - in File + in v0_7_exp.File out error }{ { - in: File{}, + in: v0_7_exp.File{}, out: nil, }, { - in: File{ + in: v0_7_exp.File{ Mode: util.IntToPtr(0600), }, out: nil, }, { - in: File{ + in: v0_7_exp.File{ Mode: util.IntToPtr(600), }, out: common.ErrDecimalMode, @@ -197,21 +198,21 @@ func TestValidateFileMode(t *testing.T) { func TestValidateDirMode(t *testing.T) { dirTests := []struct { - in Directory + in v0_7_exp.Directory out error }{ { - in: Directory{}, + in: v0_7_exp.Directory{}, out: nil, }, { - in: Directory{ + in: v0_7_exp.Directory{ Mode: util.IntToPtr(01770), }, out: nil, }, { - in: Directory{ + in: v0_7_exp.Directory{ Mode: util.IntToPtr(1770), }, out: common.ErrDecimalMode, @@ -231,24 +232,24 @@ func TestValidateDirMode(t *testing.T) { func TestValidateFilesystem(t *testing.T) { tests := []struct { - in Filesystem + in v0_7_exp.Filesystem out error errPath path.ContextPath }{ { - Filesystem{}, + v0_7_exp.Filesystem{}, nil, path.New("yaml"), }, { - Filesystem{ + v0_7_exp.Filesystem{ Device: "/dev/foo", }, nil, path.New("yaml"), }, { - Filesystem{ + v0_7_exp.Filesystem{ Device: "/dev/foo", Format: util.StrToPtr("zzz"), Path: util.StrToPtr("/z"), @@ -258,7 +259,7 @@ func TestValidateFilesystem(t *testing.T) { path.New("yaml"), }, { - Filesystem{ + v0_7_exp.Filesystem{ Device: "/dev/foo", Format: util.StrToPtr("swap"), WithMountUnit: util.BoolToPtr(true), @@ -267,7 +268,7 @@ func TestValidateFilesystem(t *testing.T) { path.New("yaml"), }, { - Filesystem{ + v0_7_exp.Filesystem{ Device: "/dev/foo", WithMountUnit: util.BoolToPtr(true), }, @@ -275,7 +276,7 @@ func TestValidateFilesystem(t *testing.T) { path.New("yaml", "format"), }, { - Filesystem{ + v0_7_exp.Filesystem{ Device: "/dev/foo", Format: util.StrToPtr("zzz"), WithMountUnit: util.BoolToPtr(true), @@ -299,14 +300,14 @@ func TestValidateFilesystem(t *testing.T) { // TestValidateUnit tests that multiple sources (i.e. contents and contents_local) are not allowed but zero or one sources are func TestValidateUnit(t *testing.T) { tests := []struct { - in Unit + in v0_7_exp.Unit out error errPath path.ContextPath }{ {}, // contents specified { - Unit{ + v0_7_exp.Unit{ Contents: util.StrToPtr("hello"), }, nil, @@ -314,7 +315,7 @@ func TestValidateUnit(t *testing.T) { }, // contents_local specified { - Unit{ + v0_7_exp.Unit{ ContentsLocal: util.StrToPtr("hello"), }, nil, @@ -322,7 +323,7 @@ func TestValidateUnit(t *testing.T) { }, // contents + contents_local, invalid { - Unit{ + v0_7_exp.Unit{ Contents: util.StrToPtr("hello"), ContentsLocal: util.StrToPtr("hello, too"), }, @@ -345,14 +346,14 @@ func TestValidateUnit(t *testing.T) { // TestValidateDropin tests that multiple sources (i.e. contents and contents_local) are not allowed but zero or one sources are func TestValidateDropin(t *testing.T) { tests := []struct { - in Dropin + in v0_7_exp.Dropin out error errPath path.ContextPath }{ {}, // contents specified { - Dropin{ + v0_7_exp.Dropin{ Contents: util.StrToPtr("hello"), }, nil, @@ -360,7 +361,7 @@ func TestValidateDropin(t *testing.T) { }, // contents_local specified { - Dropin{ + v0_7_exp.Dropin{ ContentsLocal: util.StrToPtr("hello"), }, nil, @@ -368,7 +369,7 @@ func TestValidateDropin(t *testing.T) { }, // contents + contents_local, invalid { - Dropin{ + v0_7_exp.Dropin{ Contents: util.StrToPtr("hello"), ContentsLocal: util.StrToPtr("hello, too"), }, @@ -391,11 +392,11 @@ func TestValidateDropin(t *testing.T) { // TestUnkownIgnitionVersion tests that butane will raise a warning but will not fail when an ignition config with an unkown version is specified func TestUnkownIgnitionVersion(t *testing.T) { test := struct { - in Resource + in v0_7_exp.Resource out error errPath path.ContextPath }{ - Resource{ + v0_7_exp.Resource{ Inline: util.StrToPtr(`{"ignition": {"version": "10.0.0"}}`), }, common.ErrUnkownIgnitionVersion, diff --git a/base/v0_7_exp/translate.go b/base/v0_7_exp/translate.go index fd95720d..887295bf 100644 --- a/base/v0_7_exp/translate.go +++ b/base/v0_7_exp/translate.go @@ -82,13 +82,13 @@ func (c Config) ToIgn3_6Unvalidated(options common.TranslateOptions) (types.Conf ret := types.Config{} tr := translate.NewTranslator("yaml", "json", options) - tr.AddCustomTranslator(translateIgnition) - tr.AddCustomTranslator(translateFile) - tr.AddCustomTranslator(translateDirectory) - tr.AddCustomTranslator(translateLink) - tr.AddCustomTranslator(translateResource) - tr.AddCustomTranslator(translatePasswdUser) - tr.AddCustomTranslator(translateUnit) + tr.AddCustomTranslator(TranslateIgnition) + tr.AddCustomTranslator(TranslateFile) + tr.AddCustomTranslator(TranslateDirectory) + tr.AddCustomTranslator(TranslateLink) + tr.AddCustomTranslator(TranslateResource) + tr.AddCustomTranslator(TranslatePasswdUser) + tr.AddCustomTranslator(TranslateUnit) tm, r := translate.Prefixed(tr, "ignition", &c.Ignition, &ret.Ignition) tm.AddTranslation(path.New("yaml", "version"), path.New("json", "ignition", "version")) @@ -110,9 +110,9 @@ func (c Config) ToIgn3_6Unvalidated(options common.TranslateOptions) (types.Conf return ret, tm, r } -func translateIgnition(from Ignition, options common.TranslateOptions) (to types.Ignition, tm translate.TranslationSet, r report.Report) { +func TranslateIgnition(from Ignition, options common.TranslateOptions) (to types.Ignition, tm translate.TranslationSet, r report.Report) { tr := translate.NewTranslator("yaml", "json", options) - tr.AddCustomTranslator(translateResource) + tr.AddCustomTranslator(TranslateResource) to.Version = types.MaxVersion.String() tm, r = translate.Prefixed(tr, "config", &from.Config, &to.Config) translate.MergeP(tr, tm, &r, "proxy", &from.Proxy, &to.Proxy) @@ -121,9 +121,9 @@ func translateIgnition(from Ignition, options common.TranslateOptions) (to types return } -func translateFile(from File, options common.TranslateOptions) (to types.File, tm translate.TranslationSet, r report.Report) { +func TranslateFile(from File, options common.TranslateOptions) (to types.File, tm translate.TranslationSet, r report.Report) { tr := translate.NewTranslator("yaml", "json", options) - tr.AddCustomTranslator(translateResource) + tr.AddCustomTranslator(TranslateResource) tm, r = translate.Prefixed(tr, "group", &from.Group, &to.Group) translate.MergeP(tr, tm, &r, "user", &from.User, &to.User) translate.MergeP(tr, tm, &r, "append", &from.Append, &to.Append) @@ -134,7 +134,7 @@ func translateFile(from File, options common.TranslateOptions) (to types.File, t return } -func translateResource(from Resource, options common.TranslateOptions) (to types.Resource, tm translate.TranslationSet, r report.Report) { +func TranslateResource(from Resource, options common.TranslateOptions) (to types.Resource, tm translate.TranslationSet, r report.Report) { tr := translate.NewTranslator("yaml", "json", options) tm, r = translate.Prefixed(tr, "verification", &from.Verification, &to.Verification) translate.MergeP2(tr, tm, &r, "http_headers", &from.HTTPHeaders, "httpHeaders", &to.HTTPHeaders) @@ -148,6 +148,7 @@ func translateResource(from Resource, options common.TranslateOptions) (to types r.AddOnError(c, err) return } + // Validating the contents of the local file from here since there is no way to // get both the filename and filedirectory in the Validate context if strings.HasPrefix(c.String(), "$.ignition.config") { @@ -157,39 +158,36 @@ func translateResource(from Resource, options common.TranslateOptions) (to types return } } - - src, compression, err := baseutil.MakeDataURL(contents, to.Compression, !options.NoResourceAutoCompression) - if err != nil { - r.AddOnError(c, err) - return - } - to.Source = &src - tm.AddTranslation(c, path.New("json", "source")) - if compression != nil { - to.Compression = compression - tm.AddTranslation(c, path.New("json", "compression")) - } + contentToURL(contents, c, &r, &to, &tm, options) } if from.Inline != nil { c := path.New("yaml", "inline") + contentToURL([]byte(*from.Inline), c, &r, &to, &tm, options) + } + + if from.LocalButane != nil { + c := path.New("yaml", "local_butane") - src, compression, err := baseutil.MakeDataURL([]byte(*from.Inline), to.Compression, !options.NoResourceAutoCompression) + contents, err := baseutil.ReadLocalFile(*from.LocalButane, options.FilesDir) if err != nil { r.AddOnError(c, err) return } - to.Source = &src - tm.AddTranslation(c, path.New("json", "source")) - if compression != nil { - to.Compression = compression - tm.AddTranslation(c, path.New("json", "compression")) - } + + translateButaneResource(contents, c, &r, &to, &tm, options) + } + + if from.InlineButane != nil { + c := path.New("yaml", "inline_butane") + + translateButaneResource([]byte(*from.InlineButane), c, &r, &to, &tm, options) } + return } -func translateDirectory(from Directory, options common.TranslateOptions) (to types.Directory, tm translate.TranslationSet, r report.Report) { +func TranslateDirectory(from Directory, options common.TranslateOptions) (to types.Directory, tm translate.TranslationSet, r report.Report) { tr := translate.NewTranslator("yaml", "json", options) tm, r = translate.Prefixed(tr, "group", &from.Group, &to.Group) translate.MergeP(tr, tm, &r, "user", &from.User, &to.User) @@ -199,7 +197,7 @@ func translateDirectory(from Directory, options common.TranslateOptions) (to typ return } -func translateLink(from Link, options common.TranslateOptions) (to types.Link, tm translate.TranslationSet, r report.Report) { +func TranslateLink(from Link, options common.TranslateOptions) (to types.Link, tm translate.TranslationSet, r report.Report) { tr := translate.NewTranslator("yaml", "json", options) tm, r = translate.Prefixed(tr, "group", &from.Group, &to.Group) translate.MergeP(tr, tm, &r, "user", &from.User, &to.User) @@ -210,7 +208,7 @@ func translateLink(from Link, options common.TranslateOptions) (to types.Link, t return } -func translatePasswdUser(from PasswdUser, options common.TranslateOptions) (to types.PasswdUser, tm translate.TranslationSet, r report.Report) { +func TranslatePasswdUser(from PasswdUser, options common.TranslateOptions) (to types.PasswdUser, tm translate.TranslationSet, r report.Report) { tr := translate.NewTranslator("yaml", "json", options) tm, r = translate.Prefixed(tr, "gecos", &from.Gecos, &to.Gecos) translate.MergeP(tr, tm, &r, "groups", &from.Groups, &to.Groups) @@ -255,9 +253,9 @@ func translatePasswdUser(from PasswdUser, options common.TranslateOptions) (to t return } -func translateUnit(from Unit, options common.TranslateOptions) (to types.Unit, tm translate.TranslationSet, r report.Report) { +func TranslateUnit(from Unit, options common.TranslateOptions) (to types.Unit, tm translate.TranslationSet, r report.Report) { tr := translate.NewTranslator("yaml", "json", options) - tr.AddCustomTranslator(translateDropin) + tr.AddCustomTranslator(TranslateDropin) tm, r = translate.Prefixed(tr, "contents", &from.Contents, &to.Contents) translate.MergeP(tr, tm, &r, "dropins", &from.Dropins, &to.Dropins) translate.MergeP(tr, tm, &r, "enabled", &from.Enabled, &to.Enabled) @@ -278,7 +276,7 @@ func translateUnit(from Unit, options common.TranslateOptions) (to types.Unit, t return } -func translateDropin(from Dropin, options common.TranslateOptions) (to types.Dropin, tm translate.TranslationSet, r report.Report) { +func TranslateDropin(from Dropin, options common.TranslateOptions) (to types.Dropin, tm translate.TranslationSet, r report.Report) { tr := translate.NewTranslator("yaml", "json", options) tm, r = translate.Prefixed(tr, "contents", &from.Contents, &to.Contents) translate.MergeP(tr, tm, &r, "name", &from.Name, &to.Name) @@ -509,3 +507,41 @@ func mountUnitFromFS(fs Filesystem, remote bool) types.Unit { Contents: util.StrToPtr(contents.String()), } } + +func contentToURL(contents []byte, c path.ContextPath, r *report.Report, to *types.Resource, tm *translate.TranslationSet, options common.TranslateOptions) { + src, compression, err := baseutil.MakeDataURL(contents, to.Compression, !options.NoResourceAutoCompression) + if err != nil { + r.AddOnError(c, err) + return + } + to.Source = &src + tm.AddTranslation(c, path.New("json", "source")) + if compression != nil { + to.Compression = compression + tm.AddTranslation(c, path.New("json", "compression")) + } +} + +func translateButaneResource(butaneContents []byte, c path.ContextPath, r *report.Report, to *types.Resource, tm *translate.TranslationSet, options common.TranslateOptions) { + contents, rp, err := common.TranslateBytes(butaneContents, common.TranslateBytesOptions{ + Pretty: false, + Raw: true, + TranslateOptions: options, + }) + r.Merge(rp) + if err != nil { + return + } + + // Validating the contents of the local file from here since there is no way to + // get both the filename and filedirectory in the Validate context + if strings.HasPrefix(c.String(), "$.ignition.config") { + rp, err := ValidateIgnitionConfig(c, contents) + r.Merge(rp) + if err != nil { + return + } + } + + contentToURL(contents, c, r, to, tm, options) +} diff --git a/config/common/translate.go b/config/common/translate.go new file mode 100644 index 00000000..544a3898 --- /dev/null +++ b/config/common/translate.go @@ -0,0 +1,74 @@ +package common + +import ( + "fmt" + "github.com/coreos/go-semver/semver" + "github.com/coreos/vcontext/report" + "gopkg.in/yaml.v3" +) + +var ( + registry = map[string]translator{} +) + +// Fields that must be included in the root struct of every spec version. +type commonFields struct { + Version string `yaml:"version"` + Variant string `yaml:"variant"` +} + +// RegisterTranslator registers a translator for the specified variant and +// version to be available for use by TranslateBytes. This is only needed +// by users implementing their own translators outside the Butane package. +func RegisterTranslator(variant, version string, trans translator) { + key := fmt.Sprintf("%s+%s", variant, version) + if _, ok := registry[key]; ok { + panic("tried to reregister existing translator") + } + registry[key] = trans +} + +func getTranslator(variant string, version semver.Version) (translator, error) { + t, ok := registry[fmt.Sprintf("%s+%s", variant, version.String())] + if !ok { + return nil, ErrUnknownVersion{ + Variant: variant, + Version: version, + } + } + return t, nil +} + +// translators take a raw config and translate it to a raw Ignition config. The report returned should include any +// errors, warnings, etc. and may or may not be fatal. If report is fatal, or other errors are encountered while translating +// translators should return an error. +type translator func([]byte, TranslateBytesOptions) ([]byte, report.Report, error) + +// TranslateBytes wraps all of the individual TranslateBytes functions in a switch that determines the correct one to call. +// TranslateBytes returns an error if the report had fatal errors or if other errors occured during translation. +func TranslateBytes(input []byte, options TranslateBytesOptions) ([]byte, report.Report, error) { + // first determine version; this will ignore most fields + ver := commonFields{} + if err := yaml.Unmarshal(input, &ver); err != nil { + return nil, report.Report{}, ErrUnmarshal{ + Detail: err.Error(), + } + } + + if ver.Variant == "" { + return nil, report.Report{}, ErrNoVariant + } + + tmp, err := semver.NewVersion(ver.Version) + if err != nil { + return nil, report.Report{}, ErrInvalidVersion + } + version := *tmp + + translator, err := getTranslator(ver.Variant, version) + if err != nil { + return nil, report.Report{}, err + } + + return translator(input, options) +} diff --git a/config/config.go b/config/config.go index ac69167d..0463f290 100644 --- a/config/config.go +++ b/config/config.go @@ -15,8 +15,6 @@ package config import ( - "fmt" - "github.com/coreos/butane/config/common" fcos1_0 "github.com/coreos/butane/config/fcos/v1_0" fcos1_1 "github.com/coreos/butane/config/fcos/v1_1" @@ -48,108 +46,40 @@ import ( r4e1_1 "github.com/coreos/butane/config/r4e/v1_1" r4e1_2_exp "github.com/coreos/butane/config/r4e/v1_2_exp" - "github.com/coreos/go-semver/semver" "github.com/coreos/vcontext/report" - "gopkg.in/yaml.v3" -) - -var ( - registry = map[string]translator{} ) -// Fields that must be included in the root struct of every spec version. -type commonFields struct { - Version string `yaml:"version"` - Variant string `yaml:"variant"` -} - func init() { - RegisterTranslator("fcos", "1.0.0", fcos1_0.ToIgn3_0Bytes) - RegisterTranslator("fcos", "1.1.0", fcos1_1.ToIgn3_1Bytes) - RegisterTranslator("fcos", "1.2.0", fcos1_2.ToIgn3_2Bytes) - RegisterTranslator("fcos", "1.3.0", fcos1_3.ToIgn3_2Bytes) - RegisterTranslator("fcos", "1.4.0", fcos1_4.ToIgn3_3Bytes) - RegisterTranslator("fcos", "1.5.0", fcos1_5.ToIgn3_4Bytes) - RegisterTranslator("fcos", "1.6.0", fcos1_6.ToIgn3_5Bytes) - RegisterTranslator("fcos", "1.7.0-experimental", fcos1_7_exp.ToIgn3_6Bytes) - RegisterTranslator("flatcar", "1.0.0", flatcar1_0.ToIgn3_3Bytes) - RegisterTranslator("flatcar", "1.1.0", flatcar1_1.ToIgn3_4Bytes) - RegisterTranslator("flatcar", "1.2.0-experimental", flatcar1_2_exp.ToIgn3_6Bytes) - RegisterTranslator("openshift", "4.8.0", openshift4_8.ToConfigBytes) - RegisterTranslator("openshift", "4.9.0", openshift4_9.ToConfigBytes) - RegisterTranslator("openshift", "4.10.0", openshift4_10.ToConfigBytes) - RegisterTranslator("openshift", "4.11.0", openshift4_11.ToConfigBytes) - RegisterTranslator("openshift", "4.12.0", openshift4_12.ToConfigBytes) - RegisterTranslator("openshift", "4.13.0", openshift4_13.ToConfigBytes) - RegisterTranslator("openshift", "4.14.0", openshift4_14.ToConfigBytes) - RegisterTranslator("openshift", "4.15.0", openshift4_15.ToConfigBytes) - RegisterTranslator("openshift", "4.16.0", openshift4_16.ToConfigBytes) - RegisterTranslator("openshift", "4.17.0", openshift4_17.ToConfigBytes) - RegisterTranslator("openshift", "4.18.0", openshift4_18.ToConfigBytes) - RegisterTranslator("openshift", "4.19.0", openshift4_19.ToConfigBytes) - RegisterTranslator("openshift", "4.20.0-experimental", openshift4_20_exp.ToConfigBytes) - RegisterTranslator("r4e", "1.0.0", r4e1_0.ToIgn3_3Bytes) - RegisterTranslator("r4e", "1.1.0", r4e1_1.ToIgn3_4Bytes) - RegisterTranslator("r4e", "1.2.0-experimental", r4e1_2_exp.ToIgn3_6Bytes) - RegisterTranslator("fiot", "1.0.0", fiot1_0.ToIgn3_4Bytes) - RegisterTranslator("fiot", "1.1.0-experimental", fiot1_1_exp.ToIgn3_6Bytes) - RegisterTranslator("rhcos", "0.1.0", unsupportedRhcosVariant) -} - -// RegisterTranslator registers a translator for the specified variant and -// version to be available for use by TranslateBytes. This is only needed -// by users implementing their own translators outside the Butane package. -func RegisterTranslator(variant, version string, trans translator) { - key := fmt.Sprintf("%s+%s", variant, version) - if _, ok := registry[key]; ok { - panic("tried to reregister existing translator") - } - registry[key] = trans -} - -func getTranslator(variant string, version semver.Version) (translator, error) { - t, ok := registry[fmt.Sprintf("%s+%s", variant, version.String())] - if !ok { - return nil, common.ErrUnknownVersion{ - Variant: variant, - Version: version, - } - } - return t, nil -} - -// translators take a raw config and translate it to a raw Ignition config. The report returned should include any -// errors, warnings, etc. and may or may not be fatal. If report is fatal, or other errors are encountered while translating -// translators should return an error. -type translator func([]byte, common.TranslateBytesOptions) ([]byte, report.Report, error) - -// TranslateBytes wraps all of the individual TranslateBytes functions in a switch that determines the correct one to call. -// TranslateBytes returns an error if the report had fatal errors or if other errors occured during translation. -func TranslateBytes(input []byte, options common.TranslateBytesOptions) ([]byte, report.Report, error) { - // first determine version; this will ignore most fields - ver := commonFields{} - if err := yaml.Unmarshal(input, &ver); err != nil { - return nil, report.Report{}, common.ErrUnmarshal{ - Detail: err.Error(), - } - } - - if ver.Variant == "" { - return nil, report.Report{}, common.ErrNoVariant - } - - tmp, err := semver.NewVersion(ver.Version) - if err != nil { - return nil, report.Report{}, common.ErrInvalidVersion - } - version := *tmp - - translator, err := getTranslator(ver.Variant, version) - if err != nil { - return nil, report.Report{}, err - } - - return translator(input, options) + common.RegisterTranslator("fcos", "1.0.0", fcos1_0.ToIgn3_0Bytes) + common.RegisterTranslator("fcos", "1.1.0", fcos1_1.ToIgn3_1Bytes) + common.RegisterTranslator("fcos", "1.2.0", fcos1_2.ToIgn3_2Bytes) + common.RegisterTranslator("fcos", "1.3.0", fcos1_3.ToIgn3_2Bytes) + common.RegisterTranslator("fcos", "1.4.0", fcos1_4.ToIgn3_3Bytes) + common.RegisterTranslator("fcos", "1.5.0", fcos1_5.ToIgn3_4Bytes) + common.RegisterTranslator("fcos", "1.6.0", fcos1_6.ToIgn3_5Bytes) + common.RegisterTranslator("fcos", "1.7.0-experimental", fcos1_7_exp.ToIgn3_6Bytes) + common.RegisterTranslator("flatcar", "1.0.0", flatcar1_0.ToIgn3_3Bytes) + common.RegisterTranslator("flatcar", "1.1.0", flatcar1_1.ToIgn3_4Bytes) + common.RegisterTranslator("flatcar", "1.2.0-experimental", flatcar1_2_exp.ToIgn3_6Bytes) + common.RegisterTranslator("openshift", "4.8.0", openshift4_8.ToConfigBytes) + common.RegisterTranslator("openshift", "4.9.0", openshift4_9.ToConfigBytes) + common.RegisterTranslator("openshift", "4.10.0", openshift4_10.ToConfigBytes) + common.RegisterTranslator("openshift", "4.11.0", openshift4_11.ToConfigBytes) + common.RegisterTranslator("openshift", "4.12.0", openshift4_12.ToConfigBytes) + common.RegisterTranslator("openshift", "4.13.0", openshift4_13.ToConfigBytes) + common.RegisterTranslator("openshift", "4.14.0", openshift4_14.ToConfigBytes) + common.RegisterTranslator("openshift", "4.15.0", openshift4_15.ToConfigBytes) + common.RegisterTranslator("openshift", "4.16.0", openshift4_16.ToConfigBytes) + common.RegisterTranslator("openshift", "4.17.0", openshift4_17.ToConfigBytes) + common.RegisterTranslator("openshift", "4.18.0", openshift4_18.ToConfigBytes) + common.RegisterTranslator("openshift", "4.19.0", openshift4_19.ToConfigBytes) + common.RegisterTranslator("openshift", "4.20.0-experimental", openshift4_20_exp.ToConfigBytes) + common.RegisterTranslator("r4e", "1.0.0", r4e1_0.ToIgn3_3Bytes) + common.RegisterTranslator("r4e", "1.1.0", r4e1_1.ToIgn3_4Bytes) + common.RegisterTranslator("r4e", "1.2.0-experimental", r4e1_2_exp.ToIgn3_6Bytes) + common.RegisterTranslator("fiot", "1.0.0", fiot1_0.ToIgn3_4Bytes) + common.RegisterTranslator("fiot", "1.1.0-experimental", fiot1_1_exp.ToIgn3_6Bytes) + common.RegisterTranslator("rhcos", "0.1.0", unsupportedRhcosVariant) } func unsupportedRhcosVariant(input []byte, options common.TranslateBytesOptions) ([]byte, report.Report, error) { diff --git a/docs/config-fcos-v1_7-exp.md b/docs/config-fcos-v1_7-exp.md index de740ada..4e1412d4 100644 --- a/docs/config-fcos-v1_7-exp.md +++ b/docs/config-fcos-v1_7-exp.md @@ -22,6 +22,8 @@ The Fedora CoreOS configuration is a YAML document conforming to the following s * **_source_** (string): the URL of the config. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the config. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the config. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the config (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -32,6 +34,8 @@ The Fedora CoreOS configuration is a YAML document conforming to the following s * **_source_** (string): the URL of the config. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the config. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the config. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the config (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -47,6 +51,8 @@ The Fedora CoreOS configuration is a YAML document conforming to the following s * **_source_** (string): the URL of the certificate bundle (in PEM format). The bundle can contain multiple concatenated certificates. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the certificate bundle (in PEM format). The bundle can contain multiple concatenated certificates. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the certificate bundle (in PEM format), relative to the directory specified by the `--files-dir` command-line argument. The bundle can contain multiple concatenated certificates. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the certificate bundle. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the certificate bundle, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the certificate bundle (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -94,6 +100,8 @@ The Fedora CoreOS configuration is a YAML document conforming to the following s * **_source_** (string): the URL of the file. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. If source is omitted and a regular file already exists at the path, Ignition will do nothing. If source is omitted and no file exists, an empty file will be created. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the file. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the file. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the file (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -104,6 +112,8 @@ The Fedora CoreOS configuration is a YAML document conforming to the following s * **_source_** (string): the URL of the fragment. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the fragment. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the fragment, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the fragment. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the fragment, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the fragment (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -145,6 +155,8 @@ The Fedora CoreOS configuration is a YAML document conforming to the following s * **_source_** (string): the URL of the key file. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the key file. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the key file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the key file. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the key file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the key file (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. diff --git a/docs/config-fiot-v1_1-exp.md b/docs/config-fiot-v1_1-exp.md index 3e8c33fb..b9741188 100644 --- a/docs/config-fiot-v1_1-exp.md +++ b/docs/config-fiot-v1_1-exp.md @@ -22,6 +22,8 @@ The Fedora IoT configuration is a YAML document conforming to the following spec * **_source_** (string): the URL of the config. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the config. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the config. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the config (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -32,6 +34,8 @@ The Fedora IoT configuration is a YAML document conforming to the following spec * **_source_** (string): the URL of the config. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the config. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the config. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the config (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -47,6 +51,8 @@ The Fedora IoT configuration is a YAML document conforming to the following spec * **_source_** (string): the URL of the certificate bundle (in PEM format). The bundle can contain multiple concatenated certificates. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the certificate bundle (in PEM format). The bundle can contain multiple concatenated certificates. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the certificate bundle (in PEM format), relative to the directory specified by the `--files-dir` command-line argument. The bundle can contain multiple concatenated certificates. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the certificate bundle. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the certificate bundle, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the certificate bundle (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -65,6 +71,8 @@ The Fedora IoT configuration is a YAML document conforming to the following spec * **_source_** (string): the URL of the file. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. If source is omitted and a regular file already exists at the path, Ignition will do nothing. If source is omitted and no file exists, an empty file will be created. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the file. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the file. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the file (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -75,6 +83,8 @@ The Fedora IoT configuration is a YAML document conforming to the following spec * **_source_** (string): the URL of the fragment. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the fragment. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the fragment, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the fragment. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the fragment, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the fragment (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. diff --git a/docs/config-flatcar-v1_2-exp.md b/docs/config-flatcar-v1_2-exp.md index 806556b4..0d3d6e6b 100644 --- a/docs/config-flatcar-v1_2-exp.md +++ b/docs/config-flatcar-v1_2-exp.md @@ -22,6 +22,8 @@ The Flatcar configuration is a YAML document conforming to the following specifi * **_source_** (string): the URL of the config. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the config. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the config. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the config (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -32,6 +34,8 @@ The Flatcar configuration is a YAML document conforming to the following specifi * **_source_** (string): the URL of the config. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the config. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the config. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the config (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -47,6 +51,8 @@ The Flatcar configuration is a YAML document conforming to the following specifi * **_source_** (string): the URL of the certificate bundle (in PEM format). The bundle can contain multiple concatenated certificates. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the certificate bundle (in PEM format). The bundle can contain multiple concatenated certificates. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the certificate bundle (in PEM format), relative to the directory specified by the `--files-dir` command-line argument. The bundle can contain multiple concatenated certificates. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the certificate bundle. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the certificate bundle, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the certificate bundle (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -94,6 +100,8 @@ The Flatcar configuration is a YAML document conforming to the following specifi * **_source_** (string): the URL of the file. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. If source is omitted and a regular file already exists at the path, Ignition will do nothing. If source is omitted and no file exists, an empty file will be created. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the file. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the file. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the file (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -104,6 +112,8 @@ The Flatcar configuration is a YAML document conforming to the following specifi * **_source_** (string): the URL of the fragment. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the fragment. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the fragment, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the fragment. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the fragment, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the fragment (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -145,6 +155,8 @@ The Flatcar configuration is a YAML document conforming to the following specifi * **_source_** (string): the URL of the key file. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the key file. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the key file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the key file. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the key file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the key file (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. diff --git a/docs/config-openshift-v4_20-exp.md b/docs/config-openshift-v4_20-exp.md index c3c91fd9..f58b8935 100644 --- a/docs/config-openshift-v4_20-exp.md +++ b/docs/config-openshift-v4_20-exp.md @@ -25,6 +25,8 @@ The OpenShift configuration is a YAML document conforming to the following speci * **_source_** (string): the URL of the config. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the config. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the config. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the config (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -35,6 +37,8 @@ The OpenShift configuration is a YAML document conforming to the following speci * **_source_** (string): the URL of the config. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the config. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the config. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the config (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -50,6 +54,8 @@ The OpenShift configuration is a YAML document conforming to the following speci * **_source_** (string): the URL of the certificate bundle (in PEM format). The bundle can contain multiple concatenated certificates. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the certificate bundle (in PEM format). The bundle can contain multiple concatenated certificates. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the certificate bundle (in PEM format), relative to the directory specified by the `--files-dir` command-line argument. The bundle can contain multiple concatenated certificates. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the certificate bundle. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the certificate bundle, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the certificate bundle (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -97,6 +103,8 @@ The OpenShift configuration is a YAML document conforming to the following speci * **_source_** (string): the URL of the file. Only the [`data`](https://tools.ietf.org/html/rfc2397) scheme is supported. If source is omitted and a regular file already exists at the path, Ignition will do nothing. If source is omitted and no file exists, an empty file will be created. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the file. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the file. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the file (null or gzip). Compression cannot be used with S3. * **_verification_** (object): options related to the verification of the file. * **_hash_** (string): the hash of the file, in the form `-` where type is either `sha512` or `sha256`. If `compression` is specified, the hash describes the decompressed file. @@ -114,6 +122,8 @@ The OpenShift configuration is a YAML document conforming to the following speci * **_source_** (string): the URL of the key file. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the key file. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the key file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the key file. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the key file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the key file (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. diff --git a/docs/config-r4e-v1_2-exp.md b/docs/config-r4e-v1_2-exp.md index 9f309af0..72f95ce8 100644 --- a/docs/config-r4e-v1_2-exp.md +++ b/docs/config-r4e-v1_2-exp.md @@ -22,6 +22,8 @@ The RHEL for Edge configuration is a YAML document conforming to the following s * **_source_** (string): the URL of the config. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the config. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the config. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the config (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -32,6 +34,8 @@ The RHEL for Edge configuration is a YAML document conforming to the following s * **_source_** (string): the URL of the config. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the config. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the config. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the config, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the config (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -47,6 +51,8 @@ The RHEL for Edge configuration is a YAML document conforming to the following s * **_source_** (string): the URL of the certificate bundle (in PEM format). The bundle can contain multiple concatenated certificates. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the certificate bundle (in PEM format). The bundle can contain multiple concatenated certificates. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the certificate bundle (in PEM format), relative to the directory specified by the `--files-dir` command-line argument. The bundle can contain multiple concatenated certificates. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the certificate bundle. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the certificate bundle, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the certificate bundle (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -65,6 +71,8 @@ The RHEL for Edge configuration is a YAML document conforming to the following s * **_source_** (string): the URL of the file. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. If source is omitted and a regular file already exists at the path, Ignition will do nothing. If source is omitted and no file exists, an empty file will be created. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the file. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the file. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the file, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the file (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. @@ -75,6 +83,8 @@ The RHEL for Edge configuration is a YAML document conforming to the following s * **_source_** (string): the URL of the fragment. Supported schemes are `http`, `https`, `tftp`, `s3`, `arn`, `gs`, and [`data`](https://tools.ietf.org/html/rfc2397). When using `http`, it is advisable to use the verification option to ensure the contents haven't been modified. Mutually exclusive with `inline` and `local`. * **_inline_** (string): the contents of the fragment. Mutually exclusive with `source` and `local`. * **_local_** (string): a local path to the contents of the fragment, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. + * **_inline_butane_** (string): the contents of the fragment. Mutually exclusive with `source` and `local`. + * **_local_butane_** (string): a local path to the contents of the fragment, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`. * **_compression_** (string): the type of compression used on the fragment (null or gzip). Compression cannot be used with S3. * **_http_headers_** (list of objects): a list of HTTP headers to be added to the request. Available for `http` and `https` source schemes only. * **name** (string): the header name. diff --git a/docs/release-notes.md b/docs/release-notes.md index bcc95ad3..d9607936 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -8,6 +8,8 @@ nav_order: 9 ### Features +- Add support for loading `inline` and `local` butane files, these are automatically translated to `ignition`. + ### Bug fixes ### Misc. changes diff --git a/internal/doc/butane.yaml b/internal/doc/butane.yaml index a313d977..570b7846 100644 --- a/internal/doc/butane.yaml +++ b/internal/doc/butane.yaml @@ -27,6 +27,19 @@ resource: - name: local after: source desc: "a local path to the contents of the %TYPE%, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`." + ## TODO: check & fix + - name: inline_butane + after: source + desc: "the contents of the %TYPE%. Mutually exclusive with `source` and `local`." + transforms: + - regex: " and `local`" + replacement: "" + if: + - variant: fcos + max: 1.0.0 + - name: local_butane + after: source + desc: "a local path to the contents of the %TYPE%, relative to the directory specified by the `--files-dir` command-line argument. Mutually exclusive with `source` and `inline`." mode: # File mode transforms. diff --git a/internal/doc/main.go b/internal/doc/main.go index 98544afc..0ae9f8a2 100644 --- a/internal/doc/main.go +++ b/internal/doc/main.go @@ -30,7 +30,7 @@ import ( "github.com/coreos/ignition/v2/config/util" "gopkg.in/yaml.v3" - "github.com/coreos/butane/config" + _ "github.com/coreos/butane/config" "github.com/coreos/butane/config/common" buUtil "github.com/coreos/butane/config/util" @@ -298,7 +298,7 @@ func getIgnitionVersion(variant string, version semver.Version) (semver.Version, } // translate to Ignition config - ign, _, err := config.TranslateBytes(bu, common.TranslateBytesOptions{ + ign, _, err := common.TranslateBytes(bu, common.TranslateBytesOptions{ Raw: true, }) if err != nil { diff --git a/internal/main.go b/internal/main.go index d55eeae1..07221d2e 100644 --- a/internal/main.go +++ b/internal/main.go @@ -21,7 +21,7 @@ import ( "github.com/spf13/pflag" - "github.com/coreos/butane/config" + _ "github.com/coreos/butane/config" "github.com/coreos/butane/config/common" "github.com/coreos/butane/internal/version" ) @@ -96,7 +96,7 @@ func main() { fail("failed to read %s: %v\n", infile.Name(), err) } - dataOut, r, err := config.TranslateBytes(dataIn, options) + dataOut, r, err := common.TranslateBytes(dataIn, options) fmt.Fprintf(os.Stderr, "%s", r.String()) if err != nil { fail("Error translating config: %v\n", err)