Skip to content

Commit 3180604

Browse files
astefanuttiopenshift-merge-robot
authored andcommitted
Generate CodeFlare API client
1 parent 360e01f commit 3180604

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3364
-93
lines changed

Makefile

+60
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,38 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
125125
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
126126
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
127127

128+
.PHONY: generate-client ## Generate client packages
129+
generate-client: code-generator
130+
rm -rf client
131+
$(APPLYCONFIGURATION_GEN) \
132+
--input-dirs="github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" \
133+
--go-header-file="hack/boilerplate.go.txt" \
134+
--output-package="github.com/project-codeflare/codeflare-operator/client/applyconfiguration" \
135+
--trim-path-prefix "github.com/project-codeflare/codeflare-operator"
136+
$(CLIENT_GEN) \
137+
--input="codeflare/v1alpha1" \
138+
--input-base="github.com/project-codeflare/codeflare-operator/api" \
139+
--apply-configuration-package="github.com/project-codeflare/codeflare-operator/client/applyconfiguration" \
140+
--go-header-file="hack/boilerplate.go.txt" \
141+
--clientset-name "versioned" \
142+
--output-package="github.com/project-codeflare/codeflare-operator/client/clientset" \
143+
--output-base="." \
144+
--trim-path-prefix "github.com/project-codeflare/codeflare-operator"
145+
$(LISTER_GEN) \
146+
--input-dirs="github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" \
147+
--go-header-file="hack/boilerplate.go.txt" \
148+
--output-base="." \
149+
--output-package="github.com/project-codeflare/codeflare-operator/client/listers" \
150+
--trim-path-prefix "github.com/project-codeflare/codeflare-operator"
151+
$(INFORMER_GEN) \
152+
--input-dirs="github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" \
153+
--versioned-clientset-package="github.com/project-codeflare/codeflare-operator/client/clientset/versioned" \
154+
--listers-package="github.com/project-codeflare/codeflare-operator/client/listers" \
155+
--go-header-file="hack/boilerplate.go.txt" \
156+
--output-base="." \
157+
--output-package="github.com/project-codeflare/codeflare-operator/client/informer" \
158+
--trim-path-prefix "github.com/project-codeflare/codeflare-operator"
159+
128160
.PHONY: fmt
129161
fmt: ## Run go fmt against code.
130162
go fmt ./...
@@ -185,13 +217,18 @@ $(LOCALBIN):
185217

186218
## Tool Binaries
187219
KUSTOMIZE ?= $(LOCALBIN)/kustomize
220+
APPLYCONFIGURATION_GEN ?= $(LOCALBIN)/applyconfiguration-gen
221+
CLIENT_GEN ?= $(LOCALBIN)/client-gen
222+
LISTER_GEN ?= $(LOCALBIN)/lister-gen
223+
INFORMER_GEN ?= $(LOCALBIN)/informer-gen
188224
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
189225
ENVTEST ?= $(LOCALBIN)/setup-envtest
190226
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
191227
GH_CLI ?= $(LOCALBIN)/gh
192228

193229
## Tool Versions
194230
KUSTOMIZE_VERSION ?= v4.5.4
231+
CODEGEN_VERSION ?= v0.27.2
195232
CONTROLLER_TOOLS_VERSION ?= v0.9.2
196233
OPERATOR_SDK_VERSION ?= v1.27.0
197234
GH_CLI_VERSION ?= 2.30.0
@@ -213,6 +250,29 @@ $(GH_CLI): $(LOCALBIN)
213250
rm -rf $(GH_CLI_DL_FILENAME)
214251
rm $(GH_CLI_DL_FILENAME).tar.gz
215252

253+
.PHONY: code-generator
254+
code-generator: $(APPLYCONFIGURATION_GEN) $(CLIENT_GEN) $(LISTER_GEN) $(INFORMER_GEN)
255+
256+
.PHONY: applyconfiguration-gen
257+
applyconfiguration-gen: $(APPLYCONFIGURATION_GEN)
258+
$(APPLYCONFIGURATION_GEN): $(LOCALBIN)
259+
test -s $(LOCALBIN)/applyconfiguration-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/applyconfiguration-gen@$(CODEGEN_VERSION)
260+
261+
.PHONY: client-gen
262+
client-gen: $(CLIENT_GEN)
263+
$(CLIENT_GEN): $(LOCALBIN)
264+
test -s $(LOCALBIN)/client-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/client-gen@$(CODEGEN_VERSION)
265+
266+
.PHONY: lister-gen
267+
lister-gen: $(LISTER_GEN)
268+
$(LISTER_GEN): $(LOCALBIN)
269+
test -s $(LOCALBIN)/lister-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/lister-gen@$(CODEGEN_VERSION)
270+
271+
.PHONY: informer-gen
272+
informer-gen: $(INFORMER_GEN)
273+
$(INFORMER_GEN): $(LOCALBIN)
274+
test -s $(LOCALBIN)/informer-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/informer-gen@$(CODEGEN_VERSION)
275+
216276
.PHONY: controller-gen
217277
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
218278
$(CONTROLLER_GEN): $(LOCALBIN)

