From 848c995e3412530ecdbbf03f7359687a2e1eda33 Mon Sep 17 00:00:00 2001 From: eweziyi Date: Mon, 23 Dec 2024 10:52:10 +0800 Subject: [PATCH] Pass api server env vars as kaniko build args --- api/pkg/imagebuilder/imagebuilder.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/api/pkg/imagebuilder/imagebuilder.go b/api/pkg/imagebuilder/imagebuilder.go index 796b0d398..f4dbfdc23 100644 --- a/api/pkg/imagebuilder/imagebuilder.go +++ b/api/pkg/imagebuilder/imagebuilder.go @@ -646,12 +646,9 @@ func (c *imageBuilder) createKanikoJobSpec( volumes, volumeMounts = c.configureVolumesAndVolumeMountsToAddCredentials(volumes, volumeMounts) envVars = c.configureEnvVarsToAddCredentials(envVars) - // Add all other env vars that are propagated from the API server + // Add all other env vars that are propagated from the API server as build args for _, envVar := range c.config.KanikoAPIServerEnvVars { - envVars = append(envVars, v1.EnvVar{ - Name: envVar, - Value: os.Getenv(envVar), - }) + kanikoArgs = append(kanikoArgs, fmt.Sprintf("--build-arg=%s=%s", envVar, os.Getenv(envVar))) } var resourceRequirements RequestLimitResources