/
types.go
199 lines (183 loc) · 7.18 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
// Copyright 2024 The Carvel Authors.
// SPDX-License-Identifier: Apache-2.0
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:subresource:status
// +kubebuilder:resource:categories={carvel}
// +kubebuilder:printcolumn:name=Description,JSONPath=.status.friendlyDescription,description=Friendly description,type=string
// +kubebuilder:printcolumn:name=Since-Deploy,JSONPath=.status.deploy.startedAt,description=Last time app started being deployed. Does not mean anything was changed.,type=date
// +kubebuilder:printcolumn:name=Age,JSONPath=.metadata.creationTimestamp,description=Time since creation,type=date
// +protobuf=false
// An App is a set of Kubernetes resources. These resources could span any number of namespaces or could be cluster-wide (e.g. CRDs). An App is represented in kapp-controller using a App CR.
// The App CR comprises of three main sections:
// spec.fetch – declare source for fetching configuration and OCI images
// spec.template – declare templating tool and values
// spec.deploy – declare deployment tool and any deploy specific configuration
type App struct {
metav1.TypeMeta `json:",inline"`
// Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata.
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec AppSpec `json:"spec"`
// +optional
Status AppStatus `json:"status,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +protobuf=false
type AppList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
Items []App `json:"items"`
}
// +k8s:openapi-gen=true
type AppSpec struct {
// Specifies that app should be deployed authenticated via
// given service account, found in this namespace (optional; v0.6.0+)
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty" protobuf:"bytes,1,opt,name=serviceAccountName"`
// Specifies that app should be deployed to destination cluster;
// by default, cluster is same as where this resource resides (optional; v0.5.0+)
// +optional
Cluster *AppCluster `json:"cluster,omitempty" protobuf:"bytes,2,opt,name=cluster"`
// +optional
Fetch []AppFetch `json:"fetch,omitempty" protobuf:"bytes,3,rep,name=fetch"`
// +optional
Template []AppTemplate `json:"template,omitempty" protobuf:"bytes,4,rep,name=template"`
// +optional
Deploy []AppDeploy `json:"deploy,omitempty" protobuf:"bytes,5,rep,name=deploy"`
// Pauses _future_ reconciliation; does _not_ affect
// currently running reconciliation (optional; default=false)
// +optional
Paused bool `json:"paused,omitempty" protobuf:"varint,6,opt,name=paused"`
// Cancels current and future reconciliations (optional; default=false)
// +optional
Canceled bool `json:"canceled,omitempty" protobuf:"varint,7,opt,name=canceled"`
// Specifies the length of time to wait, in time + unit
// format, before reconciling. Always >= 30s. If value below
// 30s is specified, 30s will be used. (optional; v0.9.0+; default=30s)
// +optional
SyncPeriod *metav1.Duration `json:"syncPeriod,omitempty" protobuf:"bytes,8,opt,name=syncPeriod"`
// Deletion requests for the App will result in the App CR being
// deleted, but its associated resources will not be deleted
// (optional; default=false; v0.18.0+)
// +optional
NoopDelete bool `json:"noopDelete,omitempty" protobuf:"varint,9,opt,name=noopDelete"`
// Specifies the default namespace to install the App resources, by default this is
// same as the App's namespace (optional; v0.48.0+)
// +optional
DefaultNamespace string `json:"defaultNamespace,omitempty" protobuf:"bytes,10,opt,name=defaultNamespace"`
}
// +k8s:openapi-gen=true
type AppCluster struct {
// Specifies namespace in destination cluster (optional)
// +optional
Namespace string `json:"namespace,omitempty" protobuf:"bytes,1,opt,name=namespace"`
// Specifies secret containing kubeconfig (required)
// +optional
KubeconfigSecretRef *AppClusterKubeconfigSecretRef `json:"kubeconfigSecretRef,omitempty" protobuf:"bytes,2,opt,name=kubeconfigSecretRef"`
}
// +k8s:openapi-gen=true
type AppClusterKubeconfigSecretRef struct {
// Specifies secret name within app's namespace (required)
// +optional
Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"`
// Specifies key that contains kubeconfig (optional)
// +optional
Key string `json:"key,omitempty" protobuf:"bytes,2,opt,name=key"`
}
// +protobuf=false
type AppStatus struct {
// +optional
ManagedAppName string `json:"managedAppName,omitempty"`
// +optional
Fetch *AppStatusFetch `json:"fetch,omitempty"`
// +optional
Template *AppStatusTemplate `json:"template,omitempty"`
// +optional
Deploy *AppStatusDeploy `json:"deploy,omitempty"`
// +optional
Inspect *AppStatusInspect `json:"inspect,omitempty"`
// +optional
ConsecutiveReconcileSuccesses int `json:"consecutiveReconcileSuccesses,omitempty"`
// +optional
ConsecutiveReconcileFailures int `json:"consecutiveReconcileFailures,omitempty"`
// +optional
GenericStatus `json:",inline"`
}
// +protobuf=false
type AppStatusFetch struct {
// +optional
Stderr string `json:"stderr,omitempty"`
// +optional
Stdout string `json:"stdout,omitempty"`
// +optional
ExitCode int `json:"exitCode"`
// +optional
Error string `json:"error,omitempty"`
// +optional
StartedAt metav1.Time `json:"startedAt,omitempty"`
// +optional
UpdatedAt metav1.Time `json:"updatedAt,omitempty"`
}
// +protobuf=false
type AppStatusTemplate struct {
// +optional
Stderr string `json:"stderr,omitempty"`
// +optional
ExitCode int `json:"exitCode"`
// +optional
Error string `json:"error,omitempty"`
// +optional
UpdatedAt metav1.Time `json:"updatedAt,omitempty"`
}
// +protobuf=false
type AppStatusDeploy struct {
// +optional
Stdout string `json:"stdout,omitempty"`
// +optional
Stderr string `json:"stderr,omitempty"`
// +optional
Finished bool `json:"finished"`
// +optional
ExitCode int `json:"exitCode"`
// +optional
Error string `json:"error,omitempty"`
// +optional
StartedAt metav1.Time `json:"startedAt,omitempty"`
// +optional
UpdatedAt metav1.Time `json:"updatedAt,omitempty"`
// +optional
KappDeployStatus *KappDeployStatus `json:"kapp,omitempty"`
}
// KappDeployStatus contains the associated AppCR deployed resources
// +protobuf=false
type KappDeployStatus struct {
AssociatedResources AssociatedResources `json:"associatedResources,omitempty"`
}
// AssociatedResources contains the associated App label, namespaces and GKs
// +protobuf=false
type AssociatedResources struct {
Label string `json:"label,omitempty"`
Namespaces []string `json:"namespaces,omitempty"`
GroupKinds []metav1.GroupKind `json:"groupKinds,omitempty"`
}
// +protobuf=false
type AppStatusInspect struct {
// +optional
Stdout string `json:"stdout,omitempty"`
// +optional
Stderr string `json:"stderr,omitempty"`
// +optional
ExitCode int `json:"exitCode"`
// +optional
Error string `json:"error,omitempty"`
// +optional
UpdatedAt metav1.Time `json:"updatedAt,omitempty"`
}