mirror of
https://github.com/optim-enterprises-bv/secureblue.git
synced 2025-11-25 14:35:07 +00:00
Merge pull request #170 from ublue-os/module-working-dir
docs: module working directory, style guides
This commit is contained in:
1
build.sh
1
build.sh
@@ -23,6 +23,7 @@ run_module() {
|
||||
MODULE="$1"
|
||||
TYPE=$(echo "$MODULE" | yq '.type')
|
||||
if [[ "$TYPE" != "null" ]]; then
|
||||
cd "$CONFIG_DIRECTORY"
|
||||
# If type is found, that means that the module config
|
||||
# has been declared inline, and thus is safe to pass to the module
|
||||
echo "=== Launching module of type: $TYPE ==="
|
||||
|
||||
@@ -8,6 +8,8 @@ Modules get only the configuration options given to them in the recipe.yml, not
|
||||
|
||||
Additionally, each module has access to four environment variables, `CONFIG_DIRECTORY` pointing to the Startingpoint directory in `/usr/share/ublue-os/`, `IMAGE_NAME` being the name of the image as declared in the recipe, `BASE_IMAGE` being the URL of the container image used as the base (FROM) in the image, and `OS_VERSION` being the `VERSION_ID` from `/usr/lib/os-release`.
|
||||
|
||||
When running modules, the working directory is the `CONFIG_DIRECTORY`.
|
||||
|
||||
A helper bash function called `get_yaml_array` is exported from the main build script.
|
||||
```bash
|
||||
# "$1" is the first cli argument, being the module configuration.
|
||||
@@ -23,3 +25,22 @@ All bash-based modules should start with the following lines to ensure the image
|
||||
#!/usr/bin/env bash
|
||||
set -oue pipefail
|
||||
```
|
||||
|
||||
## Style directions for official modules
|
||||
|
||||
These are general directions for writing official modules and their documentation to follow to keep a consistent style. Not all of these are to be mindlessly followed, especially the ones about grammar and writing style. It's good to keep these in mind if you intend to contribute back upstream, though, so that your module doesn't feel out of place.
|
||||
|
||||
### Bash
|
||||
|
||||
- Start with `#!/usr/bin/env bash` and `set -oue pipefail`
|
||||
- Don't print "===", this is only for encapsulating the output of _different_ modules in `build.sh`
|
||||
- Print something on each step and on errors for easier debugging
|
||||
- Use CAPITALIZED names for variables that are read from the configuration
|
||||
|
||||
### README
|
||||
|
||||
- Title should be "`type` Module for Startingpoint", where the name/type of the module is a noun that shows the module's purpose
|
||||
- There should be a subtitle "Example configuration", under which there should be a loosely documented yaml block showcasing each of the module's configuration options
|
||||
- For a YAML block, specify the language as "yaml", not "yml" (MkDocs only supports "yaml")
|
||||
- At the start of each paragraph, refer to the module using its name or with "the module", not "it" or "the script"
|
||||
- Use passive grammar when talking about the user, ie. "should be used", "can be configured", preferring references to what the module does, ie. "This module downloads the answer to the question of life, the universe and everything..."
|
||||
|
||||
Reference in New Issue
Block a user