You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e77ee37
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,6 +150,43 @@ Here is an example of an `input.json` file with responses:
150
150
151
151
The `input.json` file is converted and merged into the main `def.json` during the build, using the `input` build step.
152
152
153
+
### Render module input as an augments file
154
+
155
+
```
156
+
cfbs render-input <module> <infile (or - for stdin)> <outfile (or - for stdout)>
157
+
```
158
+
159
+
Converts input data for a module, as shown above, into the augments (`def.json`) format, and writes it to the outfile.
160
+
This is the same conversion the `input` build step performs during `cfbs build`, except that the input data is read from the infile instead of `<module-name>/input.json`, and nothing is stored in the project.
161
+
162
+
Use it to render an augment for input data which is kept outside of the project, for example input entered per host group in Mission Portal:
163
+
164
+
```
165
+
$ cfbs render-input create-single-file - - <<EOF
166
+
[
167
+
{
168
+
"type": "string",
169
+
"variable": "filename",
170
+
"label": "Filename",
171
+
"question": "What file should this module create?",
172
+
"response": "/tmp/create-single-file.txt"
173
+
}
174
+
]
175
+
EOF
176
+
{
177
+
"variables": {
178
+
"cfbs:create_single_file.filename": {
179
+
"value": "/tmp/create-single-file.txt",
180
+
"comment": "Added by 'cfbs input'"
181
+
}
182
+
}
183
+
}
184
+
```
185
+
186
+
The input data must conform with the module's input definition, just like for `cfbs set-input`.
187
+
A variable is only added to the augment if the input data has a `response` for it.
188
+
Thus, if none of the questions have been answered, the rendered augment contains no variables at all.
189
+
153
190
### Deploy your policy set to a remote hub
154
191
155
192
```
@@ -288,6 +325,9 @@ These commands are intended to be run as part of build systems / deployment pipe
288
325
Empty list `[]` is returned if the module was found, but it does not accept any input.
289
326
-`cfbs install`: Run this on a hub as root to install the policy set (copy the files from `out/masterfiles` to `/var/cfengine/masterfiles`).
290
327
-`cfbs pretty`: Run on a JSON file to pretty-format it. (May be expanded to other formats in the future).
328
+
-`cfbs render-input`: Convert input data for a module into an augments file (`def.json`) and print it.
329
+
Takes the same input data as `cfbs set-input`, validates it the same way, but stores nothing - the augment is written to the given outfile instead.
330
+
Useful for rendering the augment for input data which is not stored in the project, for example input entered per host group in Mission Portal.
291
331
-`cfbs set-input`: Set input data for a module.
292
332
Non-interactive version of `cfbs input`, takes the input as a JSON, validates it and stores it.
293
333
`cfbs set-input` and `cfbs get-input` can be thought of as ways to save and load the input file.
0 commit comments