Skip to content

Commit

Permalink
save default chart values to Module spec
Browse files Browse the repository at this point in the history
  • Loading branch information
petar-cvit committed Apr 24, 2024
1 parent 52d3256 commit 9bd84b0
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 74 deletions.
3 changes: 2 additions & 1 deletion cyclops-ctrl/internal/models/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ type Template struct {
Modules []dto.Module `json:"modules"`
Version string `json:"version"`

Files []*chart.File `json:"files"`
Files []*chart.File `json:"files"`
Helpers []*chart.File `json:"helpers"`

Dependencies []*Template `json:"dependencies"`
}
Expand Down
10 changes: 4 additions & 6 deletions cyclops-ctrl/internal/template/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,12 @@ func (r Repo) mapHelmChart(chartName string, files map[string][]byte) (*models.T

}

if len(schemaBytes) == 0 {
return nil, errors.New("could not read 'values.schema.json' file; it should be placed in the repo/path you provided; make sure you provided the correct path")
}

var schema helm.Property
// unmarshal values schema only if present
if err := json.Unmarshal(schemaBytes, &schema); err != nil {
return &models.Template{}, err
if len(schemaBytes) > 0 {
if err := json.Unmarshal(schemaBytes, &schema); err != nil {
return &models.Template{}, err
}
}

var metadata helmchart.Metadata
Expand Down
4 changes: 4 additions & 0 deletions cyclops-ctrl/internal/template/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ func HelmTemplate(module cyclopsv1alpha1.Module, moduleTemplate *models.Template

out, err := engine.Render(chart, top)
if err != nil {
//fmt.Println("pocetak")
//fmt.Println(moduleTemplate.Manifest)
//fmt.Println("kraj")
//fmt.Println(err)
//panic("akak")
return "", err
}

Expand Down
Loading

0 comments on commit 9bd84b0

Please sign in to comment.