-
Notifications
You must be signed in to change notification settings - Fork 6
/
resourcesummary_type.go
150 lines (114 loc) · 4.68 KB
/
resourcesummary_type.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
/*
Copyright 2022-23. projectsveltos.io. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
// ResourceSummaryFinalizer is finalizer added to ResourceSummary
ResourceSummaryFinalizer = "resourcesummaryfinalizer.projectsveltos.io"
ResourceSummaryKind = "ResourceSummary"
// ClusterSummaryNameLabel is added to all ResourceSummary instances
ClusterSummaryNameLabel = "projectsveltos.io/cluster-summary-name"
// ClusterSummaryNamespaceLabel is added to all ResourceSummary instances
ClusterSummaryNamespaceLabel = "projectsveltos.io/cluster-summary-namespace"
// ClusterSummaryTypeLabel is added to all ResourceSummary instances
ClusterSummaryTypeLabel = "projectsveltos.io/cluster-summary-type"
)
type Resource struct {
// Name of the resource deployed in the Cluster.
// +kubebuilder:validation:MinLength=1
Name string `json:"name"`
// Namespace of the resource deployed in the Cluster.
// Empty for resources scoped at cluster level.
// +optional
Namespace string `json:"namespace,omitempty"`
// Group of the resource deployed in the Cluster.
Group string `json:"group"`
// Kind of the resource deployed in the Cluster.
// +kubebuilder:validation:MinLength=1
Kind string `json:"kind"`
// Version of the resource deployed in the Cluster.
Version string `json:"version"`
}
type HelmResources struct {
// ChartName is the chart name
// +kubebuilder:validation:MinLength=1
ChartName string `json:"chartName"`
// ReleaseName is the chart release
// +kubebuilder:validation:MinLength=1
ReleaseName string `json:"releaseName"`
// ReleaseNamespace is the namespace release will be installed
// +kubebuilder:validation:MinLength=1
ReleaseNamespace string `json:"releaseNamespace"`
// Resources deployed by ClusterSummary because of helm charts
// +optional
Resources []Resource `json:"group,omitempty"`
}
type ResourceHash struct {
// Resource specifies a resource.
Resource `json:",inline"`
// Hash is the hash of a resource's data.
Hash string `json:"hash,omitempty"`
}
// ResourceSummarySpec defines the desired state of ResourceSummary
type ResourceSummarySpec struct {
// Resources deployed by ClusterSummary because of referenced ConfigMaps/Secrets
// +optional
Resources []Resource `json:"resources,omitempty"`
// KustomizeResources deployed by ClusterSummary because of referenced
// KustomizationRef
// +optional
KustomizeResources []Resource `json:"kustomizeResources,omitempty"`
// Resources deployed by ClusterSummary because of referenced Helm charts
// +optional
ChartResources []HelmResources `json:"chartResources,omitempty"`
}
// ResourceSummaryStatus defines the status of ResourceSummary
type ResourceSummaryStatus struct {
// Resources changed.
// +optional
ResourcesChanged bool `json:"resourcesChanged,omitempty"`
// KustomizeResources changed.
// +optional
KustomizeResourcesChanged bool `json:"kustomizeResourcesChanged,omitempty"`
// Helm Resources changed.
// +optional
HelmResourcesChanged bool `json:"helmResourcesChanged,omitempty"`
// ResourceHashes specifies a list of resource plus hash
ResourceHashes []ResourceHash `json:"resourceHashes,omitempty"`
// KustomizeResourceHashes specifies a list of resource plus hash
KustomizeResourceHashes []ResourceHash `json:"kustomizeResourceHashes,omitempty"`
// HelmResourceHashes specifies list of resource plus hash.
HelmResourceHashes []ResourceHash `json:"helmResourceHashes,omitempty"`
}
//+kubebuilder:object:root=true
//+kubebuilder:resource:path=resourcesummaries,scope=Namespaced
//+kubebuilder:subresource:status
// ResourceSummary is the Schema for the ResourceSummary API
type ResourceSummary struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ResourceSummarySpec `json:"spec,omitempty"`
Status ResourceSummaryStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// ResourceSummaryList contains a list of ResourceSummary
type ResourceSummaryList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ResourceSummary `json:"items"`
}
func init() {
SchemeBuilder.Register(&ResourceSummary{}, &ResourceSummaryList{})
}