parametrized working directory (#185)

* parametrized working directory

* manifests v3.0
This commit is contained in:
Reinier Timmer 2020-11-25 00:55:26 +01:00 committed by GitHub
parent 4e93879b8f
commit ee8fb5a388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 34 additions and 3 deletions

View File

@ -342,6 +342,10 @@ spec:
value: abcd1234
securityContext:
runAsUser: 0
# if workDir is not specified, the default working directory is /runner/_work
# this setting allows you to customize the working directory location
# for example, the below setting is the same as on the ubuntu-18.04 image
workDir: /home/runner/work
```
## Runner labels

View File

@ -59,6 +59,8 @@ type RunnerSpec struct {
// +optional
Volumes []corev1.Volume `json:"volumes,omitempty"`
// +optional
WorkDir string `json:"workDir,omitempty"`
// +optional
InitContainers []corev1.Container `json:"initContainers,omitempty"`

View File

@ -1533,6 +1533,8 @@ spec:
- name
type: object
type: array
workDir:
type: string
type: object
type: object
required:

View File

@ -1533,6 +1533,8 @@ spec:
- name
type: object
type: array
workDir:
type: string
type: object
type: object
required:

View File

@ -1526,6 +1526,8 @@ spec:
- name
type: object
type: array
workDir:
type: string
type: object
status:
description: RunnerStatus defines the observed state of Runner

View File

@ -1533,6 +1533,8 @@ spec:
- name
type: object
type: array
workDir:
type: string
type: object
type: object
required:

View File

@ -1533,6 +1533,8 @@ spec:
- name
type: object
type: array
workDir:
type: string
type: object
type: object
required:

View File

@ -1526,6 +1526,8 @@ spec:
- name
type: object
type: array
workDir:
type: string
type: object
status:
description: RunnerStatus defines the observed state of Runner

View File

@ -307,6 +307,11 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
runnerImage = r.RunnerImage
}
workDir := runner.Spec.WorkDir
if workDir == "" {
workDir = "/runner/_work"
}
runnerImagePullPolicy := runner.Spec.ImagePullPolicy
if runnerImagePullPolicy == "" {
runnerImagePullPolicy = corev1.PullAlways
@ -345,6 +350,10 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
Name: "GITHUB_URL",
Value: r.GitHubClient.GithubBaseURL,
},
{
Name: "RUNNER_WORKDIR",
Value: workDir,
},
}
env = append(env, runner.Spec.Env...)
@ -392,7 +401,7 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
pod.Spec.Containers[0].VolumeMounts = []corev1.VolumeMount{
{
Name: "work",
MountPath: "/runner/_work",
MountPath: workDir,
},
{
Name: "externals",
@ -409,7 +418,7 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
VolumeMounts: []corev1.VolumeMount{
{
Name: "work",
MountPath: "/runner/_work",
MountPath: workDir,
},
{
Name: "externals",

View File

@ -27,6 +27,10 @@ else
exit 1
fi
if [ -n "${RUNNER_WORKDIR}" ]; then
WORKDIR_ARG="--work ${RUNNER_WORKDIR}"
fi
if [ -n "${RUNNER_LABELS}" ]; then
LABEL_ARG="--labels ${RUNNER_LABELS}"
fi
@ -41,7 +45,7 @@ if [ -z "${RUNNER_REPO}" ] && [ -n "${RUNNER_ORG}" ] && [ -n "${RUNNER_GROUP}" ]
fi
cd /runner
./config.sh --unattended --replace --name "${RUNNER_NAME}" --url "${GITHUB_URL}${ATTACH}" --token "${RUNNER_TOKEN}" ${RUNNER_GROUP_ARG} ${LABEL_ARG}
./config.sh --unattended --replace --name "${RUNNER_NAME}" --url "${GITHUB_URL}${ATTACH}" --token "${RUNNER_TOKEN}" ${RUNNER_GROUP_ARG} ${LABEL_ARG} ${WORKDIR_ARG}
# Hack due to the DinD volumes
mv ./externalstmp/* ./externals/