Gofer's abstraction for running a container is called a Task. Specifically Custom Tasks are containers you point Gofer to and configure to perform some workload.
A Custom Task can be any Docker container you want to run. In the Getting Started example we take a regular standard
ubuntu:latest container and customize it to run a passed in bash script.
WithTasks( sdk.NewCustomTask("simple_task", "ubuntu:latest"). WithDescription("This task simply prints our hello-world message and exists!"). WithCommand("echo", "Hello from Gofer!"), )
Gofer handles container configuration the cloud native way. That is to say every configuration is passed in as an environment variable. This allows for many advantages, the greatest of which is standardization.
As a user, you pass your configuration in via the
Variable(s) flavor of functions in your pipeline-config.
When a container is run by Gofer, the Gofer scheduler has the potential to pass in configuration from multiple sources1:
Your pipeline configuration: Configs you pass in by using the
Trigger/Manual configurations: Triggers are allowed to pass in custom configuration for a run. Usually this configuration gives extra information the run might need. (For example, the git commit that activated the trigger.).
Alternatively, if this run was not activated by a trigger and instead kicked of manually, the user who launched the run might opt to pass in configuration at that runtime.
Gofer's system configurations: Gofer will pass in system configurations that might be helpful to the user. (For example, what current pipeline is running.)2
The exact key names injected for each of these configurations can be seen on any taskrun by getting that taskrun's details:
gofer taskrun get <pipeline_name> <run_id>
These sources are ordered from most to least important. Since the configuration is passed in a "Key => Value" format any conflicts between sources will default to the source with the greater importance. For instance, a pipeline config with the key
GOFER_PIPELINE_ID will replace the key of the same name later injected by the Gofer system itself.
The current Gofer system injected variables can be found here. Below is a possibly out of date short reference:
|The pipeline identification string.|
|The run identification number.|
|The task run identification string.|
|The image name the task is currently running with.|
|Runs can be assigned a unique Gofer API token automatically. This makes it easy and manageable for tasks to query Gofer's API and do lots of other convenience tasks.|
The high level flow is:
- Gofer checks to make sure your task configuration is valid.
- Gofer parses the task configuration's variables list. It attempts replace any substitution variables with their actual values from the object or secret store.
- Gofer then passes the details of your task to the configured scheduler, variables are passed in as environment variables.
- Usually this means the scheduler will take the configuration and attempt to pull the
imagementioned in the configuration.
- Once the image is successfully pulled the container is then run with the settings passed.