From a50adef4814f1d637916c0e05f17c5d2a8eb46a3 Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Fri, 6 Dec 2024 15:26:33 +0200 Subject: [PATCH] fix: handle delete of docker env value --- common/envOverwrite/overwriter.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/common/envOverwrite/overwriter.go b/common/envOverwrite/overwriter.go index 3b4bcac378..87237cc2f2 100644 --- a/common/envOverwrite/overwriter.go +++ b/common/envOverwrite/overwriter.go @@ -96,14 +96,24 @@ func GetPatchedEnvValue(envName string, observedValue string, currentSdk *common // check if we already processed this env since it's annotation if annotationOriginalValueFound { + + desiredFullValueWithObserved := observedValue + if !strings.Contains(observedValue, desiredOdigosPart) { + desiredFullValueWithObserved = observedValue + envMetadata.delim + desiredOdigosPart + } + if currentContainerManifestValue == nil { - return &desiredOdigosPart, nil + // if the value is from dockerfile, we need to add observed value to it + if annotationOriginalValue == nil { + return &desiredFullValueWithObserved, nil + } else { + return &desiredOdigosPart, nil + } } // this part checks if the value in the env is what odigos would use, // and if it is, don't make any changes - desiredFullValue := observedValue + envMetadata.delim + desiredOdigosPart - if desiredFullValue == *currentContainerManifestValue { + if desiredFullValueWithObserved == *currentContainerManifestValue { return currentContainerManifestValue, annotationOriginalValue }