Skip to content

Commit 84e8e6f

Browse files
committed
project: import otk
Automatically import `otk`'s `doc/` subdirectory into the project pages. Signed-off-by: Simon de Vlieger <[email protected]>
1 parent f53773d commit 84e8e6f

File tree

14 files changed

+702
-0
lines changed

14 files changed

+702
-0
lines changed

.github/workflows/pull.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ jobs:
3232
run: |
3333
make pull-osbuild-modules
3434
35+
- name: Pull otk
36+
working-directory: ./osbuild.github.io
37+
run: |
38+
make pull-otk
39+
3540
- name: Setup node
3641
uses: actions/setup-node@v4
3742
with:

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ test: ## test pulling the readmes from the other projects
1616
pull-readmes: ## pull the readmes from other projects given in `readme-list`
1717
python3 scripts/pull_readmes.py readme-list
1818

19+
.PHONY: pull-otk
20+
pull-otk: ## pull the otk documentation
21+
python3 scripts/pull_otk.py
22+
1923
.PHONY: pull-osbuild-modules
2024
pull-osbuild-modules: ## pull the documentation of the osbuild modules
2125
python3 scripts/pull_osbuild_modules.py
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Installation
2+
3+
As `otk` is still in a proof of concept state it is not yet packaged for any distributions. Installation thus requires you to work from [source](https://github.com/osbuild/otk).
4+
5+
To start hacking on `otk` you can:
6+
7+
```
8+
€ git clone https://github.com/osbuild/otk
9+
# ...
10+
€ python3 -m venv venv
11+
# ...
12+
€ . venv/bin/activate
13+
# ...
14+
€ pip install -e ".[dev]"
15+
# ...
16+
€ make external
17+
# ...
18+
€ pre-commit install
19+
# ...
20+
```
21+
22+
This will get you an activated Python virtual environment with an editable install of `otk`. You can then run edit source in `src/` and run `otk` as long as your virtual environment is enabled. When you do a `git commit` some verification steps will run locally on the changed files.
23+
24+
You can read more about [contributing](./01-contributing.md)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Contributing
2+
3+
`otk` is written in Python with a minimal version of `3.9`. It is licensed under the Apache License. To get started with contributing to `otk` [check out the repository and install the dependencies](./00-installation.md). After you've done so familiarize yourself a bit with the layout of the source code.
4+
5+
You can run the test suite with `make test` or `pytest` in your source checkout directory.
6+
7+
## What to do?
8+
9+
You can find open [issues](https://github.com/osbuild/otk/issues) at our [GitHub](https://github.com/osbuild/otk) page.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Usage
2+
3+
After [installing](./00-installation.md) `otk` you'll probably want to start using it. If you've followed the [installation instructions](./00-installation.md) for a source checkout you'll have an examples directory available. You can compile one of the examples like so:
4+
5+
```
6+
€ OTK_EXTERNAL_PATH="./external" otk compile example/centos/centos-9-x86_64-minimal-raw.yaml
7+
# ...
8+
```
9+
10+
Note that this example will take some time to generate, this is due to dependency solving. After the command is done it will output the generated content on `STDOUT`.
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
# Directive
2+
3+
In [omnifests](./index.md) directives are sections of the document that get transformed by `otk` into something else.
4+
5+
`otk` has various directives that can be used in an omnifest. Generally these directives can appear anywhere in the tree unless otherwise specified (see below) and they are replaced with other trees or values as produced by the directive.
6+
7+
There are [example omnifests](https://github.com/osbuild/otk/tree/main/example) for various distributions and images in a [source checkout](../00-installation.md).
8+
9+
## `otk.version`
10+
11+
### Example
12+
13+
```yaml
14+
otk.version: "1"
15+
```
16+
17+
## `otk.target.<consumer>.<name>`
18+
19+
Only act on this sub-tree if producing output for the specified consumer. Anything specific to the pipelines of e.g. osbuild would be put under `otk.target.osbuild`. This allows `otk` to infer context for the omnifest that is being processed.
20+
21+
A target is necessary for `otk` to generate any outputs. The target is namespaced to a specific application. `otk` tries to keep little context but it does need to know what it is outputting for. This allows us to scope [otk.external](#otkexternal) things to only be allowed within specific targets and for those externals to assume certain things will be in the tree.
22+
23+
The following values are valid for the `<consumer>` part of the key, this list can grow as other image build tooling is supported:
24+
25+
- `osbuild`
26+
27+
The `<name>` part of the key is free form and allows you to use a descriptive name for the export. Note that there MUST be no duplication of the `<consumer>.<name>` tuple.
28+
29+
```yaml
30+
otk.target.osbuild.tree:
31+
pipelines:
32+
- otk.include: pipelines/root.yaml
33+
- otk.include: pipelines/tree.yaml
34+
```
35+
36+
---
37+
38+
## `otk.define`
39+
40+
Defines variables that can be used through the `${}` directive in
41+
other parts of the omnifest.
42+
43+
Variable scope is global, an `otk.define` directive anywhere in the omnifest
44+
tree will result in the defined names being hoisted to the global scope.
45+
46+
Redefinitions of variables are allowed. This allows for setting up default
47+
values. If `-W duplicate-definition` is passed as an argument to `otk` then
48+
`otk` will warn on all duplicate definitions.
49+
50+
Expects a `map` for its value.
51+
52+
```yaml
53+
otk.define:
54+
packages:
55+
include:
56+
- @core
57+
- kernel
58+
exclude:
59+
- linux-util
60+
boot_mode: uefi
61+
```
62+
63+
Valid variable names must start with `[a-zA-Z]` and after that initial
64+
char can also contain `[a-zA-Z0-9_]`. E.g. `foo` is valid but `f?` is
65+
not.
66+
67+
## Usage of `${}`
68+
69+
Use a previously defined variable. String values can be used inside other
70+
string values, non-string values *must* stand on their own.
71+
72+
```yaml
73+
otk.define:
74+
variable: "foo"
75+
76+
otk.include: ${variable}
77+
```
78+
79+
Using the above `packages` map example you can refer to the include and exclude
80+
lists using `${packages.include}` and `${packages.exclude}`.
81+
82+
If a `${}` appears in a `str` value then its string value as it appears
83+
in `otk.define` is replaced into the string. Note that substitutions
84+
in this form require the value to be a string in the `otk.define`.
85+
86+
```yaml
87+
# this is OK
88+
otk.define:
89+
variable: aarch64
90+
91+
otk.include: path/${variable}.yaml
92+
```
93+
94+
The following example is an error as the value of `variable` is a `seq`, which
95+
is not allowed inside a string format.
96+
97+
```yaml
98+
# this is NOT OK
99+
otk.define:
100+
variable:
101+
- 1
102+
- 2
103+
104+
otk.include: path/${variable}.yaml
105+
```
106+
107+
This is okay because `${variable}` is there on it's own so it's unambiguous.
108+
```yaml
109+
# this is OK
110+
otk.define:
111+
variable:
112+
- 1
113+
- 2
114+
115+
some:
116+
thing: ${variable}
117+
```
118+
119+
## `otk.include`
120+
121+
Include a file at this position in the tree, replacing the directive with the
122+
contents of the file.
123+
124+
Note that cyclical includes are forbidden and will cause an error.
125+
126+
It expects a `str` for its value and as with other strings variable substitution
127+
is performed before using it.
128+
129+
```yaml
130+
otk.include: file.yaml
131+
```
132+
133+
## `otk.op`
134+
135+
Perform various operations on variables.
136+
137+
### `otk.op.join`
138+
139+
Join two or more variables of type `sequence` or `map` together, trying to
140+
join other types or mix types will cause an error. Duplicate keys in
141+
maps are considered an error.
142+
143+
Expects a `map` for its value that contains a `values` key with a value of type
144+
`seq` or `map`.
145+
146+
Example when using with a `sequence` as input:
147+
148+
```yaml
149+
otk.define:
150+
a:
151+
- 1
152+
- 2
153+
b:
154+
- 3
155+
- 4
156+
c:
157+
otk.op.join:
158+
values:
159+
- ${a}
160+
- ${b}
161+
162+
-> Result c: [1, 2, 3, 4]
163+
```
164+
165+
Example when using with a `map` as input:
166+
167+
```yaml
168+
otk.define:
169+
a:
170+
a: 1
171+
b:
172+
b: 2
173+
c:
174+
otk.op.join:
175+
values:
176+
- ${a}
177+
- ${b}
178+
179+
-> Result
180+
c:
181+
a: 1
182+
b: 2
183+
```
184+
185+
## `otk.external`
186+
187+
External directives. Directives starting with `otk.external` are redirected
188+
to `/usr/libexec/otk/external`-binaries. For example the directive
189+
`otk.external.osbuild-depsolve-dnf4` will execute `osbuild-depsolve-dnf4`
190+
with the tree under the directive on stdin and expect a new tree to replace
191+
the directive with on stdout.
192+
193+
Read more about [external directives](./02-external.md) in their specific
194+
documentation section.

0 commit comments

Comments
 (0)