Skip to content

Commit

Permalink
Corrected certificate managment for OCI helm charts (#16656)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Block <[email protected]>
Co-authored-by: Soumya Ghosh Dastidar <[email protected]>
  • Loading branch information
sabre1041 and gdsoumya authored Jan 31, 2024
1 parent 7f749c6 commit c691d36
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions util/helm/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,28 @@ func (c *Cmd) RegistryLogin(repo string, creds Creds) (string, error) {
args = append(args, "--password", creds.Password)
}

if creds.CAPath != "" {
args = append(args, "--ca-file", creds.CAPath)
}

if len(creds.CertData) > 0 {
filePath, closer, err := writeToTmp(creds.CertData)
if err != nil {
return "", err
}
defer argoio.Close(closer)
args = append(args, "--cert-file", filePath)
}

if len(creds.KeyData) > 0 {
filePath, closer, err := writeToTmp(creds.KeyData)
if err != nil {
return "", err
}
defer argoio.Close(closer)
args = append(args, "--key-file", filePath)
}

if creds.InsecureSkipVerify {
args = append(args, "--insecure")
}
Expand Down Expand Up @@ -238,6 +260,25 @@ func (c *Cmd) PullOCI(repo string, chart string, version string, destination str
if creds.CAPath != "" {
args = append(args, "--ca-file", creds.CAPath)
}

if len(creds.CertData) > 0 {
filePath, closer, err := writeToTmp(creds.CertData)
if err != nil {
return "", err
}
defer argoio.Close(closer)
args = append(args, "--cert-file", filePath)
}

if len(creds.KeyData) > 0 {
filePath, closer, err := writeToTmp(creds.KeyData)
if err != nil {
return "", err
}
defer argoio.Close(closer)
args = append(args, "--key-file", filePath)
}

if creds.InsecureSkipVerify && c.insecureSkipVerifySupported {
args = append(args, "--insecure-skip-tls-verify")
}
Expand Down

0 comments on commit c691d36

Please sign in to comment.