This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
helm.go
79 lines (64 loc) · 2.57 KB
/
helm.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 ambassador
import (
toolsetsv1beta2 "github.com/caos/orbos/internal/operator/boom/api/v1beta2"
argocdnet "github.com/caos/orbos/internal/operator/boom/application/applications/argocd/network"
grafananet "github.com/caos/orbos/internal/operator/boom/application/applications/grafana/network"
"github.com/caos/orbos/internal/utils/helper"
"github.com/caos/orbos/mntr"
"github.com/caos/orbos/internal/operator/boom/application/applications/ambassador/crds"
"github.com/caos/orbos/internal/operator/boom/application/applications/ambassador/helm"
"github.com/caos/orbos/internal/operator/boom/templator/helm/chart"
)
func (a *Ambassador) HelmPreApplySteps(monitor mntr.Monitor, toolsetCRDSpec *toolsetsv1beta2.ToolsetSpec) ([]interface{}, error) {
ret := make([]interface{}, 0)
if toolsetCRDSpec.Reconciling.Network != nil {
host := crds.GetHostFromConfig(argocdnet.GetHostConfig(toolsetCRDSpec.Reconciling.Network))
ret = append(ret, host)
mapping := crds.GetMappingFromConfig(argocdnet.GetMappingConfig(toolsetCRDSpec.Reconciling.Network))
ret = append(ret, mapping)
}
if toolsetCRDSpec.Monitoring.Network != nil {
host := crds.GetHostFromConfig(grafananet.GetHostConfig(toolsetCRDSpec.Monitoring.Network))
ret = append(ret, host)
mapping := crds.GetMappingFromConfig(grafananet.GetMappingConfig(toolsetCRDSpec.Monitoring.Network))
ret = append(ret, mapping)
}
return ret, nil
}
func (a *Ambassador) HelmMutate(monitor mntr.Monitor, toolsetCRDSpec *toolsetsv1beta2.ToolsetSpec, resultFilePath string) error {
if err := helper.DeleteFirstResourceFromYaml(resultFilePath, "v1", "Pod", "ambassador-test-ready"); err != nil {
return err
}
return nil
}
func (a *Ambassador) SpecToHelmValues(monitor mntr.Monitor, toolsetCRDSpec *toolsetsv1beta2.ToolsetSpec) interface{} {
spec := toolsetCRDSpec.APIGateway
imageTags := helm.GetImageTags()
values := helm.DefaultValues(imageTags)
if spec.ReplicaCount != 0 {
values.ReplicaCount = spec.ReplicaCount
}
if spec.Service != nil {
values.Service.Type = spec.Service.Type
values.Service.LoadBalancerIP = spec.Service.LoadBalancerIP
if spec.Service.Ports != nil {
ports := make([]*helm.Port, 0)
for _, v := range spec.Service.Ports {
ports = append(ports, &helm.Port{
Name: v.Name,
Port: v.Port,
TargetPort: v.TargetPort,
NodePort: v.NodePort,
})
}
values.Service.Ports = ports
}
}
return values
}
func (a *Ambassador) GetChartInfo() *chart.Chart {
return helm.GetChartInfo()
}
func (a *Ambassador) GetImageTags() map[string]string {
return helm.GetImageTags()
}