This commit is contained in:
admju
2024-09-09 14:17:02 +00:00
parent 550675a4aa
commit 13025746e6
32 changed files with 1597 additions and 664 deletions

View File

@@ -22,7 +22,8 @@ type InstallClass struct {
toolsBin map[string]string
charts []chart.ChartRepoData
commandHelm helm.HelmCommandInterface
commandHelm helm.HelmCommand
commandKubectl kubectl.KubectlCommand
}
func (this *InstallClass) NewInstall() (string, error) {
@@ -91,8 +92,8 @@ func (this *InstallClass) ChartRepo() (error) {
func (this *InstallClass) InstallCharts(modules []string) (error) {
helm_bin, _ := this.getToolBin("helm")
kubectl_bin, _ := this.getToolBin("kubectl")
// helm_bin, _ := this.getToolBin("helm")
// kubectl_bin, _ := this.getToolBin("kubectl")
var wg sync.WaitGroup
@@ -103,7 +104,7 @@ func (this *InstallClass) InstallCharts(modules []string) (error) {
go func() {
defer wg.Done()
this.installChart(helm_bin, kubectl_bin, v1)
this.installChart(v1)
} ()
}
}
@@ -112,35 +113,32 @@ func (this *InstallClass) InstallCharts(modules []string) (error) {
return nil
}
func (this *InstallClass) installChart(helm_bin string, kubectl_bin string, chart chart.ChartData) {
func (this *InstallClass) installChart(chart chart.ChartData) {
log.Log().Info().Msg(fmt.Sprintf(" << Chart : %s ", chart.Name))
helmchart := helm.HelmChart{Bin: helm_bin,
Name: chart.Name,
Chart: chart.Chart,
Url: chart.Url,
Version: chart.Version,
Workspace: this.Workspace,
Opts: chart.Opts,
Values: chart.Values,
FileValues: chart.FileValues}
data := helm.HelmChart{Name: chart.Name,
Chart: chart.Chart,
Url: chart.Url,
Version: chart.Version,
Workspace: this.Workspace,
Opts: chart.Opts,
Values: chart.Values,
FileValues: chart.FileValues}
res, err := helmchart.Install()
res, err := this.commandHelm.ChartInstall(data)
if err != nil {
log.Log().Error().Msg(fmt.Sprintf(" >> %s %s (%s)", helmchart.Name, "KO", err))
log.Log().Error().Msg(fmt.Sprintf(" >> %s %s (%s)", data.Name, "KO", err))
return
}
log.Log().Info().Msg(fmt.Sprintf(" >> %s (%s)", helmchart.Name, res))
log.Log().Info().Msg(fmt.Sprintf(" >> %s (%s)", data.Name, res))
ressources, _ := helmchart.GetRessources()
ressources, _ := this.commandHelm.GetRessources(data)
for key, value := range ressources {
obj := kubectl.KubeObject{Bin: kubectl_bin,
Kind: value,
Name: key}
err := obj.Wait()
obj := kubectl.KubectlObject{Name: key, Kind: value}
err := this.commandKubectl.Wait(obj)
if err != nil {
log.Log().Error().Msg(fmt.Sprintf(" >> %s/%s KO (%s)", chart.Name, key, err))
} else {