Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changes/unreleased/Feature-20260629-093256.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Feature
body: Add Scope field on RunnerJobVariable so variables can be restricted to the init container or the main job container
time: 2026-06-29T09:32:56.728664-07:00
3 changes: 3 additions & 0 deletions .changes/unreleased/Feature-20260629-093307.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Feature
body: Add InitCommands and InitImage fields on RunnerJob to support running an init container before the main job container
time: 2026-06-29T09:33:07.696442-07:00
33 changes: 23 additions & 10 deletions job.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,21 @@ type Runner struct {
Status RunnerStatusTypeEnum `json:"status"`
}

// RunnerJobVariableScope controls which container(s) on the job pod receive a
// variable. An empty value means the variable is available in both the init
// container and the main job container (the default).
type RunnerJobVariableScope string

const (
RunnerJobVariableScopeInit RunnerJobVariableScope = "init"
RunnerJobVariableScopeMain RunnerJobVariableScope = "main"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

presumably we could also extend it with sidecar or something too!

)

type RunnerJobVariable struct {
Key string `json:"key"`
Sensitive bool `json:"sensitive"`
Value string `json:"value"`
Key string `json:"key"`
Sensitive bool `json:"sensitive"`
Value string `json:"value"`
Scope RunnerJobVariableScope `json:"scope"`
}

type RunnerJobFile struct {
Expand All @@ -83,13 +94,15 @@ type RunnerJobFile struct {
}

type RunnerJob struct {
Commands []string `json:"commands"`
Id ID `json:"id"`
Image string `json:"image"`
Outcome RunnerJobOutcomeEnum `json:"outcome"`
Status RunnerJobStatusEnum `json:"status"`
Variables []RunnerJobVariable `json:"variables"`
Files []RunnerJobFile `json:"files"`
Commands []string `json:"commands"`
Id ID `json:"id"`
Image string `json:"image"`
Outcome RunnerJobOutcomeEnum `json:"outcome"`
Status RunnerJobStatusEnum `json:"status"`
Variables []RunnerJobVariable `json:"variables"`
Files []RunnerJobFile `json:"files"`
InitCommands []string `json:"initCommands"`
InitImage string `json:"initImage"`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initImage is not technically required at present, but could be handy in short order

}

func (runnerJob *RunnerJob) Number() string {
Expand Down
21 changes: 18 additions & 3 deletions job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestRunnerGetScale(t *testing.T) {
func TestRunnerGetPendingJobs(t *testing.T) {
// Arrange
testRequest := autopilot.NewTestRequest(
`mutation RunnerGetPendingJob($id:ID!$token:ID){runnerGetPendingJob(runnerId: $id lastUpdateToken: $token){runnerJob{commands,id,image,outcome,status,variables{key,sensitive,value},files{name,contents}},lastUpdateToken,errors{message,path}}}`,
`mutation RunnerGetPendingJob($id:ID!$token:ID){runnerGetPendingJob(runnerId: $id lastUpdateToken: $token){runnerJob{commands,id,image,outcome,status,variables{key,sensitive,value,scope},files{name,contents},initCommands,initImage},lastUpdateToken,errors{message,path}}}`,
`{"id":"1234567890", "token": "1234"}`,
`{"data": {
"runnerGetPendingJob": {
Expand All @@ -75,9 +75,20 @@ func TestRunnerGetPendingJobs(t *testing.T) {
"variables": [
{
"key": "AWS_ACCESS_KEY",
"value": "XXXXXXX"
"value": "XXXXXXX",
"scope": "main"
},
{
"key": "REPO_CLONE_URL",
"value": "https://token@example.com/repo.git",
"sensitive": true,
"scope": "init"
}
]
],
"initCommands": [
"/opslevel/clone-repo ."
],
"initImage": "public.ecr.aws/opslevel/cli:v2022.02.25"
},
"lastUpdateToken": "12344321",
"errors": []
Expand All @@ -92,6 +103,10 @@ func TestRunnerGetPendingJobs(t *testing.T) {
autopilot.Equals(t, "public.ecr.aws/opslevel/cli:v2022.02.25", result.Image)
autopilot.Equals(t, "ls -al", result.Commands[1])
autopilot.Equals(t, ol.ID("12344321"), token)
autopilot.Equals(t, []string{"/opslevel/clone-repo ."}, result.InitCommands)
autopilot.Equals(t, "public.ecr.aws/opslevel/cli:v2022.02.25", result.InitImage)
autopilot.Equals(t, ol.RunnerJobVariableScopeMain, result.Variables[0].Scope)
autopilot.Equals(t, ol.RunnerJobVariableScopeInit, result.Variables[1].Scope)
}

func TestRunnerAppendJobLog(t *testing.T) {
Expand Down
Loading