Ver Fonte

only add image pull secret when necessary

Alexander Belanger há 5 anos atrás
pai
commit
6640c454b2
1 ficheiros alterados com 8 adições e 14 exclusões
  1. 8 14
      internal/helm/postrenderer.go

+ 8 - 14
internal/helm/postrenderer.go

@@ -269,14 +269,8 @@ func (d *DockerSecretsPostRenderer) updatePodSpecs(secrets map[string]string) {
 		imagePullSecrets := make([]map[string]interface{}, 0)
 
 		if existingPullSecrets, ok := podSpec["imagePullSecrets"]; ok {
-			existing := existingPullSecrets.([]map[string]interface{})
-
-			for _, s := range existing {
-				if name, ok := s["name"]; ok {
-					if n, ok := name.(string); ok && n != "" {
-						imagePullSecrets = append(imagePullSecrets, s)
-					}
-				}
+			if existing, ok := existingPullSecrets.([]map[string]interface{}); ok {
+				imagePullSecrets = existing
 			}
 		}
 
@@ -308,16 +302,16 @@ func (d *DockerSecretsPostRenderer) updatePodSpecs(secrets map[string]string) {
 				regName += "/" + strings.Join(pathArr[:len(pathArr)-1], "/")
 			}
 
-			imagePullSecrets = append(imagePullSecrets, map[string]interface{}{
-				"name": secrets[regName],
-			})
+			if secretName, ok := secrets[regName]; ok && secretName != "" {
+				imagePullSecrets = append(imagePullSecrets, map[string]interface{}{
+					"name": secretName,
+				})
+			}
 		}
+
 		if len(imagePullSecrets) > 0 {
 			podSpec["imagePullSecrets"] = imagePullSecrets
-		} else {
-			podSpec["imagePullSecrets"] = nil
 		}
-
 	}
 }