generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
93 lines (76 loc) · 2.58 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
/*
SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and pod-reloader-cop contributors
SPDX-License-Identifier: Apache-2.0
*/
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
"github.com/sap/component-operator-runtime/pkg/component"
componentoperatorruntimetypes "github.com/sap/component-operator-runtime/pkg/types"
)
// PodReloaderSpec defines the desired state of PodReloader.
type PodReloaderSpec struct {
component.Spec `json:",inline"`
// +kubebuilder:validation:Minimum=1
// +kubebuilder:default=1
ReplicaCount int `json:"replicaCount,omitempty"`
// +optional
Image component.ImageSpec `json:"image"`
component.KubernetesProperties `json:",inline"`
ObjectSelector *metav1.LabelSelector `json:"objectSelector,omitempty"`
NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty"`
}
// PodReloaderStatus defines the observed state of PodReloader.
type PodReloaderStatus struct {
component.Status `json:",inline"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +genclient
// PodReloader is the Schema for the podreloaders API.
type PodReloader struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec PodReloaderSpec `json:"spec,omitempty"`
// +kubebuilder:default={"observedGeneration":-1}
Status PodReloaderStatus `json:"status,omitempty"`
}
var _ component.Component = &PodReloader{}
// +kubebuilder:object:root=true
// PodReloaderList contains a list of PodReloader.
type PodReloaderList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []PodReloader `json:"items"`
}
func (s *PodReloaderSpec) ToUnstructured() map[string]any {
result, err := runtime.DefaultUnstructuredConverter.ToUnstructured(s)
if err != nil {
panic(err)
}
return result
}
func (c *PodReloader) GetDeploymentNamespace() string {
if c.Spec.Namespace != "" {
return c.Spec.Namespace
}
return c.Namespace
}
func (c *PodReloader) GetDeploymentName() string {
if c.Spec.Name != "" {
return c.Spec.Name
}
return c.Name
}
func (c *PodReloader) GetSpec() componentoperatorruntimetypes.Unstructurable {
return &c.Spec
}
func (c *PodReloader) GetStatus() *component.Status {
return &c.Status.Status
}
func init() {
SchemeBuilder.Register(&PodReloader{}, &PodReloaderList{})
}