forked from kyma-project/kyma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prometheus.go
77 lines (59 loc) · 2.21 KB
/
prometheus.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
package steps
import (
"log"
"path"
"strings"
"github.com/kyma-project/kyma/components/installer/pkg/config"
"github.com/kyma-project/kyma/components/installer/pkg/consts"
)
//InstallPrometheus .
func (steps *InstallationSteps) InstallPrometheus(installationData *config.InstallationData) error {
const stepName string = "Installing Prometheus operator"
const namespace = "kyma-system"
chartDir := path.Join(steps.chartDir, consts.PrometheusComponent)
overrides := steps.getPrometheusOverrides(installationData, chartDir)
steps.PrintInstallationStep(stepName)
steps.statusManager.InProgress(stepName)
installResp, installErr := steps.helmClient.InstallRelease(
chartDir,
namespace,
consts.PrometheusComponent,
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
}
//UpdatePrometheus .
func (steps *InstallationSteps) UpdatePrometheus(installationData *config.InstallationData) error {
const stepName string = "Updating Prometheus operator"
const namespace = "kyma-system"
chartDir := path.Join(steps.chartDir, consts.PrometheusComponent)
overrides := steps.getPrometheusOverrides(installationData, chartDir)
steps.PrintInstallationStep(stepName)
steps.statusManager.InProgress(stepName)
upgradeResp, upgradeErr := steps.helmClient.UpgradeRelease(
chartDir,
consts.PrometheusComponent,
overrides)
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) getPrometheusOverrides(installationData *config.InstallationData, chartDir string) string {
var allOverrides []string
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")
}