Skip to content

Commit

Permalink
add ValuesTemplateExample to HelmChart Model
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed May 31, 2022
1 parent 7694f15 commit 36c2461
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
17 changes: 9 additions & 8 deletions k8s-deploy/pkg/modules/helm_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ import (

// HelmChart Helm Chart model
type HelmChart struct {
Uuid string `json:"uuid" gorm:"type:varchar(36);index;unique"`
Name string `json:"name" gorm:"type:varchar(16);not null"`
Chart string `json:"chart" gorm:"type:text;not null"`
Values string `json:"values" gorm:"type:text;not null"`
ValuesTemplate string `json:"values_template" gorm:"type:text;not null"`
Templates Templates `json:"templates" gorm:"type:mediumblob" swaggerignore:"true"`
Version string `json:"version" gorm:"type:varchar(32);not null"`
AppVersion string `json:"app_version" gorm:"type:varchar(32);not null"`
Uuid string `json:"uuid" gorm:"type:varchar(36);index;unique"`
Name string `json:"name" gorm:"type:varchar(16);not null"`
Chart string `json:"chart" gorm:"type:text;not null"`
Values string `json:"values" gorm:"type:text;not null"`
ValuesTemplate string `json:"values_template" gorm:"type:text;not null"`
ValuesTemplateExample string `json:"values_template_example" gorm:"type:text;not null"`
Templates Templates `json:"templates" gorm:"type:mediumblob" swaggerignore:"true"`
Version string `json:"version" gorm:"type:varchar(32);not null"`
AppVersion string `json:"app_version" gorm:"type:varchar(32);not null"`

gorm.Model
}
Expand Down
10 changes: 10 additions & 0 deletions k8s-deploy/pkg/modules/helm_chart_special.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (e *HelmChart) ChartRequestedToHelmChart(chartRequested *chart.Chart) (*Hel
var chartData string
var valuesData string
var ValuesTemplate string
var ValuesTemplateExample string
for _, v := range chartRequested.Raw {
if v.Name == "Chart.yaml" {
chartData = string(v.Data)
Expand All @@ -49,12 +50,16 @@ func (e *HelmChart) ChartRequestedToHelmChart(chartRequested *chart.Chart) (*Hel
if v.Name == "values-template.yaml" {
ValuesTemplate = string(v.Data)
}
if v.Name == "values-template-example.yaml" {
ValuesTemplateExample = string(v.Data)
}
}

helmChart := NewHelmChart(chartRequested.Name(),
chartData, valuesData, chartRequested.Templates, chartRequested.Metadata.Version, chartRequested.AppVersion())

helmChart.ValuesTemplate = ValuesTemplate
helmChart.ValuesTemplateExample = ValuesTemplateExample
return helmChart, nil
}

Expand Down Expand Up @@ -103,6 +108,7 @@ func ChartRequestedToHelmChart(chartRequested *chart.Chart) (*HelmChart, error)
var chartData string
var valuesData string
var ValuesTemplate string
var ValuesTemplateExample string
for _, v := range chartRequested.Raw {
if v.Name == "Chart.yaml" {
chartData = string(v.Data)
Expand All @@ -113,12 +119,16 @@ func ChartRequestedToHelmChart(chartRequested *chart.Chart) (*HelmChart, error)
if v.Name == "values-template.yaml" {
ValuesTemplate = string(v.Data)
}
if v.Name == "values-template-example.yaml" {
ValuesTemplateExample = string(v.Data)
}
}

helmChart := NewHelmChart(chartRequested.Name(),
chartData, valuesData, chartRequested.Templates, chartRequested.Metadata.Version, chartRequested.AppVersion())

helmChart.ValuesTemplate = ValuesTemplate
helmChart.ValuesTemplateExample = ValuesTemplateExample
return helmChart, nil
}

Expand Down

0 comments on commit 36c2461

Please sign in to comment.