feature(provider): Make some of the runner parameters configurable in the extra config at garm runtime
Some checks failed
Go Tests / go-tests (push) Failing after 1m3s
Some checks failed
Go Tests / go-tests (push) Failing after 1m3s
This commit is contained in:
parent
dadb5076f2
commit
94038106d7
2 changed files with 54 additions and 3 deletions
24
README.md
24
README.md
|
|
@ -16,3 +16,27 @@ docker buildx build -t edp.buildth.ing/devfw-cicd/garm:provider-ec-[new_number]
|
|||
|
||||
kubectl apply -f ../garm/deploy.yaml
|
||||
´´´
|
||||
|
||||
# Configuration
|
||||
|
||||
## Extra Specs
|
||||
|
||||
You can configure runner behavior by passing extra specifications as JSON in the pool's `extra_specs` field.
|
||||
|
||||
### Available Parameters
|
||||
|
||||
| Parameter | Type | Default Value | Description |
|
||||
|-----------|------|---------------|-------------|
|
||||
| `runner_workdir` | string | `/runner/_work/` | The working directory for the runner |
|
||||
| `disable_runner_update` | boolean | `true` | Whether to disable automatic runner updates |
|
||||
| `runner_ephemeral` | boolean | `true` | Whether the runner should be ephemeral (single-use) |
|
||||
|
||||
### Example
|
||||
|
||||
```json
|
||||
{
|
||||
"runner_workdir": "/custom/path/",
|
||||
"disable_runner_update": false,
|
||||
"runner_ephemeral": false
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package spec
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
|
@ -16,6 +17,12 @@ type GitHubScopeDetails struct {
|
|||
Enterprise string
|
||||
}
|
||||
|
||||
type RunnerExtraSpecs struct {
|
||||
RunnerWorkDir string `json:"runner_workdir"`
|
||||
DisableRunnerUpdate *bool `json:"disable_runner_update"`
|
||||
RunnerEphemeral *bool `json:"runner_ephemeral"`
|
||||
}
|
||||
|
||||
func ExtractGitHubScopeDetails(gitRepoURL string) (GitHubScopeDetails, error) {
|
||||
if gitRepoURL == "" {
|
||||
return GitHubScopeDetails{}, fmt.Errorf("no gitRepoURL supplied")
|
||||
|
|
@ -51,6 +58,26 @@ func ExtractGitHubScopeDetails(gitRepoURL string) (GitHubScopeDetails, error) {
|
|||
}
|
||||
|
||||
func GetRunnerEnvs(gitHubScope GitHubScopeDetails, bootstrapParams params.BootstrapInstance) []corev1.EnvVar {
|
||||
var extraSpecs RunnerExtraSpecs
|
||||
if len(bootstrapParams.ExtraSpecs) > 0 {
|
||||
_ = json.Unmarshal(bootstrapParams.ExtraSpecs, &extraSpecs)
|
||||
}
|
||||
|
||||
runnerWorkDir := extraSpecs.RunnerWorkDir
|
||||
if runnerWorkDir == "" {
|
||||
runnerWorkDir = "/runner/_work/"
|
||||
}
|
||||
|
||||
disableRunnerUpdate := "true"
|
||||
if extraSpecs.DisableRunnerUpdate != nil {
|
||||
disableRunnerUpdate = fmt.Sprintf("%t", *extraSpecs.DisableRunnerUpdate)
|
||||
}
|
||||
|
||||
runnerEphemeral := "true"
|
||||
if extraSpecs.RunnerEphemeral != nil {
|
||||
runnerEphemeral = fmt.Sprintf("%t", *extraSpecs.RunnerEphemeral)
|
||||
}
|
||||
|
||||
return []corev1.EnvVar{
|
||||
{
|
||||
Name: "RUNNER_GITEA_INSTANCE",
|
||||
|
|
@ -74,11 +101,11 @@ func GetRunnerEnvs(gitHubScope GitHubScopeDetails, bootstrapParams params.Bootst
|
|||
},
|
||||
{
|
||||
Name: "DISABLE_RUNNER_UPDATE",
|
||||
Value: "true",
|
||||
Value: disableRunnerUpdate,
|
||||
},
|
||||
{
|
||||
Name: "RUNNER_WORKDIR",
|
||||
Value: "/runner/_work/",
|
||||
Value: runnerWorkDir,
|
||||
},
|
||||
{
|
||||
Name: "GITHUB_URL",
|
||||
|
|
@ -86,7 +113,7 @@ func GetRunnerEnvs(gitHubScope GitHubScopeDetails, bootstrapParams params.Bootst
|
|||
},
|
||||
{
|
||||
Name: "RUNNER_EPHEMERAL",
|
||||
Value: "true",
|
||||
Value: runnerEphemeral,
|
||||
},
|
||||
{
|
||||
Name: "RUNNER_TOKEN",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue