Skip to content

Commit

Permalink
only add image pull secret when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
abelanger5 committed Jan 21, 2021
1 parent 08e6fa8 commit 7016ae8
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions internal/helm/postrenderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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
}

}
}

Expand Down

0 comments on commit 7016ae8

Please sign in to comment.