Skip to content

Commit

Permalink
Merge pull request #768 from somtochiama/nil-artifac
Browse files Browse the repository at this point in the history
Check source for nil artifact before loading chart
  • Loading branch information
hiddeco committed Sep 11, 2023
2 parents 9fa5cf7 + c1d77ad commit 394ab5a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/controller/helmrelease_controller_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,19 @@ func (r *HelmReleaseReconciler) getHelmChart(ctx context.Context, hr *v2.HelmRel
// loads it into a chart.Chart, and removes the downloaded artifact.
// It returns the loaded chart.Chart on success, or an error.
func (r *HelmReleaseReconciler) loadHelmChart(source *sourcev1b2.HelmChart) (*chart.Chart, error) {
artifact := source.GetArtifact()
if artifact == nil {
return nil, fmt.Errorf("cannot load chart: HelmChart '%s/%s' has no artifact", source.GetNamespace(), source.GetName())
}

f, err := os.CreateTemp("", fmt.Sprintf("%s-%s-*.tgz", source.GetNamespace(), source.GetName()))
if err != nil {
return nil, err
}
defer f.Close()
defer os.Remove(f.Name())

artifactURL := source.GetArtifact().URL
artifactURL := artifact.URL
if hostname := os.Getenv("SOURCE_CONTROLLER_LOCALHOST"); hostname != "" {
u, err := url.Parse(artifactURL)
if err != nil {
Expand Down

0 comments on commit 394ab5a

Please sign in to comment.