/
catalog_types.go
129 lines (115 loc) · 4.16 KB
/
catalog_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
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/giantswarm/k8smetadata/pkg/annotation"
)
const (
kindCatalog = "Catalog"
catalogDocumentationLink = "https://docs.giantswarm.io/ui-api/management-api/crd/catalogs.application.giantswarm.io/"
)
func NewCatalogTypeMeta() metav1.TypeMeta {
return metav1.TypeMeta{
APIVersion: SchemeGroupVersion.String(),
Kind: kindCatalog,
}
}
// NewCatalogCR returns an Catalog Custom Resource.
func NewCatalogCR() *Catalog {
return &Catalog{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
annotation.Docs: catalogDocumentationLink,
},
},
TypeMeta: NewCatalogTypeMeta(),
}
}
// +kubebuilder:printcolumn:name="Catalog URL",type=string,JSONPath=`.spec.storage.URL`,description="URL of the catalog"
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,description="Time since created"
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:categories=common;giantswarm
// +kubebuilder:storageversion
// +k8s:openapi-gen=true
// Catalog represents a catalog of managed apps. It stores general information for potential apps to install.
// It is reconciled by app-operator.
type Catalog struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec CatalogSpec `json:"spec"`
}
// +k8s:openapi-gen=true
type CatalogSpec struct {
// Title is the name of the catalog for this CR
// e.g. Catalog of Apps by Giant Swarm
Title string `json:"title"`
Description string `json:"description"`
// +kubebuilder:validation:Optional
// +nullable
// Config is the config to be applied when apps belonging to this
// catalog are deployed.
Config *CatalogSpecConfig `json:"config,omitempty"`
// LogoURL contains the links for logo image file for this catalog
LogoURL string `json:"logoURL"`
// Storage references an object defining catalog repository.
// This field is deprecated and replaced by Repositories.
Storage CatalogSpecStorage `json:"storage"`
// +kubebuilder:validation:MinItems=1
// Repositories is an array of objects defining catalog repositories.
Repositories []CatalogSpecRepository `json:"repositories"`
}
// +k8s:openapi-gen=true
type CatalogSpecConfig struct {
// +kubebuilder:validation:Optional
// +nullable
// ConfigMap references a config map containing catalog values that
// should be applied to apps in this catalog.
ConfigMap *CatalogSpecConfigConfigMap `json:"configMap,omitempty"`
// +kubebuilder:validation:Optional
// +nullable
// Secret references a secret containing catalog values that should be
// applied to apps in this catalog.
Secret *CatalogSpecConfigSecret `json:"secret,omitempty"`
}
// +k8s:openapi-gen=true
type CatalogSpecConfigConfigMap struct {
// Name is the name of the config map containing catalog values to
// apply, e.g. app-catalog-values.
Name string `json:"name"`
// Namespace is the namespace of the catalog values config map,
// e.g. giantswarm.
Namespace string `json:"namespace"`
}
// +k8s:openapi-gen=true
type CatalogSpecConfigSecret struct {
// Name is the name of the secret containing catalog values to apply,
// e.g. app-catalog-secret.
Name string `json:"name"`
// Namespace is the namespace of the secret,
// e.g. giantswarm.
Namespace string `json:"namespace"`
}
// +k8s:openapi-gen=true
type CatalogSpecStorage struct {
// Type indicates which repository type would be used for this Catalog.
// e.g. helm
Type string `json:"type"`
// URL is the link to where this Catalog's repository is located
// e.g. https://example.com/app-catalog/
URL string `json:"URL"`
}
// +k8s:openapi-gen=true
type CatalogSpecRepository struct {
// Type indicates which repository type would be used for this Catalog.
// e.g. helm
Type string `json:"type"`
// URL is the link to where this Catalog's repository is located
// e.g. https://example.com/app-catalog/
URL string `json:"URL"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type CatalogList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Catalog `json:"items"`
}