Use container name to detect runner container in Pod

This commit is contained in:
Endre Karlson 2022-03-23 12:39:58 +01:00
parent debf53c640
commit ee7484ac91
1 changed files with 12 additions and 1 deletions

View File

@ -18,6 +18,7 @@ package controllers
import (
"context"
"errors"
"fmt"
"time"
@ -64,9 +65,19 @@ func (r *RunnerPodReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
return ctrl.Result{}, nil
}
var envvars []corev1.EnvVar
for _, container := range runnerPod.Spec.Containers {
if container.Name == "runner" {
envvars = container.Env
}
}
if len(envvars) == 0 {
return ctrl.Result{}, errors.New("Could not determine env vars for runner Pod")
}
var enterprise, org, repo string
envvars := runnerPod.Spec.Containers[0].Env
for _, e := range envvars {
switch e.Name {
case EnvVarEnterprise: