Registry item format¶
A registry item describes one component: its fields and the files it renders. Built-in components are registry items compiled into kikx-core. A registry-item.json file, local or at a URL, is loaded with the same schema. Schema source: backend/core/src/registry/item.rs.
Reference resolution¶
A component reference is resolved in this order:
Step |
Condition |
Result |
|---|---|---|
1 |
The part after the last |
That built-in component |
2 |
Starts with |
JSON fetched with HTTP |
3 |
Names an existing local file |
JSON read from the file |
4 |
Otherwise |
Error: |
Step 1 applies to URLs and paths too: https://example.com/items/role and ./items/deployment resolve to the built-ins ansible/role and k8s/deployment. The category is not compared: other/deployment resolves to k8s/deployment.
Relative paths are resolved against the working directory of the CLI or backend process.
Failure |
Message |
|---|---|
URL fetch fails |
|
JSON does not match the schema |
|
Item¶
Key |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
string |
yes |
— |
Component name |
|
string |
yes |
— |
Category. The reference is |
|
string |
no |
|
Display title |
|
string |
no |
|
One-line description |
|
array of Field |
no |
|
Declared fields |
|
array of File |
yes |
— |
Files to render, in order |
Field¶
Key |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
string |
yes |
— |
Field name, and template variable name |
|
boolean |
no |
|
Rendering fails when no value is supplied and |
|
string |
no |
absent |
Value used when none is supplied |
|
string |
no |
absent |
Help text |
|
string |
no |
absent |
Example value |
|
array of Option |
no |
|
Suggested values. Not enforced |
Option¶
Key |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
string |
yes |
— |
Option value |
|
string |
no |
|
Display label. The HTTP API returns |
File¶
Key |
Type |
Required |
Description |
|---|---|---|---|
|
string |
yes |
Output path template, relative to the target directory |
|
string |
yes |
File content template |
path and template are rendered with MiniJinja using the template context. A trailing newline in template is kept. An undefined variable renders as an empty string.
Template context¶
Variable |
Type |
Value |
|---|---|---|
|
string |
Component name: |
|
string |
Supplied |
|
map of string to string |
Supplied labels, with |
each declared field except |
string, list or map |
Supplied value, else |
each supplied field not declared |
string, list or map |
Supplied value |
The default namespace is:
Caller |
Default namespace |
|---|---|
|
|
|
|
|
|
A declared field named namespace has no effect: its default is not applied.
A required field with no supplied value and no default fails with --<field> is required for <category>/<name>.
JSON-valued fields¶
Every supplied value and default is a string. A value whose first non-whitespace character is [ or { is parsed as JSON:
Value |
Template receives |
|---|---|
|
list |
|
map, keys iterated in alphabetical order |
|
the original string |
any other value |
the original string |
Path rules¶
Checked when files are written by kikx add, kikx setup and kikx apply. POST /api/render does not write and applies only the duplicate check within one item.
Rule |
Error |
|---|---|
Two files of one item render to the same path |
|
Two files of one run render to the same path ( |
|
Path is absolute |
|
Path, read left to right, climbs above the target directory at any |
|
Target file exists and |
|
All checks run before the first file is written. Parent directories are created as needed.
Example¶
registry-item.json:
{
"name": "configmap",
"category": "k8s",
"title": "ConfigMap",
"description": "Key/value configuration for pods.",
"fields": [
{"name": "data", "required": true, "description": "JSON map of keys and values.", "example": "{\"LOG_LEVEL\": \"info\"}"},
{"name": "immutable", "default": "false", "options": [{"value": "true"}, {"value": "false"}]}
],
"files": [
{
"path": "{{ name }}-configmap.yaml",
"template": "apiVersion: v1\nkind: ConfigMap\nmetadata:\n name: {{ name }}\n namespace: {{ namespace }}\n labels:\n app: {{ labels.app }}\nimmutable: {{ immutable }}\ndata:\n{% for key in data %} {{ key }}: \"{{ data[key] }}\"\n{% endfor %}"
}
]
}
Command:
kikx add ./registry-item.json --name web --set 'data={"LOG_LEVEL":"info","MODE":"prod"}'
Output, web-configmap.yaml:
apiVersion: v1
kind: ConfigMap
metadata:
name: web
namespace: default
labels:
app: web
immutable: false
data:
LOG_LEVEL: "info"
MODE: "prod"