Skip to content

Commit 0893332

Browse files
author
Mengqi Yu
committed
🏃 use right markers
1 parent f39791e commit 0893332

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

examples/crd/pkg/doc.go renamed to examples/crd/pkg/groupversion_info.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,25 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// +kubebuilder:object:generate=true
18+
// +groupName=chaosapps.metamagical.io
1719
package pkg
1820

1921
import (
22+
"k8s.io/apimachinery/pkg/runtime/schema"
2023
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
2125
)
2226

23-
var log = logf.Log.WithName("chaospod-resource")
27+
var (
28+
log = logf.Log.WithName("chaospod-resource")
29+
30+
// SchemeGroupVersion is group version used to register these objects
31+
SchemeGroupVersion = schema.GroupVersion{Group: "chaosapps.metamagical.io", Version: "v1"}
32+
33+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
34+
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
35+
36+
// AddToScheme is required by pkg/client/...
37+
AddToScheme = SchemeBuilder.AddToScheme
38+
)

examples/crd/pkg/resource.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import (
2323
corev1 "k8s.io/api/core/v1"
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2525
"k8s.io/apimachinery/pkg/runtime"
26-
"k8s.io/apimachinery/pkg/runtime/schema"
27-
"sigs.k8s.io/controller-runtime/pkg/scheme"
2826
"sigs.k8s.io/controller-runtime/pkg/webhook"
2927
)
3028

@@ -41,12 +39,11 @@ type ChaosPodStatus struct {
4139
LastRun metav1.Time `json:"lastRun,omitempty"`
4240
}
4341

44-
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
42+
// +kubebuilder:object:root=true
4543

4644
// ChaosPod is the Schema for the randomjobs API
4745
// +kubebuilder:printcolumn:name="next stop",type="string",JSONPath=".spec.nextStop",format="date"
4846
// +kubebuilder:printcolumn:name="last run",type="string",JSONPath=".status.lastRun",format="date"
49-
// +k8s:openapi-gen=true
5047
type ChaosPod struct {
5148
metav1.TypeMeta `json:",inline"`
5249
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -55,7 +52,7 @@ type ChaosPod struct {
5552
Status ChaosPodStatus `json:"status,omitempty"`
5653
}
5754

58-
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
55+
// +kubebuilder:object:root=true
5956

6057
// ChaosPodList contains a list of ChaosPod
6158
type ChaosPodList struct {
@@ -106,14 +103,3 @@ func (c *ChaosPod) Default() {
106103
func init() {
107104
SchemeBuilder.Register(&ChaosPod{}, &ChaosPodList{})
108105
}
109-
110-
var (
111-
// SchemeGroupVersion is group version used to register these objects
112-
SchemeGroupVersion = schema.GroupVersion{Group: "chaosapps.metamagical.io", Version: "v1"}
113-
114-
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
115-
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
116-
117-
// AddToScheme is required by pkg/client/...
118-
AddToScheme = SchemeBuilder.AddToScheme
119-
)

0 commit comments

Comments
 (0)