From 64f49c75c68f6daf5e1b1cb26e2acd40eb57f8db Mon Sep 17 00:00:00 2001 From: Horiodino Date: Mon, 12 Aug 2024 21:54:38 +0530 Subject: [PATCH] use sourcevalue Signed-off-by: Horiodino --- pkg/devfile/generator/generators_test.go | 14 -------------- pkg/devfile/generator/utils.go | 11 ++++++++--- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/pkg/devfile/generator/generators_test.go b/pkg/devfile/generator/generators_test.go index 9f65ccbd..c287e015 100644 --- a/pkg/devfile/generator/generators_test.go +++ b/pkg/devfile/generator/generators_test.go @@ -135,10 +135,6 @@ func TestGetContainers(t *testing.T) { Name: "PROJECTS_ROOT", Value: "/projects", }, - { - Name: "PROJECT_SOURCE", - Value: "/projects", - }, { Name: "PROJECT_SOURCE", Value: "/projects/test-project", @@ -1452,7 +1448,6 @@ func TestGetPodTemplateSpec(t *testing.T) { Env: []corev1.EnvVar{ {Name: "PROJECTS_ROOT", Value: "/projects"}, {Name: "PROJECT_SOURCE", Value: "/projects"}, - {Name: "PROJECT_SOURCE", Value: "/projects"}, }, ImagePullPolicy: corev1.PullAlways, SecurityContext: &corev1.SecurityContext{ @@ -1465,7 +1460,6 @@ func TestGetPodTemplateSpec(t *testing.T) { Env: []corev1.EnvVar{ {Name: "PROJECTS_ROOT", Value: "/projects"}, {Name: "PROJECT_SOURCE", Value: "/projects"}, - {Name: "PROJECT_SOURCE", Value: "/projects"}, }, ImagePullPolicy: corev1.PullAlways, Ports: []corev1.ContainerPort{}, @@ -1518,7 +1512,6 @@ func TestGetPodTemplateSpec(t *testing.T) { Env: []corev1.EnvVar{ {Name: "PROJECTS_ROOT", Value: "/projects"}, {Name: "PROJECT_SOURCE", Value: "/projects"}, - {Name: "PROJECT_SOURCE", Value: "/projects"}, }, ImagePullPolicy: corev1.PullAlways, SecurityContext: &corev1.SecurityContext{ @@ -1573,7 +1566,6 @@ func TestGetPodTemplateSpec(t *testing.T) { Env: []corev1.EnvVar{ {Name: "PROJECTS_ROOT", Value: "/projects"}, {Name: "PROJECT_SOURCE", Value: "/projects"}, - {Name: "PROJECT_SOURCE", Value: "/projects"}, }, ImagePullPolicy: corev1.PullAlways, SecurityContext: &corev1.SecurityContext{ @@ -1630,7 +1622,6 @@ func TestGetPodTemplateSpec(t *testing.T) { Env: []corev1.EnvVar{ {Name: "PROJECTS_ROOT", Value: "/projects"}, {Name: "PROJECT_SOURCE", Value: "/projects"}, - {Name: "PROJECT_SOURCE", Value: "/projects"}, }, ImagePullPolicy: corev1.PullAlways, Ports: []corev1.ContainerPort{}, @@ -1685,7 +1676,6 @@ func TestGetPodTemplateSpec(t *testing.T) { Env: []corev1.EnvVar{ {Name: "PROJECTS_ROOT", Value: "/projects"}, {Name: "PROJECT_SOURCE", Value: "/projects"}, - {Name: "PROJECT_SOURCE", Value: "/projects"}, }, ImagePullPolicy: corev1.PullAlways, SecurityContext: &corev1.SecurityContext{ @@ -1752,7 +1742,6 @@ func TestGetPodTemplateSpec(t *testing.T) { Env: []corev1.EnvVar{ {Name: "PROJECTS_ROOT", Value: "/projects"}, {Name: "PROJECT_SOURCE", Value: "/projects"}, - {Name: "PROJECT_SOURCE", Value: "/projects"}, }, ImagePullPolicy: corev1.PullAlways, Ports: []corev1.ContainerPort{}, @@ -1822,7 +1811,6 @@ func TestGetPodTemplateSpec(t *testing.T) { Env: []corev1.EnvVar{ {Name: "PROJECTS_ROOT", Value: "/projects"}, {Name: "PROJECT_SOURCE", Value: "/projects"}, - {Name: "PROJECT_SOURCE", Value: "/projects"}, }, ImagePullPolicy: corev1.PullAlways, Ports: []corev1.ContainerPort{}, @@ -1886,7 +1874,6 @@ func TestGetPodTemplateSpec(t *testing.T) { Env: []corev1.EnvVar{ {Name: "PROJECTS_ROOT", Value: "/projects"}, {Name: "PROJECT_SOURCE", Value: "/projects"}, - {Name: "PROJECT_SOURCE", Value: "/projects"}, }, ImagePullPolicy: corev1.PullAlways, Ports: []corev1.ContainerPort{}, @@ -1949,7 +1936,6 @@ func TestGetPodTemplateSpec(t *testing.T) { Env: []corev1.EnvVar{ {Name: "PROJECTS_ROOT", Value: "/projects"}, {Name: "PROJECT_SOURCE", Value: "/projects"}, - {Name: "PROJECT_SOURCE", Value: "/projects"}, }, ImagePullPolicy: corev1.PullAlways, Ports: []corev1.ContainerPort{}, diff --git a/pkg/devfile/generator/utils.go b/pkg/devfile/generator/utils.go index 19d44c19..59db9102 100644 --- a/pkg/devfile/generator/utils.go +++ b/pkg/devfile/generator/utils.go @@ -157,12 +157,17 @@ func addSyncRootFolder(container *corev1.Container, sourceMapping string) string { Name: EnvProjectsRoot, Value: syncRootFolder, - }, { - Name: EnvProjectsSrc, - Value: syncRootFolder, }, }, container.Env...) + if sourceMapping != "" { + container.Env = append(container.Env, + corev1.EnvVar{ + Name: EnvProjectsSrc, + Value: sourceMapping, + }) + } + return syncRootFolder }