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
|
|
@ -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