mirror of
https://github.com/drone-plugins/drone-docker.git
synced 2026-06-04 18:24:24 +08:00
feat: [CI-18951]: added unit tests and better comments for the changes
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user