Skip to content
This repository was archived by the owner on Sep 18, 2020. It is now read-only.

Commit 5326376

Browse files
committed
Support for Compressed, Base64-Enc, Inline Content
This patch adds support for local, inline content as compressed, base64 encoded values. For example, the string "Hello, world." can be compressed with gzip and base64 encoded with the following command: $ echo Hello, world. | gzip | base64 H4sIAG/kFlsAA/NIzcnJ11Eozy/KSdHjAgDXu838DgAAAA== A Container Linux Config could use the above contents and write them to the file "/etc/helloworld.txt": storage: files: - path: /etc/helloworld.txt filesystem: root mode: 0644 contents: compression: gzip inline: !binary | H4sIAB/jFlsAA/NIzcnJ11Eozy/KSdHjAgDXu838DgAAAA== The CT transpiler would transform the above configuration snippet into the JSON below: { "filesystem": "root", "path": "/etc/helloworld.txt", "contents": { "compression": "gzip", "source": "data:,H4sIAB%2FjFlsAA%2FNIzcnJ11Eozy%2FKSdHjAgDXu838DgAAAA%3D%3D", "verification": {} }, "mode": 420 }, The following command may be used to verify the URL encoded data matches the original "Hello, world." string: $ echo H4sIAB%2FjFlsAA%2FNIzcnJ11Eozy%2FKSdHjAgDXu838DgAAAA%3D%3D | \ perl -pe 's/\%(\w\w)/chr hex $1/ge' | \ base64 -D | \ gzip -d Hello, world.
1 parent 5b24575 commit 5326376

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

config/types/files.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ type File struct {
6363
}
6464

6565
type FileContents struct {
66-
Remote Remote `yaml:"remote"`
67-
Inline string `yaml:"inline"`
68-
Local string `yaml:"local"`
66+
Compression string `yaml:"compression"`
67+
Remote Remote `yaml:"remote"`
68+
Inline string `yaml:"inline"`
69+
Local string `yaml:"local"`
6970
}
7071

7172
type Remote struct {
7273
Url string `yaml:"url"`
73-
Compression string `yaml:"compression"`
7474
Verification Verification `yaml:"verification"`
7575
}
7676

@@ -237,7 +237,7 @@ func init() {
237237
}
238238
}
239239

240-
newFile.Contents.Compression = file.Contents.Remote.Compression
240+
newFile.Contents.Compression = file.Contents.Compression
241241
newFile.Contents.Verification = convertVerification(file.Contents.Remote.Verification)
242242

243243
out.Storage.Files = append(out.Storage.Files, newFile)

doc/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ _Note: all fields are optional unless otherwise marked_
6363
* **overwrite** (boolean): whether to delete preexisting nodes at the path. Defaults to true.
6464
* **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.
6565
* **contents** (object): options related to the contents of the file.
66+
* **compression** (string): the type of compression used on the contents (null or gzip)
6667
* **inline** (string): the contents of the file.
6768
* **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.
6869
* **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.
69-
* **compression** (string): the type of compression used on the contents (null or gzip)
7070
* **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.
7171
* **verification** (object): options related to the verification of the file contents.
7272
* **hash** (object): the hash of the config

0 commit comments

Comments
 (0)