helm : fichiers multiples + variable
This commit is contained in:
parent
c7f8503fb6
commit
279f93224f
@ -12,8 +12,8 @@ type ChartData struct {
|
||||
Version string `yaml:"version"`
|
||||
|
||||
Opts string `yaml:"helm_opts"`
|
||||
Values string `yaml:"helm_values"`
|
||||
FileValues string `yaml:"helm_filevalues"`
|
||||
Values map[string]string `yaml:"helm_values"`
|
||||
FileValues []string `yaml:"helm_filevalues"`
|
||||
}
|
||||
|
||||
type repoData struct {
|
||||
@ -33,6 +33,7 @@ type chartsRepoData struct {
|
||||
|
||||
func FromConfigFile(filename string) ([]ChartRepoData, error) {
|
||||
yamlFile, _ := os.ReadFile(filename)
|
||||
|
||||
var data chartsRepoData
|
||||
err := yaml.Unmarshal(yamlFile, &data)
|
||||
if err != nil {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package chart
|
||||
|
||||
// https://pkg.go.dev/github.com/stretchr/testify/assert
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"path/filepath"
|
||||
@ -22,11 +20,15 @@ func TestReadConfChart(t *testing.T){
|
||||
assert.Equal(t, "wordpress", wordpress.Name, "FromConfigFile error")
|
||||
assert.Equal(t, "bitnami/wordpress", wordpress.Chart, "FromConfigFile error")
|
||||
assert.Equal(t, "23.1.0", wordpress.Version, "FromConfigFile error")
|
||||
assert.Equal(t, 0, len(wordpress.FileValues), "FromConfigFile error")
|
||||
assert.Equal(t, 0, len(wordpress.Values), "FromConfigFile error")
|
||||
|
||||
phpmyadmin := data[0].Charts[1]
|
||||
assert.Equal(t, "phpmyadmin", phpmyadmin.Name, "FromConfigFile error")
|
||||
assert.Equal(t, "bitnami/phpmyadmin", phpmyadmin.Chart,"FromConfigFile error")
|
||||
assert.Equal(t, "17.0.4", phpmyadmin.Version, "FromConfigFile error")
|
||||
assert.Equal(t, 2, len(phpmyadmin.FileValues), "FromConfigFile error")
|
||||
assert.Equal(t, 1, len(phpmyadmin.Values), "FromConfigFile error")
|
||||
|
||||
data1 := data[1]
|
||||
assert.Equal(t, "", data1.Repository.Name, "FromConfigFile error")
|
||||
|
@ -20,8 +20,8 @@ type HelmChart struct {
|
||||
|
||||
Workspace string
|
||||
Opts string
|
||||
Values string
|
||||
FileValues string
|
||||
Values map[string]string
|
||||
FileValues []string
|
||||
}
|
||||
|
||||
type installInfoOutput struct {
|
||||
@ -66,8 +66,12 @@ func (this HelmCommand) ChartInstall(data HelmChart) (string, error) {
|
||||
msg = fmt.Sprintf("%s --version %s", msg, data.Version)
|
||||
}
|
||||
|
||||
if data.FileValues != "" {
|
||||
fic := filepath.Join(data.Workspace, data.FileValues)
|
||||
for key, value := range data.Values {
|
||||
msg = fmt.Sprintf("%s --set %s=%s", msg, key, value)
|
||||
}
|
||||
|
||||
for _, valuefilename := range data.FileValues {
|
||||
fic := filepath.Join(data.Workspace, valuefilename)
|
||||
if _, err := os.Stat(fic); err != nil {
|
||||
log.Log().Warn().Msg(fic)
|
||||
} else {
|
||||
|
@ -92,8 +92,6 @@ func (this *InstallClass) ChartRepo() (error) {
|
||||
|
||||
|
||||
func (this *InstallClass) InstallCharts(modules []string) (error) {
|
||||
// helm_bin, _ := this.getToolBin("helm")
|
||||
// kubectl_bin, _ := this.getToolBin("kubectl")
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
|
@ -8,12 +8,16 @@ opencloud:
|
||||
- name: wordpress
|
||||
chart: bitnami/wordpress
|
||||
version: 23.1.0
|
||||
values: {}
|
||||
helm_values: []
|
||||
|
||||
- name: phpmyadmin
|
||||
chart: bitnami/phpmyadmin
|
||||
version: 17.0.4
|
||||
values: {}
|
||||
helm_values:
|
||||
VAR1: aaa
|
||||
helm_filevalues:
|
||||
- values-global.yml
|
||||
- values-phpmyadmin.yml
|
||||
|
||||
- charts:
|
||||
- name: myfirstrelease
|
||||
|
Loading…
Reference in New Issue
Block a user