forked from kubernetes-sigs/controller-tools
/
toy_types.go
137 lines (104 loc) · 4.37 KB
/
toy_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
/*
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 (
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// ToyS3LogConfig defines logs configs using S3 backend
type ToyS3LogConfig struct {
// +kubebuilder:validation:MinLength=1
Bucket string `json:"bucket,omitempty"`
}
// ToySpec defines the desired state of Toy
type ToySpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// +kubebuilder:validation:Maximum=100
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:ExclusiveMinimum=true
Power float32 `json:"power,omitempty"`
Bricks int32 `json:"bricks,omitempty"`
// +kubebuilder:validation:MaxLength=15
// +kubebuilder:validation:MinLength=1
Name string `json:"name,omitempty"`
// This is a comment on an array field.
// +kubebuilder:validation:MaxItems=500
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:UniqueItems=false
Knights []string `json:"knights,omitempty"`
// This is a comment on a boolean field.
Winner bool `json:"winner,omitempty"`
// +kubebuilder:validation:Enum=Lion,Wolf,Dragon
Alias string `json:"alias,omitempty"`
// +kubebuilder:validation:Enum=1,2,3
Rank int `json:"rank"`
Comment []byte `json:"comment,omitempty"`
// This is a simple string without validation.
Description string `json:"description"`
// This is a comment on an object field.
Template v1.PodTemplateSpec `json:"template"`
Claim v1.PersistentVolumeClaim `json:"claim,omitempty"`
//This is a dummy comment.
// Just checking if the multi-line comments are working or not.
Replicas *int32 `json:"replicas"`
// This is a newly added field.
// Using this for testing purpose.
Rook *intstr.IntOrString `json:"rook"`
// Used this for testing fieldNames with number.
S3Log ToyS3LogConfig `json:"s3Log"`
// This is a comment on a map field.
Location map[string]string `json:"location"`
// This is an IPv4 address.
// +kubebuilder:validation:Format=ipv4
Address string `json:"address"`
// This is a list of IPv4 addresses.
// +kubebuilder:validation:Format=ipv4
Addresses []string `json:"addresses"`
}
// ToyStatus defines the observed state of Toy
type ToyStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
// It tracks the number of replicas.
Replicas int32 `json:"replicas"`
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Toy is the Schema for the toys API
// +k8s:openapi-gen=true
// +kubebuilder:subresource:status
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=
// +kubebuilder:printcolumn:name="toy",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description="descr1",format="date",priority=3
// +kubebuilder:printcolumn:name="abc",type="integer",JSONPath="status",description="descr2",format="int32",priority=1
// +kubebuilder:printcolumn:name="service",type="string",JSONPath=".status.conditions.ready",description="descr3",format="byte",priority=2
// +kubebuilder:resource:path=services,shortName=to;ty
// +kubebuilder:singular=toy
type Toy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ToySpec `json:"spec,omitempty"`
Status ToyStatus `json:"status,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ToyList contains a list of Toy
type ToyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Toy `json:"items"`
}
func init() {
SchemeBuilder.Register(&Toy{}, &ToyList{})
}