forked from kyma-project/kyma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathistio.go
84 lines (65 loc) · 2.57 KB
/
istio.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package steps
import (
"log"
"path"
"strings"
"github.com/kyma-project/kyma/components/installer/pkg/config"
"github.com/kyma-project/kyma/components/installer/pkg/consts"
"github.com/kyma-project/kyma/components/installer/pkg/overrides"
)
// InstallIstio .
func (steps *InstallationSteps) InstallIstio(installationData *config.InstallationData) error {
const stepName string = "Installing istio"
steps.PrintInstallationStep(stepName)
steps.statusManager.InProgress(stepName)
chartDir := path.Join(steps.chartDir, consts.IstioComponent, "istio")
overrides := steps.getIstioOverrides(installationData, chartDir)
//helm install
installResp, installErr := steps.helmClient.InstallReleaseWithoutWait(
chartDir,
"istio-system",
consts.IstioComponent,
overrides)
if steps.errorHandlers.CheckError("Install Error: ", installErr) {
steps.statusManager.Error(stepName)
return installErr
}
steps.helmClient.PrintRelease(installResp.Release)
log.Println(stepName + "...DONE")
return nil
}
// UpdateIstio .
func (steps *InstallationSteps) UpdateIstio(installationData *config.InstallationData) error {
const stepName string = "Updating istio"
steps.PrintInstallationStep(stepName)
steps.statusManager.InProgress(stepName)
chartDir := path.Join(steps.chartDir, consts.IstioComponent, "istio")
overrides := steps.getIstioOverrides(installationData, chartDir)
upgradeResp, upgradeErr := steps.helmClient.UpgradeRelease(
chartDir,
consts.IstioComponent,
overrides)
if steps.errorHandlers.CheckError("Upgrade Error: ", upgradeErr) {
steps.statusManager.Error("Updating istio")
return upgradeErr
}
steps.helmClient.PrintRelease(upgradeResp.Release)
log.Println(stepName + "...DONE")
return nil
}
func (steps *InstallationSteps) getIstioOverrides(installationData *config.InstallationData, chartDir string) string {
var allOverrides []string
globalOverrides, err := overrides.GetGlobalOverrides(installationData)
steps.errorHandlers.LogError("Couldn't get global overrides: ", err)
allOverrides = append(allOverrides, globalOverrides)
istioOverrides, err := overrides.GetIstioOverrides(installationData)
steps.errorHandlers.LogError("Couldn't get Istio overrides: ", err)
allOverrides = append(allOverrides, istioOverrides)
fileOverrides := steps.getStaticFileOverrides(installationData, chartDir)
if fileOverrides.HasOverrides() == true {
fileOverridesStr, err := fileOverrides.GetOverrides()
steps.errorHandlers.LogError("Couldn't get additional overrides: ", err)
allOverrides = append(allOverrides, *fileOverridesStr)
}
return strings.Join(allOverrides, "\n")
}