generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
142 lines (116 loc) · 3.42 KB
/
types.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and component-operator-runtime contributors
SPDX-License-Identifier: Apache-2.0
*/
package helm
import (
"encoding/json"
"fmt"
)
// +kubebuilder:object:generate=true
type ChartMetadata struct {
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
Type string `json:"type,omitempty"`
AppVersion string `json:"appVersion,omitempty"`
Dependencies []ChartDependency `json:"dependencies,omitempty"`
}
const (
ChartTypeApplication = "application"
ChartTypeLibrary = "library"
)
// +kubebuilder:object:generate=true
type ChartDependency struct {
Name string `json:"name,omitempty"`
Alias string `json:"alias,omitempty"`
Condition string `json:"condition,omitempty"`
Tags []string `json:"tags,omitempty"`
ImportValues []ChartImportValue `json:"import-values,omitempty"`
}
// +kubebuilder:object:generate=true
type ChartImportValue struct {
Child string `json:"child"`
Parent string `json:"parent"`
}
func (v *ChartImportValue) UnmarshalJSON(b []byte) error {
if len(b) > 0 && b[0] == '"' {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
v.Child = fmt.Sprintf("exports.%s", s)
} else {
type chartImportValue ChartImportValue
w := chartImportValue(*v)
if err := json.Unmarshal(b, &w); err != nil {
return err
}
*v = ChartImportValue(w)
}
return nil
}
// +kubebuilder:object:generate=true
type Template struct {
Name string `json:"name,omitempty"`
BasePath string `json:"basePath,omitempty"`
}
// +kubebuilder:object:generate=true
type Release struct {
Namespace string `json:"namespace,omitempty"`
Name string `json:"name,omitempty"`
Service string `json:"service,omitempty"`
IsInstall bool `json:"isInstall,omitempty"`
IsUpgrade bool `json:"isUpgrade,omitempty"`
}
// +kubebuilder:object:generate=true
type Capabilities struct {
KubeVersion KubeVersion `json:"kubeVersion,omitempty"`
APIVersions ApiVersions `json:"apiVersions,omitempty"`
}
// +kubebuilder:object:generate=true
type KubeVersion struct {
Version string `json:"version,omitempty"`
Major string `json:"major,omitempty"`
Minor string `json:"minor,omitempty"`
// GitVersion is actually deprecated, but some charts still use it
GitVersion string `json:"gitVersion,omitempty"`
}
func (kubeVersion *KubeVersion) String() string {
return kubeVersion.Version
}
// +kubebuilder:object:generate=true
type ApiVersions []string
func (apiVersions ApiVersions) Has(version string) bool {
for _, v := range apiVersions {
if v == version {
return true
}
}
return false
}
type HookMetadata struct {
Types []string
Weight int
DeletePolicies []string
}
const (
HookTypePreInstall = "pre-install"
HookTypePostInstall = "post-install"
HookTypePreUpgrade = "pre-upgrade"
HookTypePostUpgrade = "post-upgrade"
HookTypePreDelete = "pre-delete"
HookTypePostDelete = "post-delete"
HookTypePreRollback = "pre-rollback"
HookTypePostRollback = "post-rollback"
HookTypeTest = "test"
HookTypeTestSuccess = "test-success"
)
const (
HookMinWeight = -100
HookMaxWeight = 100
)
const (
HookDeletePolicyBeforeHookCreation = "before-hook-creation"
HookDeletePolicyHookSucceeded = "hook-succeeded"
HookDeletePolicyHookFailed = "hook-failed"
)