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