-
Notifications
You must be signed in to change notification settings - Fork 104
/
types.go
87 lines (73 loc) · 3.32 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
package packages
import (
"github.com/kudobuilder/kudo/pkg/apis/kudo/v1beta1"
)
const (
APIVersion = "kudo.dev/v1beta1"
)
// This is an abstraction which abstracts the underlying packages, which is likely file system or compressed file.
// There should be a complete separation between retrieving a packages if not local and working with a packages.
// Package is an abstraction of the collection of files that makes up a package. It is anything we can retrieve the Resources from.
type Package struct {
// transformed server view
Resources *Resources
// working with local package files
Files *Files
}
// Resources is collection of CRDs that are used when installing operator
// during installation, package format is converted to this structure
type Resources struct {
Operator *v1beta1.Operator
OperatorVersion *v1beta1.OperatorVersion
Instance *v1beta1.Instance
}
// Modified v1beta1.Parameter that allows for defaults provided as YAML.
type Parameter struct {
DisplayName string `json:"displayName,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Required *bool `json:"required,omitempty"`
Default interface{} `json:"default,omitempty"`
Trigger string `json:"trigger,omitempty"`
Type v1beta1.ParameterType `json:"type,omitempty"`
}
type Parameters []Parameter
// Len returns the number of params.
// This is needed to allow sorting of params.
func (p Parameters) Len() int { return len(p) }
// Swap swaps the position of two items in the params slice.
// This is needed to allow sorting of params.
func (p Parameters) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
// Less returns true if the name of a param a is less than the name of param b.
// This is needed to allow sorting of params.
func (p Parameters) Less(x, y int) bool {
return p[x].Name < p[y].Name
}
// Templates is a map of file names and stringified files in the template folder of an operator
type Templates map[string]string
// Files represents the raw operator package format the way it is found in the tgz packages
type Files struct {
Templates Templates
Operator *OperatorFile
Params *ParamsFile
}
// ParamsFile is a representation of the package params.yaml
type ParamsFile struct {
APIVersion string `json:"apiVersion,omitempty"`
Parameters Parameters `json:"parameters"`
}
// OperatorFile is a representation of the package operator.yaml
type OperatorFile struct {
APIVersion string `json:"apiVersion,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
OperatorVersion string `json:"operatorVersion"`
AppVersion string `json:"appVersion,omitempty"`
KUDOVersion string `json:"kudoVersion,omitempty"`
KubernetesVersion string `json:"kubernetesVersion,omitempty"`
Maintainers []*v1beta1.Maintainer `json:"maintainers,omitempty"`
URL string `json:"url,omitempty"`
Tasks []v1beta1.Task `json:"tasks"`
Plans map[string]v1beta1.Plan `json:"plans"`
NamespaceManifest string `json:"namespaceManifest,omitempty"`
}