Browse Source

Code refactoring

Sebastián Gómez 3 years ago
parent
commit
65e93fa992
1 changed files with 3 additions and 18 deletions
  1. 3 18
      pkg/provider/azure/keyvault/keyvault.go

+ 3 - 18
pkg/provider/azure/keyvault/keyvault.go

@@ -253,25 +253,10 @@ func getSecretTag(tags map[string]*string, property string) ([]byte, error) {
 	}
 	}
 
 
 	if idx > 0 {
 	if idx > 0 {
-		tagName := string(property[0:idx])
+		tagName := property[0:idx]
 		if val, exist := tags[tagName]; exist {
 		if val, exist := tags[tagName]; exist {
-			for idx > 0 {
-				tagName = strings.Replace(property, tagName+".", "", 1)
-				jValue := gjson.Get(*val, tagName)
-				if jValue.Exists() {
-					return []byte(jValue.String()), nil
-				} else {
-					escaped := strings.ReplaceAll(tagName, ".", "\\.")
-					jValue := gjson.Get(*val, escaped)
-					if jValue.Exists() {
-						return []byte(jValue.String()), nil
-					} else {
-						idx = strings.Index(tagName, ".")
-					}
-				}
-			}
-		} else {
-			return nil, fmt.Errorf(errTagNotExist, property)
+			key := strings.Replace(property, tagName+".", "", 1)
+			return getProperty(*val, key, property)
 		}
 		}
 	}
 	}