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
/
v1beta2tov1.go
69 lines (60 loc) · 2.37 KB
/
v1beta2tov1.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
package migrate
import (
"github.com/caos/orbos/internal/operator/boom/api/latest"
"github.com/caos/orbos/internal/operator/boom/api/v1beta2"
"github.com/caos/orbos/internal/secret"
)
func V1beta2Tov1(oldToolset *v1beta2.Toolset) (newToolset *latest.Toolset, secrets map[string]*secret.Secret) {
defer func() {
secrets = latest.GetSecretsMap(newToolset)
}()
newToolset = &latest.Toolset{
APIVersion: "boom.caos.ch/v1",
Metadata: &latest.Metadata{
Name: oldToolset.Metadata.Name,
Namespace: oldToolset.Metadata.Namespace,
},
Kind: "Toolset",
Spec: &latest.ToolsetSpec{
Boom: oldToolset.Spec.Boom,
ForceApply: oldToolset.Spec.ForceApply,
CurrentStateFolder: oldToolset.Spec.CurrentStateFolder,
PreApply: oldToolset.Spec.PreApply,
PostApply: oldToolset.Spec.PostApply,
MetricCollection: oldToolset.Spec.MetricCollection,
// LogCollection: oldToolset.Spec.LogCollection,
NodeMetricsExporter: oldToolset.Spec.NodeMetricsExporter,
SystemdMetricsExporter: oldToolset.Spec.SystemdMetricsExporter,
Monitoring: oldToolset.Spec.Monitoring,
APIGateway: oldToolset.Spec.APIGateway,
KubeMetricsExporter: oldToolset.Spec.KubeMetricsExporter,
Reconciling: oldToolset.Spec.Reconciling,
MetricsPersisting: oldToolset.Spec.MetricsPersisting,
LogsPersisting: oldToolset.Spec.LogsPersisting,
MetricsServer: oldToolset.Spec.MetricsServer,
},
}
if oldToolset.Spec.LogCollection == nil {
return newToolset, nil
}
newToolset.Spec.LogCollection = &latest.LogCollection{
Deploy: oldToolset.Spec.LogCollection.Deploy,
}
if oldToolset.Spec.LogCollection.FluentdPVC != nil {
if newToolset.Spec.LogCollection.Fluentd == nil {
newToolset.Spec.LogCollection.Fluentd = &latest.Fluentd{}
}
newToolset.Spec.LogCollection.Fluentd.PVC = oldToolset.Spec.LogCollection.FluentdPVC
}
if oldToolset.Spec.LogCollection.Resources == nil &&
oldToolset.Spec.LogCollection.Tolerations == nil &&
oldToolset.Spec.LogCollection.NodeSelector == nil {
return newToolset, nil
}
newToolset.Spec.LogCollection.Operator = &latest.Component{
NodeSelector: oldToolset.Spec.LogCollection.NodeSelector,
Tolerations: oldToolset.Spec.LogCollection.Tolerations,
Resources: oldToolset.Spec.LogCollection.Resources,
}
return newToolset, nil
}