@eighty4/c2 0.0.2-29 → 0.0.2-30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +15 -6
- package/lib/http.ts +2 -2
- package/lib_js/http.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Blow up your `cloud-init` developer workflows!
|
|
4
4
|
|
|
5
|
+
See the [examples dir](https://github.com/eighty4/c2/tree/main/examples) for
|
|
6
|
+
examples running on your local machine or deploying to cloud providers.
|
|
7
|
+
|
|
5
8
|
## Getting started
|
|
6
9
|
|
|
7
10
|
```shell
|
|
@@ -9,7 +12,8 @@ npm i -g @eighty4/c2
|
|
|
9
12
|
c2 -h
|
|
10
13
|
```
|
|
11
14
|
|
|
12
|
-
(tests use `bun:test` so [install Bun](https://bun.sh/docs/installation)
|
|
15
|
+
(tests use `bun:test` so [install Bun](https://bun.sh/docs/installation)
|
|
16
|
+
for contributing!)
|
|
13
17
|
|
|
14
18
|
## Using the CLI program
|
|
15
19
|
|
|
@@ -30,7 +34,8 @@ const userData: string = await buildUserData('./cloud_init_dir')
|
|
|
30
34
|
|
|
31
35
|
## Cloud Config data dir
|
|
32
36
|
|
|
33
|
-
Multiple user data are ordered by filenames and `01_` numbered prefixes help
|
|
37
|
+
Multiple user data are ordered by filenames and `01_` numbered prefixes help
|
|
38
|
+
declare execution order.
|
|
34
39
|
|
|
35
40
|
```
|
|
36
41
|
ls ./cloud_init_dir
|
|
@@ -39,11 +44,13 @@ ls ./cloud_init_dir
|
|
|
39
44
|
03_services.sh
|
|
40
45
|
```
|
|
41
46
|
|
|
42
|
-
Shell scripts are supported as `x-shellscript` and YAML is included as
|
|
47
|
+
Shell scripts are supported as `x-shellscript` and YAML is included as
|
|
48
|
+
`cloud-config` MIME types.
|
|
43
49
|
|
|
44
50
|
## Evaluating expressions in user data
|
|
45
51
|
|
|
46
|
-
Scripts and YAML support two template functions that can be used in
|
|
52
|
+
Scripts and YAML support two template functions that can be used in
|
|
53
|
+
expressions.
|
|
47
54
|
|
|
48
55
|
### env()
|
|
49
56
|
|
|
@@ -57,7 +64,8 @@ ENV_VAR="${{ env('LOCAL_ENV_VAR') }}"
|
|
|
57
64
|
|
|
58
65
|
### file()
|
|
59
66
|
|
|
60
|
-
Looks up a file from your local filesystem and replaces the expression with
|
|
67
|
+
Looks up a file from your local filesystem and replaces the expression with
|
|
68
|
+
its content.
|
|
61
69
|
|
|
62
70
|
```yaml
|
|
63
71
|
#cloud-config
|
|
@@ -72,6 +80,7 @@ Relative, absolute and `~/` paths are supported.
|
|
|
72
80
|
|
|
73
81
|
## Contributing
|
|
74
82
|
|
|
75
|
-
I use `c2` for initializing Debian cloud instances and locally test with QEMU
|
|
83
|
+
I use `c2` for initializing Debian cloud instances and locally test with QEMU
|
|
84
|
+
and Ubuntu.
|
|
76
85
|
|
|
77
86
|
Feedback on your use cases and worfklows is greatly appreciated!
|
package/lib/http.ts
CHANGED
|
@@ -29,8 +29,8 @@ async function sendUserData(res: ServerResponse, userDataDir: string) {
|
|
|
29
29
|
const message = new MultipartMessage(
|
|
30
30
|
await collectAttachments(userDataDir),
|
|
31
31
|
)
|
|
32
|
-
res.writeHead(200
|
|
33
|
-
res.write(message.
|
|
32
|
+
res.writeHead(200)
|
|
33
|
+
res.write(message.toHTTP())
|
|
34
34
|
} catch (e: any) {
|
|
35
35
|
console.error(500, '/user-data', e.message)
|
|
36
36
|
res.writeHead(500)
|
package/lib_js/http.js
CHANGED
|
@@ -25,8 +25,8 @@ export function startUserDataHttp(port, userDataDir) {
|
|
|
25
25
|
async function sendUserData(res, userDataDir) {
|
|
26
26
|
try {
|
|
27
27
|
const message = new MultipartMessage(await collectAttachments(userDataDir));
|
|
28
|
-
res.writeHead(200
|
|
29
|
-
res.write(message.
|
|
28
|
+
res.writeHead(200);
|
|
29
|
+
res.write(message.toHTTP());
|
|
30
30
|
}
|
|
31
31
|
catch (e) {
|
|
32
32
|
console.error(500, '/user-data', e.message);
|