Skip to content

Commit d78eb63

Browse files
Merge pull request #533 from z103cb/z103cb-issue514
Generate MCAD clients using clientgen tools
2 parents 02a47dc + 630df6d commit d78eb63

File tree

66 files changed

+1212
-1943
lines changed

Some content is hidden

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

66 files changed

+1212
-1943
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
/output*/
2121
/_output*/
2222
/_output
23+
bin
2324

2425
# Emacs save files
2526
*~

Makefile

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ $(LOCALBIN):
1313

1414
## Tool Versions
1515
CONTROLLER_TOOLS_VERSION ?= v0.9.2
16+
CODEGEN_VERSION ?= v0.20.15
1617

1718
## Tool Binaries
1819
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
20+
APPLYCONFIGURATION_GEN ?= $(LOCALBIN)/applyconfiguration-gen
21+
CLIENT_GEN ?= $(LOCALBIN)/client-gen
22+
LISTER_GEN ?= $(LOCALBIN)/lister-gen
23+
INFORMER_GEN ?= $(LOCALBIN)/informer-gen
1924

2025
# Reset branch name if this a Travis CI environment
2126
ifneq ($(strip $(TRAVIS_BRANCH)),)
@@ -70,12 +75,81 @@ init:
7075
verify-tag-name: print-global-variables
7176
# Check for invalid tag name
7277
t=${TAG} && [ $${#t} -le 128 ] || { echo "Target name $$t has 128 or more chars"; false; }
78+
.PHONY: generate-client ## Generate client packages
79+
generate-client: code-generator
80+
rm -rf pkg/client/clientset/versioned pkg/client/informers/externalversions pkg/client/listers/controller/v1beta1 pkg/client/listers/quotasubtree/v1
81+
# TODO: add this back when the version of the tool has been updated and supports this executable
82+
# $(APPLYCONFIGURATION_GEN) \
83+
# --input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" \
84+
# --go-header-file="hack/boilerplate/boilerplate.go.txt" \
85+
# --output-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/applyconfiguration" \
86+
# --trim-path-prefix "github.com/project-codeflare/multi-cluster-app-dispatcher"
87+
$(CLIENT_GEN) \
88+
--input="pkg/apis/controller/v1beta1" \
89+
--input="pkg/apis/quotaplugins/quotasubtree/v1" \
90+
--input-base="github.com/project-codeflare/multi-cluster-app-dispatcher" \
91+
--go-header-file="hack/boilerplate/boilerplate.go.txt" \
92+
--clientset-name "versioned" \
93+
--output-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset" \
94+
--output-base="."
95+
# TODO: add the following line back once the tool has been upgraded
96+
# --trim-path-prefix "github.com/project-codeflare/multi-cluster-app-dispatcher"
97+
$(LISTER_GEN) \
98+
--input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" \
99+
--input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" \
100+
--go-header-file="hack/boilerplate/boilerplate.go.txt" \
101+
--output-base="." \
102+
--output-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers"
103+
# TODO: add the following line back once the tool has been upgraded
104+
# --trim-path-prefix "github.com/project-codeflare/multi-cluster-app-dispatcher"
105+
$(INFORMER_GEN) \
106+
--input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" \
107+
--input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" \
108+
--versioned-clientset-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" \
109+
--listers-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers" \
110+
--go-header-file="hack/boilerplate/boilerplate.go.txt" \
111+
--output-base="." \
112+
--output-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers"
113+
# TODO: add the following line back once the tool has been upgraded
114+
# --trim-path-prefix "github.com/project-codeflare/multi-cluster-app-dispatcher"
115+
# TODO: remove the following lines once the tool has been upgraded and they are no longer needed.
116+
# The `mv` and `rm` are necessary as the generators write to the gihub.com/... path.
117+
mv -f github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned pkg/client/clientset/versioned
118+
mv -f github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions pkg/client/informers/externalversions
119+
mv -f github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1beta1 pkg/client/listers/controller/v1beta1
120+
mv -f github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/quotasubtree/v1 pkg/client/listers/quotasubtree/v1
121+
rm -rf github.com
73122

74123
.PHONY: controller-gen
75124
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
76125
$(CONTROLLER_GEN): $(LOCALBIN)
77126
test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
78127

128+
.PHONY: code-generator
129+
#TODO: add $(APPLYCONFIGURATION_GEN) as a dependency when the tool is supported
130+
code-generator: $(CLIENT_GEN) $(LISTER_GEN) $(INFORMER_GEN) $(CONTROLLER_GEN)
131+
132+
# TODO: enable this target once the tools is supported
133+
#.PHONY: applyconfiguration-gen
134+
#applyconfiguration-gen: $(APPLYCONFIGURATION_GEN)
135+
#$(APPLYCONFIGURATION_GEN): $(LOCALBIN)
136+
# test -s $(LOCALBIN)/applyconfiguration-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/applyconfiguration-gen@$(CODEGEN_VERSION)
137+
138+
.PHONY: client-gen
139+
client-gen: $(CLIENT_GEN)
140+
$(CLIENT_GEN): $(LOCALBIN)
141+
test -s $(LOCALBIN)/client-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/client-gen@$(CODEGEN_VERSION)
142+
143+
.PHONY: lister-gen
144+
lister-gen: $(LISTER_GEN)
145+
$(LISTER_GEN): $(LOCALBIN)
146+
test -s $(LOCALBIN)/lister-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/lister-gen@$(CODEGEN_VERSION)
147+
148+
.PHONY: informer-gen
149+
informer-gen: $(INFORMER_GEN)
150+
$(INFORMER_GEN): $(LOCALBIN)
151+
test -s $(LOCALBIN)/informer-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/informer-gen@$(CODEGEN_VERSION)
152+
79153
.PHONY: manifests
80154
manifests: controller-gen ## Generate CustomResourceDefinition objects.
81155
$(CONTROLLER_GEN) crd:allowDangerousTypes=true paths="./pkg/apis/..." output:crd:artifacts:config=config/crd/bases

hack/boilerplate/boilerplate.go.txt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
/*
2-
Copyright YEAR The Kubernetes 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-
/*
172
Copyright 2019, 2021, 2022, YEAR The Multi-Cluster App Dispatcher Authors.
183

194
Licensed under the Apache License, Version 2.0 (the "License");

pkg/apis/controller/v1beta1/appwrapper.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const AppWrapperPlural string = "appwrappers"
2828
// which AppWrapper it belongs to.
2929
const AppWrapperAnnotationKey = "appwrapper.mcad.ibm.com/appwrapper-name"
3030

31+
// +genclient
3132
// +kubebuilder:object:root=true
3233
// +kubebuilder:subresource:status
3334
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

pkg/client/clientset/controller-versioned/clients/factory.go renamed to pkg/client/client_factory.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,19 @@
11
/*
2-
Copyright 2018 The Kubernetes Authors.
2+
Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
1212
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
/*
17-
Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors.
18-
19-
Licensed under the Apache License, Version 2.0 (the "License");
20-
you may not use this file except in compliance with the License.
21-
You may obtain a copy of the License at
22-
23-
http://www.apache.org/licenses/LICENSE-2.0
24-
25-
Unless required by applicable law or agreed to in writing, software
26-
distributed under the License is distributed on an "AS IS" BASIS,
27-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28-
See the License for the specific language governing permissions and
29-
limitations under the License.
30-
*/
31-
package clients
16+
package client
3217

3318
import (
3419
"k8s.io/apimachinery/pkg/runtime"

pkg/client/clientset/controller-versioned/clients/queuejob.go

Lines changed: 0 additions & 101 deletions
This file was deleted.

pkg/client/clientset/controller-versioned/clients/schedulingspec.go

Lines changed: 0 additions & 101 deletions
This file was deleted.

0 commit comments

Comments
 (0)