2023-04-24
Fixed issue from 2023-04-22 with created directories for container. Now it looks like this:
|
|
I noticed my MySQL container exited with status 1
. With a quick podman logs
, I figured out I omitted environment variables.
But quickly, I had a problem: some variable have default values, others has to be generated later (example, password), others must be provided and fail if not. I’ve created a envvar.go
file in internal/runtimes
to address this issue.
At the core, env var have a name, a default values, and what I called modifiers. Just as for mount points, I parse Dockerfile to retrieve the information and put it in a struct. Default values come from ENV
instructions, modifiers and var without default come from label studentbox.config.env
. This is to assure compatibility with any tool using the ENV
instructions of dockerfiles/containerfile. But that might change later, so I keep the coupling level at the minimum. Note from Michelle: it’s anticipating change. Meaning parsing and applying modifiers is two distinct jobs (both deal with EnvVar
struct).
In the end, I declare “official” runtimes with go generate
, that will read and parse files in ./runtimes/
to create file ./internal/runtimes/generated.go
, that export a single map OfficialRuntimes
. A new runtime just have to create a new directory in ./runtimes
, create the needed containerfile, add labels and that’s it: runtime will be build by Github actions and will have an official entry in OfficialRuntimes.
I’ve written unit tests for envvar.go
.