From 1d97a47e471b89dc34258524759d8f93b9a81649 Mon Sep 17 00:00:00 2001 From: Himanshu <68803793+ghostx31@users.noreply.github.com> Date: Wed, 13 Dec 2023 00:46:31 +0530 Subject: [PATCH] feat: add initializer envFrom field (#351) * feat: add initializer envFrom field * test(initializer): add EnvFrom tests --- pkg/resources/jobs/initializer.go | 1 + pkg/resources/jobs/initializer_test.go | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pkg/resources/jobs/initializer.go b/pkg/resources/jobs/initializer.go index db62dbdb..1b25449b 100644 --- a/pkg/resources/jobs/initializer.go +++ b/pkg/resources/jobs/initializer.go @@ -123,6 +123,7 @@ func NewInitializerJob(k6 v1alpha1.TestRunI, argLine string) (*batchv1.Job, erro Env: env, Resources: k6.GetSpec().Initializer.Resources, VolumeMounts: volumeMounts, + EnvFrom: k6.GetSpec().Initializer.EnvFrom, Ports: ports, }, }, diff --git a/pkg/resources/jobs/initializer_test.go b/pkg/resources/jobs/initializer_test.go index 7f63a948..b1626ef8 100644 --- a/pkg/resources/jobs/initializer_test.go +++ b/pkg/resources/jobs/initializer_test.go @@ -65,7 +65,16 @@ func TestNewInitializerJob(t *testing.T) { "sh", "-c", "mkdir -p $(dirname /tmp/test.js.archived.tar) && k6 archive /test/test.js -O /tmp/test.js.archived.tar --out cloud 2> /tmp/k6logs && k6 inspect --execution-requirements /tmp/test.js.archived.tar 2> /tmp/k6logs ; ! cat /tmp/k6logs | grep 'level=error'", }, - Env: []corev1.EnvVar{}, + Env: []corev1.EnvVar{}, + EnvFrom: []corev1.EnvFromSource{ + { + ConfigMapRef: &corev1.ConfigMapEnvSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "env", + }, + }, + }, + }, Resources: corev1.ResourceRequirements{}, VolumeMounts: script.VolumeMount(), Ports: []corev1.ContainerPort{{ContainerPort: 6565}}, @@ -99,6 +108,15 @@ func TestNewInitializerJob(t *testing.T) { "awesomeAnnotation": "dope", }, }, + EnvFrom: []corev1.EnvFromSource{ + { + ConfigMapRef: &corev1.ConfigMapEnvSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "env", + }, + }, + }, + }, }, }, }