feat: [CI-18951]: added unit tests and better comments for the changes

This commit is contained in:
Chirag S
2026-02-18 10:40:37 +05:30
parent 5810bf8a5a
commit f32aa46ea8
2 changed files with 95 additions and 4 deletions
+7 -4
View File
@@ -597,7 +597,8 @@ func addProxyValue(build *Build, key string) {
// helper function to get a proxy value from the environment.
//
// assumes that the upper and lower case versions of are the same.
// Checks in order: lowercase key, uppercase key, then HARNESS_<UPPERCASE_KEY>.
// Assumes that the upper and lower case versions are the same value.
func getProxyValue(key string) string {
value := os.Getenv(key)
@@ -606,7 +607,7 @@ func getProxyValue(key string) string {
}
value = os.Getenv(strings.ToUpper(key))
if len(value) > 0 {
return value
}
@@ -617,9 +618,10 @@ func getProxyValue(key string) string {
// helper function that looks to see if a proxy value was set in the build args.
func hasProxyBuildArg(build *Build, key string) bool {
keyUpper := strings.ToUpper(key)
harnessKey := "HARNESS_" + keyUpper
for _, s := range build.Args {
if strings.HasPrefix(s, key) || strings.HasPrefix(s, keyUpper) {
if strings.HasPrefix(s, key) || strings.HasPrefix(s, keyUpper) || strings.HasPrefix(s, harnessKey) {
return true
}
}
@@ -628,9 +630,10 @@ func hasProxyBuildArg(build *Build, key string) bool {
}
func hasProxyBuildArgNew(build *Build, key string) bool {
keyUpper := strings.ToUpper(key)
harnessKey := "HARNESS_" + keyUpper
for _, s := range build.ArgsNew {
if strings.HasPrefix(s, key) || strings.HasPrefix(s, keyUpper) {
if strings.HasPrefix(s, key) || strings.HasPrefix(s, keyUpper) || strings.HasPrefix(s, harnessKey) {
return true
}
}