/
clusterreport_types.go
136 lines (108 loc) · 4.23 KB
/
clusterreport_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
/*
Copyright 2022. 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"
)
// HelmAction represents the type of action on a give resource or helm release
type HelmAction string
// Define the HelmAction constants.
const (
NoHelmAction HelmAction = "No Action"
InstallHelmAction HelmAction = "Install"
UpgradeHelmAction HelmAction = "Upgrade"
UninstallHelmAction HelmAction = "Delete"
ConflictHelmAction HelmAction = "Conflict"
)
type ResourceAction string
// Define the Action constants.
const (
NoResourceAction ResourceAction = "No Action"
CreateResourceAction ResourceAction = "Create"
UpdateResourceAction ResourceAction = "Update"
DeleteResourceAction ResourceAction = "Delete"
ConflictResourceAction ResourceAction = "Conflict"
)
type ReleaseReport struct {
// ReleaseName of the release deployed in the CAPI Cluster.
// +kubebuilder:validation:MinLength=1
ReleaseName string `json:"chartName"`
// Namespace where release is deployed in the CAPI Cluster.
// +kubebuilder:validation:MinLength=1
ReleaseNamespace string `json:"releaseNamespace"`
// ChartVersion is the version of the helm chart deployed
// in the CAPI Cluster.
ChartVersion string `json:"chartVersion"`
// Action represent the type of operation on the Helm Chart
// +kubebuilder:validation:Enum=No Action;Install;Upgrade;Delete;Conflict
// +optional
Action string `json:"action,omitempty"`
// Message is for any message that needs to added to better
// explain the action.
// +optional
Message string `json:"message,omitempty"`
}
type ResourceReport struct {
// Resource contains information about Kubernetes Resource
Resource Resource `json:"resource"`
// Action represent the type of operation on the Kubernetes resource.
// +kubebuilder:validation:Enum=No Action;Create;Update;Delete;Conflict
Action string `json:"action,omitempty"`
// Message is for any message that needs to added to better
// explain the action.
// +optional
Message string `json:"message,omitempty"`
}
// ClusterReportSpec defines the desired state of ClusterReport
type ClusterReportSpec struct {
// ClusterNamespace is the namespace of the CAPI Cluster this
// ClusterReport is for.
ClusterNamespace string `json:"clusterNamespace"`
// ClusterName is the name of the CAPI Cluster this ClusterReport
// is for.
ClusterName string `json:"clusterName"`
}
// ClusterReportStatus defines the observed state of ClusterReport
type ClusterReportStatus struct {
// ReleaseReports contains report on helm releases
// +optional
ReleaseReports []ReleaseReport `json:"releaseReports,omitempty"`
// ResourceReports contains report on Kubernetes resources
// deployed because of PolicyRefs
// +optional
ResourceReports []ResourceReport `json:"resourceReports,omitempty"`
// KustomizeResourceReports contains report on Kubernetes resources
// deployed because of KustomizationRefs
// +optional
KustomizeResourceReports []ResourceReport `json:"kustomizeResourceReports,omitempty"`
}
//+kubebuilder:object:root=true
//+kubebuilder:resource:path=clusterreports,scope=Namespaced
//+kubebuilder:subresource:status
// ClusterReport is the Schema for the clusterreports API
type ClusterReport struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ClusterReportSpec `json:"spec,omitempty"`
Status ClusterReportStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// ClusterReportList contains a list of ClusterReport
type ClusterReportList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ClusterReport `json:"items"`
}
func init() {
SchemeBuilder.Register(&ClusterReport{}, &ClusterReportList{})
}