api/v1alpha1/groupversion_info.go api/codeflare/v1alpha1/doc.go

+2-17
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,8 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// Package v1alpha1 contains API Schema definitions for the codeflare v1alpha1 API group
17+
// +k8s:deepcopy-gen=package,register
1818
// +kubebuilder:object:generate=true
1919
// +groupName=codeflare.codeflare.dev
20-
package v1alpha1
21-
22-
import (
23-
"k8s.io/apimachinery/pkg/runtime/schema"
24-
"sigs.k8s.io/controller-runtime/pkg/scheme"
25-
)
26-
27-
var (
28-
// GroupVersion is group version used to register these objects
29-
GroupVersion = schema.GroupVersion{Group: "codeflare.codeflare.dev", Version: "v1alpha1"}
3020

31-
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
32-
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33-
34-
// AddToScheme adds the types in this group-version to the given scheme.
35-
AddToScheme = SchemeBuilder.AddToScheme
36-
)
21+
package v1alpha1

api/v1alpha1/instascale_types.go api/codeflare/v1alpha1/instascale_types.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ type InstaScaleStatus struct {
5959
Ready bool `json:"ready"`
6060
}
6161

62+
// +genclient
6263
// +kubebuilder:object:root=true
6364
// +kubebuilder:subresource:status
6465

@@ -80,7 +81,3 @@ type InstaScaleList struct {
8081
metav1.ListMeta `json:"metadata,omitempty"`
8182
Items []InstaScale `json:"items"`
8283
}
83-
84-
func init() {
85-
SchemeBuilder.Register(&InstaScale{}, &InstaScaleList{})
86-
}

api/v1alpha1/mcad_types.go api/codeflare/v1alpha1/mcad_types.go

+5-8
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type MCADSpec struct {
4848
// PodCreationTimeout determines timeout in milliseconds for pods to be created after dispatching job.
4949
// +kubebuilder:default=-1
5050
PodCreationTimeout int `json:"podCreationTimeout,omitempty"`
51-
//podCreationTimeout: //int (default blank)
51+
// podCreationTimeout: //int (default blank)
5252

5353
// ControllerResources defines the cpu and memory resource requirements for the MCAD Controller
5454
// +kubebuilder:default={}
@@ -63,8 +63,9 @@ type MCADStatus struct {
6363
Ready bool `json:"ready"`
6464
}
6565

66-
//+kubebuilder:object:root=true
67-
//+kubebuilder:subresource:status
66+
// +genclient
67+
// +kubebuilder:object:root=true
68+
// +kubebuilder:subresource:status
6869

6970
// MCAD is the Schema for the mcads API
7071
type MCAD struct {
@@ -75,15 +76,11 @@ type MCAD struct {
7576
Status MCADStatus `json:"status,omitempty"`
7677
}
7778

78-
//+kubebuilder:object:root=true
79+
// +kubebuilder:object:root=true
7980

8081
// MCADList contains a list of MCAD
8182
type MCADList struct {
8283
metav1.TypeMeta `json:",inline"`
8384
metav1.ListMeta `json:"metadata,omitempty"`
8485
Items []MCAD `json:"items"`
8586
}
86-
87-
func init() {
88-
SchemeBuilder.Register(&MCAD{}, &MCADList{})
89-
}

api/codeflare/v1alpha1/register.go

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
Copyright 2023.
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 v1alpha1
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+
25+
// Kind takes an unqualified kind and returns back a Group qualified GroupKind.
26+
func Kind(kind string) schema.GroupKind {
27+
return SchemeGroupVersion.WithKind(kind).GroupKind()
28+
}
29+
30+
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
31+
func Resource(resource string) schema.GroupResource {
32+
return SchemeGroupVersion.WithResource(resource).GroupResource()
33+
}
34+
35+
var (
36+
SchemeGroupVersion = schema.GroupVersion{Group: "codeflare.codeflare.dev", Version: "v1alpha1"}
37+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
38+
AddToScheme = SchemeBuilder.AddToScheme
39+
)
40+
41+
// Adds the list of known types to Scheme.
42+
func addKnownTypes(scheme *runtime.Scheme) error {
43+
scheme.AddKnownTypes(SchemeGroupVersion,
44+
&MCAD{},
45+
&MCADList{},
46+
&InstaScale{},
47+
&InstaScaleList{},
48+
)
49+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
50+
return nil
51+
}

api/v1alpha1/zz_generated.deepcopy.go api/codeflare/v1alpha1/zz_generated.deepcopy.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)