Skip to content

Commit f42b407

Browse files
stttsmjudeikis
andcommitted
Add exampledashed
Co-authored-by: Mangirdas Judeikis <Mangirdas@Judeikis.LT> On-behalf-of: SAP mangirdas.judeikis@sap.com Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
1 parent 5be9f2c commit f42b407

File tree

5 files changed

+174
-3
lines changed

5 files changed

+174
-3
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Copyright 2021 The KCP Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package exampledashed
18+
19+
const (
20+
// GroupName is the group name use in this package.
21+
GroupName = "example-dashed.some.corp"
22+
)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright 2022 The KCP Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package v1 contains API Schema definitions for the example-dashed.some.corp
18+
// v1 API group.
19+
//
20+
// +k8s:deepcopy-gen=package,register
21+
// +groupName=example-dashed.some.corp
22+
// +groupGoName=ExampleDashed
23+
package v1
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
Copyright 2021 The KCP Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
"k8s.io/apimachinery/pkg/runtime"
22+
"k8s.io/apimachinery/pkg/runtime/schema"
23+
24+
example "acme.corp/pkg/apis/exampledashed"
25+
)
26+
27+
// SchemeGroupVersion is group version used to register these objects.
28+
var SchemeGroupVersion = schema.GroupVersion{Group: example.GroupName, Version: "v1"}
29+
30+
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
31+
func Kind(kind string) schema.GroupKind {
32+
return SchemeGroupVersion.WithKind(kind).GroupKind()
33+
}
34+
35+
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
36+
func Resource(resource string) schema.GroupResource {
37+
return SchemeGroupVersion.WithResource(resource).GroupResource()
38+
}
39+
40+
var (
41+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
42+
AddToScheme = SchemeBuilder.AddToScheme
43+
)
44+
45+
// Adds the list of known types to Scheme.
46+
func addKnownTypes(scheme *runtime.Scheme) error {
47+
scheme.AddKnownTypes(SchemeGroupVersion,
48+
&TestType{},
49+
&TestTypeList{},
50+
&ClusterTestType{},
51+
&ClusterTestTypeList{},
52+
)
53+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
54+
return nil
55+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
Copyright 2022 The KCP Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
20+
21+
// +genclient
22+
// +genclient:noStatus
23+
// +genclient:method=CreateField,verb=create,subresource=field,input=acme.corp/pkg/apis/example/v1.Field,result=acme.corp/pkg/apis/example/v1.Field
24+
// +genclient:method=UpdateField,verb=update,subresource=field,input=acme.corp/pkg/apis/example/v1.Field,result=acme.corp/pkg/apis/example/v1.Field
25+
// +genclient:method=GetField,verb=get,subresource=field,result=acme.corp/pkg/apis/example/v1.Field
26+
// TestType is a top-level type. A client is created for it.
27+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
28+
type TestType struct {
29+
metav1.TypeMeta `json:",inline"`
30+
// +optional
31+
metav1.ObjectMeta `json:"metadata,omitempty"`
32+
// +optional
33+
APIGroups []string `json:"apiGroups,omitempty"`
34+
}
35+
36+
// TestTypeList is a top-level list type. The client methods for lists are automatically created.
37+
// You are not supposed to create a separated client for this one.
38+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
39+
type TestTypeList struct {
40+
metav1.TypeMeta `json:",inline"`
41+
metav1.ListMeta `json:"metadata"`
42+
Items []TestType `json:"items"`
43+
}
44+
45+
// +genclient
46+
// +genclient:nonNamespaced
47+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
48+
type ClusterTestType struct {
49+
metav1.TypeMeta `json:",inline"`
50+
// +optional
51+
metav1.ObjectMeta `json:"metadata,omitempty"`
52+
// ObjectKind is the type of resource being referenced
53+
ObjectKind string `json:"kind"`
54+
// ObjectName is the name of resource being referenced
55+
ObjectName string `json:"name"`
56+
// +optional
57+
Status ClusterTestTypeStatus `json:"status,omitempty"`
58+
}
59+
60+
type ClusterTestTypeStatus struct {
61+
Blah string `json:"blah,omitempty"`
62+
}
63+
64+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
65+
type ClusterTestTypeList struct {
66+
metav1.TypeMeta `json:",inline"`
67+
metav1.ListMeta `json:"metadata"`
68+
69+
Items []ClusterTestType `json:"items"`
70+
}

hack/update-codegen.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ ${KUBE_CLIENT_GEN} \
3939
--input example/v1beta1 \
4040
--input example/v2 \
4141
--input example3/v1 \
42+
--input exampledashed/v1 \
4243
--input secondexample/v1 \
4344
--input existinginterfaces/v1 \
4445
--output-dir ./pkg/generated/clientset \
@@ -48,21 +49,21 @@ ${KUBE_APPLYCONFIGURATION_GEN} \
4849
--go-header-file ./../hack/boilerplate/boilerplate.generatego.txt \
4950
--output-dir ./pkg/generated/applyconfigurations \
5051
--output-pkg acme.corp/pkg/generated/applyconfigurations \
51-
acme.corp/pkg/apis/example/v1 acme.corp/pkg/apis/example/v1alpha1 acme.corp/pkg/apis/example/v1beta1 acme.corp/pkg/apis/example/v2 acme.corp/pkg/apis/example3/v1 acme.corp/pkg/apis/secondexample/v1 acme.corp/pkg/apis/existinginterfaces/v1
52+
acme.corp/pkg/apis/example/v1 acme.corp/pkg/apis/example/v1alpha1 acme.corp/pkg/apis/example/v1beta1 acme.corp/pkg/apis/example/v2 acme.corp/pkg/apis/example3/v1 acme.corp/pkg/apis/exampledashed/v1 acme.corp/pkg/apis/secondexample/v1 acme.corp/pkg/apis/existinginterfaces/v1
5253

5354
${KUBE_LISTER_GEN} \
5455
--go-header-file ./../hack/boilerplate/boilerplate.generatego.txt \
5556
--output-dir ./pkg/generated/listers \
5657
--output-pkg acme.corp/pkg/generated/listers \
57-
acme.corp/pkg/apis/example/v1 acme.corp/pkg/apis/example/v1alpha1 acme.corp/pkg/apis/example/v1beta1 acme.corp/pkg/apis/example/v2 acme.corp/pkg/apis/example3/v1 acme.corp/pkg/apis/secondexample/v1 acme.corp/pkg/apis/existinginterfaces/v1
58+
acme.corp/pkg/apis/example/v1 acme.corp/pkg/apis/example/v1alpha1 acme.corp/pkg/apis/example/v1beta1 acme.corp/pkg/apis/example/v2 acme.corp/pkg/apis/example3/v1 acme.corp/pkg/apis/exampledashed/v1 acme.corp/pkg/apis/secondexample/v1 acme.corp/pkg/apis/existinginterfaces/v1
5859

5960
${KUBE_INFORMER_GEN} \
6061
--versioned-clientset-package acme.corp/pkg/generated/clientset/versioned \
6162
--listers-package acme.corp/pkg/generated/listers \
6263
--go-header-file ./../hack/boilerplate/boilerplate.generatego.txt \
6364
--output-dir ./pkg/generated/informers \
6465
--output-pkg acme.corp/pkg/generated/informers \
65-
acme.corp/pkg/apis/example/v1 acme.corp/pkg/apis/example/v1alpha1 acme.corp/pkg/apis/example/v1beta1 acme.corp/pkg/apis/example/v2 acme.corp/pkg/apis/example3/v1 acme.corp/pkg/apis/secondexample/v1 acme.corp/pkg/apis/existinginterfaces/v1
66+
acme.corp/pkg/apis/example/v1 acme.corp/pkg/apis/example/v1alpha1 acme.corp/pkg/apis/example/v1beta1 acme.corp/pkg/apis/example/v2 acme.corp/pkg/apis/example3/v1 acme.corp/pkg/apis/exampledashed/v1 acme.corp/pkg/apis/secondexample/v1 acme.corp/pkg/apis/existinginterfaces/v1
6667

6768
# Generate cluster-aware clients, informers and listers using generated single-cluster code
6869
./../bin/code-generator \

0 commit comments

Comments
 (0)