Skip to content

Commit

Permalink
Adding isChartInstallable
Browse files Browse the repository at this point in the history
  • Loading branch information
JaylonmcShan03 committed Dec 3, 2024
1 parent 510bce8 commit 4533828
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 8 additions & 1 deletion helm-framework/helm/data_source_helm_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ func chartPathOptionsModel(model *HelmTemplateModel, meta *Meta, cpo *action.Cha
}
}

version := model.Version.ValueString()
version := getVersionModel(model)

cpo.CaFile = model.RepositoryCaFile.ValueString()
cpo.CertFile = model.RepositoryCertFile.ValueString()
Expand All @@ -851,6 +851,13 @@ func chartPathOptionsModel(model *HelmTemplateModel, meta *Meta, cpo *action.Cha

return cpo, chartName, diags
}
func getVersionModel(model *HelmTemplateModel) string {
version := model.Version.ValueString()
if version == "" && model.Devel.ValueBool() {
return ">0.0.0-0"
}
return strings.TrimSpace(version)
}

func getChartModel(ctx context.Context, model *HelmTemplateModel, meta *Meta, name string, cpo *action.ChartPathOptions) (*chart.Chart, string, diag.Diagnostics) {
var diags diag.Diagnostics
Expand Down
8 changes: 4 additions & 4 deletions helm-framework/helm/resource_helm_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -1141,11 +1141,11 @@ func getVersion(model *HelmReleaseModel) string {
}

func isChartInstallable(ch *chart.Chart) error {
chartType := ch.Metadata.Type
if strings.EqualFold(chartType, "library") {
return errors.Errorf("library charts are not installable")
switch ch.Metadata.Type {
case "", "application":
return nil
}
return nil
return errors.Errorf("%s charts are not installable", ch.Metadata.Type)
}

func getChart(ctx context.Context, model *HelmReleaseModel, m *Meta, name string, cpo *action.ChartPathOptions) (*chart.Chart, string, diag.Diagnostics) {
Expand Down

0 comments on commit 4533828

Please sign in to comment.