diff --git a/config/config_test.go b/config/config_test.go index 7b6938e..d27e85a 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -295,9 +295,9 @@ storage: - path: /opt/file2 filesystem: filesystem1 contents: + compression: gzip remote: url: http://example.com/file2 - compression: gzip verification: hash: function: sha512 @@ -311,9 +311,9 @@ storage: - path: /opt/file3 filesystem: filesystem2 contents: + compression: gzip remote: url: http://example.com/file3 - compression: gzip mode: 0400 user: id: 1000 @@ -503,9 +503,9 @@ storage: User: &types.FileUser{Id: util.IntToPtr(502)}, Group: &types.FileGroup{Id: util.IntToPtr(503)}, Contents: types.FileContents{ + Compression: "gzip", Remote: types.Remote{ - Url: "http://example.com/file2", - Compression: "gzip", + Url: "http://example.com/file2", Verification: types.Verification{ Hash: types.Hash{ Function: "sha512", @@ -523,9 +523,9 @@ storage: User: &types.FileUser{Id: util.IntToPtr(1000)}, Group: &types.FileGroup{Id: util.IntToPtr(1001)}, Contents: types.FileContents{ + Compression: "gzip", Remote: types.Remote{ - Url: "http://example.com/file3", - Compression: "gzip", + Url: "http://example.com/file3", }, }, Mode: util.IntToPtr(0400), @@ -1197,9 +1197,9 @@ func TestConvert(t *testing.T) { User: &types.FileUser{Id: util.IntToPtr(502)}, Group: &types.FileGroup{Id: util.IntToPtr(503)}, Contents: types.FileContents{ + Compression: "gzip", Remote: types.Remote{ - Url: "http://example.com/file2", - Compression: "gzip", + Url: "http://example.com/file2", Verification: types.Verification{ Hash: types.Hash{ Function: "sha512", @@ -1217,9 +1217,9 @@ func TestConvert(t *testing.T) { User: &types.FileUser{Id: util.IntToPtr(1000)}, Group: &types.FileGroup{Id: util.IntToPtr(1001)}, Contents: types.FileContents{ + Compression: "gzip", Remote: types.Remote{ - Url: "http://example.com/file3", - Compression: "gzip", + Url: "http://example.com/file3", }, }, Mode: util.IntToPtr(0400), @@ -1424,12 +1424,12 @@ func TestConvert(t *testing.T) { }, FileEmbedded1: ignTypes.FileEmbedded1{ Contents: ignTypes.FileContents{ + Compression: "gzip", Source: (&url.URL{ Scheme: "http", Host: "example.com", Path: "/file2", }).String(), - Compression: "gzip", Verification: ignTypes.Verification{ Hash: util.StringToPtr("sha512-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), }, @@ -1930,9 +1930,9 @@ storage: - path: /opt/file2 filesystem: root contents: + compression: gzip remote: url: httpz://example.com/file2 - compression: gzip verification: hash: function: sha512 @@ -1955,7 +1955,7 @@ storage: { Message: "invalid url scheme", Kind: report.EntryError, - Line: 17, + Line: 18, Column: 16, }, }}, @@ -2017,9 +2017,9 @@ storage: - path: /opt/file2 filesystem: root contents: + compression: gzip remote: url: http://example.com/file2 - compression: gzip verification: hash: function: sha512 @@ -2060,12 +2060,12 @@ storage: }, FileEmbedded1: ignTypes.FileEmbedded1{ Contents: ignTypes.FileContents{ + Compression: "gzip", Source: (&url.URL{ Scheme: "http", Host: "example.com", Path: "/file2", }).String(), - Compression: "gzip", Verification: ignTypes.Verification{ Hash: util.StringToPtr("sha512-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), }, diff --git a/config/types/files.go b/config/types/files.go index f335667..41b39bd 100644 --- a/config/types/files.go +++ b/config/types/files.go @@ -63,14 +63,14 @@ type File struct { } type FileContents struct { - Remote Remote `yaml:"remote"` - Inline string `yaml:"inline"` - Local string `yaml:"local"` + Compression string `yaml:"compression"` + Remote Remote `yaml:"remote"` + Inline string `yaml:"inline"` + Local string `yaml:"local"` } type Remote struct { Url string `yaml:"url"` - Compression string `yaml:"compression"` Verification Verification `yaml:"verification"` } @@ -237,7 +237,7 @@ func init() { } } - newFile.Contents.Compression = file.Contents.Remote.Compression + newFile.Contents.Compression = file.Contents.Compression newFile.Contents.Verification = convertVerification(file.Contents.Remote.Verification) out.Storage.Files = append(out.Storage.Files, newFile) diff --git a/doc/configuration.md b/doc/configuration.md index e4fe566..f66ff6b 100644 --- a/doc/configuration.md +++ b/doc/configuration.md @@ -63,10 +63,10 @@ _Note: all fields are optional unless otherwise marked_ * **overwrite** (boolean): whether to delete preexisting nodes at the path. Defaults to true. * **append** (boolean): whether to append to the specified file. Creates a new file if nothing exists at the path. Cannot be set if overwrite is set to true. * **contents** (object): options related to the contents of the file. + * **compression** (string): the type of compression used on the contents (null or gzip) * **inline** (string): the contents of the file. * **local** (string): the path to a local file, relative to the `--files-dir` directory. When using local files, the `--files-dir` flag must be passed to `ct`. The file contents are included in the generated config. * **remote** (object): options related to the fetching of remote file contents. Remote files are fetched by Ignition when Ignition runs, the contents are not included in the generated config. - * **compression** (string): the type of compression used on the contents (null or gzip) * **url** (string): the URL of the file contents. Supported schemes are http, https, tftp, s3, and [data][rfc2397]. Note: When using http, it is advisable to use the verification option to ensure the contents haven't been modified. * **verification** (object): options related to the verification of the file contents. * **hash** (object): the hash of the config diff --git a/doc/examples.md b/doc/examples.md index 42e587b..51d9615 100644 --- a/doc/examples.md +++ b/doc/examples.md @@ -93,9 +93,9 @@ storage: - path: /opt/file2 filesystem: root contents: + compression: gzip remote: url: http://example.com/file2 - compression: gzip verification: hash: function: sha512