forked from kyma-project/kyma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster-essentials.go
79 lines (61 loc) · 2.55 KB
/
cluster-essentials.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
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"
)
// InstallClusterEssentials .
func (steps *InstallationSteps) InstallClusterEssentials(installationData *config.InstallationData) error {
const stepName string = "Installing cluster-essentials"
steps.PrintInstallationStep(stepName)
steps.statusManager.InProgress(stepName)
chartDir := path.Join(steps.chartDir, consts.ClusterEssentialsComponent)
clusterEssentialsOverrides := steps.getClusterEssentialsOverrides(installationData, chartDir)
installResp, installErr := steps.helmClient.InstallRelease(
chartDir,
"kyma-system",
consts.ClusterEssentialsComponent,
clusterEssentialsOverrides)
if steps.errorHandlers.CheckError("Install Error: ", installErr) {
steps.statusManager.Error(stepName)
return installErr
}
steps.helmClient.PrintRelease(installResp.Release)
log.Println(stepName + "...DONE")
return nil
}
// UpdateClusterEssentials .
func (steps *InstallationSteps) UpdateClusterEssentials(installationData *config.InstallationData) error {
const stepName string = "Updating cluster-essentials"
steps.PrintInstallationStep(stepName)
steps.statusManager.InProgress(stepName)
chartDir := path.Join(steps.chartDir, consts.ClusterEssentialsComponent)
clusterEssentailsOverrides := steps.getClusterEssentialsOverrides(installationData, chartDir)
upgradeResp, upgradeErr := steps.helmClient.UpgradeRelease(
chartDir,
consts.ClusterEssentialsComponent,
clusterEssentailsOverrides)
if steps.errorHandlers.CheckError("Upgrade Error: ", upgradeErr) {
steps.statusManager.Error(stepName)
return upgradeErr
}
steps.helmClient.PrintRelease(upgradeResp.Release)
log.Println(stepName + "...DONE")
return nil
}
func (steps *InstallationSteps) getClusterEssentialsOverrides(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)
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")
}