Skip to content

Commit d83db26

Browse files
committed
OCPBUGS-44235: Fix Helm chart installation with CA/TLS certificates
Console uses Kubernetes CRDs to manage Helm repositories, not Helm's repository cache. Setting chartPathOptions.RepoURL forced Helm to look for a cache that doesn't exist in the console pod's read-only filesystem. Remove RepoURL assignments and use direct URL downloads with CaFile, CertFile, and KeyFile for authentication. Fixes https://issues.redhat.com/browse/OCPBUGS-44235 Signed-off-by: Martin Szuc <mszuc@redhat.com>
1 parent 85c59f9 commit d83db26

File tree

4 files changed

+5
-29
lines changed

4 files changed

+5
-29
lines changed

pkg/helm/actions/auth.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ func setUpAuthentication(chartPathOptions *action.ChartPathOptions, connectionCo
1919
tlsFiles := []*os.File{}
2020
//set up tls cert and key
2121
if connectionConfig.TLSClientConfig != (configv1.SecretNameReference{}) {
22-
chartPathOptions.RepoURL = connectionConfig.URL
2322
tlsKeyFile, tlsCertFile, err := setupTlsCertFile(connectionConfig.TLSClientConfig.Name, configNamespace, coreClient)
2423
if err != nil {
2524
return nil, err
@@ -31,7 +30,6 @@ func setUpAuthentication(chartPathOptions *action.ChartPathOptions, connectionCo
3130
}
3231
//set up ca certificate
3332
if connectionConfig.CA != (configv1.ConfigMapNameReference{}) {
34-
chartPathOptions.RepoURL = connectionConfig.URL
3533
caFile, err := setupCaCertFile(connectionConfig.CA.Name, configNamespace, coreClient)
3634
if err != nil {
3735
return nil, err
@@ -47,7 +45,6 @@ func setUpAuthenticationProject(chartPathOptions *action.ChartPathOptions, conne
4745
var secretNamespace string
4846
//set up tls cert and key
4947
if connectionConfig.TLSClientConfig != (configv1.SecretNameReference{}) {
50-
chartPathOptions.RepoURL = connectionConfig.URL
5148
tlsKeyFile, tlsCertFile, err := setupTlsCertFile(connectionConfig.TLSClientConfig.Name, namespace, coreClient)
5249
if err != nil {
5350
return nil, err
@@ -77,7 +74,6 @@ func setUpAuthenticationProject(chartPathOptions *action.ChartPathOptions, conne
7774
}
7875
//set up ca certificate
7976
if connectionConfig.CA != (configv1.ConfigMapNameReference{}) {
80-
chartPathOptions.RepoURL = connectionConfig.URL
8177
caFile, err := setupCaCertFile(connectionConfig.CA.Name, namespace, coreClient)
8278
if err != nil {
8379
return nil, err

pkg/helm/actions/get_chart.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ func GetChart(url string, conf *action.Configuration, repositoryNamespace string
4545
}
4646
}
4747

48-
if len(tlsFiles) == 0 {
49-
chartLocation = url
50-
} else {
51-
chartLocation = chartInfo.Name
52-
}
48+
chartLocation = url
5349

5450
cmd.ChartPathOptions.Version = chartInfo.Version
5551
chartPath, err = cmd.ChartPathOptions.LocateChart(chartLocation, settings)

pkg/helm/actions/install_chart.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,7 @@ func InstallChart(ns, name, url string, vals map[string]interface{}, conf *actio
6868
}
6969
}
7070
cmd.ReleaseName = name
71-
if len(tlsFiles) == 0 {
72-
chartLocation = url
73-
} else {
74-
chartLocation = chartInfo.Name
75-
}
71+
chartLocation = url
7672

7773
cmd.ChartPathOptions.Version = chartInfo.Version
7874
cp, err = cmd.ChartPathOptions.LocateChart(chartLocation, settings)
@@ -150,11 +146,7 @@ func InstallChartAsync(ns, name, url string, vals map[string]interface{}, conf *
150146
}
151147
}
152148
cmd.ReleaseName = name
153-
if len(tlsFiles) == 0 {
154-
chartLocation = url
155-
} else {
156-
chartLocation = chartInfo.Name
157-
}
149+
chartLocation = url
158150
cmd.ChartPathOptions.Version = chartInfo.Version
159151
cp, err = cmd.ChartPathOptions.LocateChart(chartLocation, settings)
160152
if err != nil {

pkg/helm/actions/upgrade_release.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,7 @@ func UpgradeRelease(
8484
return nil, fmt.Errorf("error setting up authentication: %v", err)
8585
}
8686
}
87-
if len(tlsFiles) == 0 {
88-
chartLocation = chartUrl
89-
} else {
90-
chartLocation = chartInfo.Name
91-
}
87+
chartLocation = chartUrl
9288
client.ChartPathOptions.Version = chartInfo.Version
9389
cp, err = client.ChartPathOptions.LocateChart(chartLocation, settings)
9490
if err != nil {
@@ -199,11 +195,7 @@ func UpgradeReleaseAsync(
199195
return nil, fmt.Errorf("error setting up authentication: %v", err)
200196
}
201197
}
202-
if len(tlsFiles) == 0 {
203-
chartLocation = chartUrl
204-
} else {
205-
chartLocation = chartInfo.Name
206-
}
198+
chartLocation = chartUrl
207199
client.ChartPathOptions.Version = chartInfo.Version
208200
cp, err = client.ChartPathOptions.LocateChart(chartLocation, settings)
209201
if err != nil {

0 commit comments

Comments
 (0)