Skip to content

Generate MCAD clients using clientgen tools #533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
/output*/
/_output*/
/_output
bin

# Emacs save files
*~
Expand Down
74 changes: 74 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ $(LOCALBIN):

## Tool Versions
CONTROLLER_TOOLS_VERSION ?= v0.9.2
CODEGEN_VERSION ?= v0.20.15

## Tool Binaries
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
APPLYCONFIGURATION_GEN ?= $(LOCALBIN)/applyconfiguration-gen
CLIENT_GEN ?= $(LOCALBIN)/client-gen
LISTER_GEN ?= $(LOCALBIN)/lister-gen
INFORMER_GEN ?= $(LOCALBIN)/informer-gen

# Reset branch name if this a Travis CI environment
ifneq ($(strip $(TRAVIS_BRANCH)),)
Expand Down Expand Up @@ -70,12 +75,81 @@ init:
verify-tag-name: print-global-variables
# Check for invalid tag name
t=${TAG} && [ $${#t} -le 128 ] || { echo "Target name $$t has 128 or more chars"; false; }
.PHONY: generate-client ## Generate client packages
generate-client: code-generator
rm -rf pkg/client/clientset/versioned pkg/client/informers/externalversions pkg/client/listers/controller/v1beta1 pkg/client/listers/quotasubtree/v1
# TODO: add this back when the version of the tool has been updated and supports this executable
# $(APPLYCONFIGURATION_GEN) \
# --input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" \
# --go-header-file="hack/boilerplate/boilerplate.go.txt" \
# --output-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/applyconfiguration" \
# --trim-path-prefix "github.com/project-codeflare/multi-cluster-app-dispatcher"
$(CLIENT_GEN) \
--input="pkg/apis/controller/v1beta1" \
--input="pkg/apis/quotaplugins/quotasubtree/v1" \
--input-base="github.com/project-codeflare/multi-cluster-app-dispatcher" \
--go-header-file="hack/boilerplate/boilerplate.go.txt" \
--clientset-name "versioned" \
--output-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset" \
--output-base="."
# TODO: add the following line back once the tool has been upgraded
# --trim-path-prefix "github.com/project-codeflare/multi-cluster-app-dispatcher"
$(LISTER_GEN) \
--input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" \
--input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" \
--go-header-file="hack/boilerplate/boilerplate.go.txt" \
--output-base="." \
--output-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers"
# TODO: add the following line back once the tool has been upgraded
# --trim-path-prefix "github.com/project-codeflare/multi-cluster-app-dispatcher"
$(INFORMER_GEN) \
--input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" \
--input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" \
--versioned-clientset-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" \
--listers-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers" \
--go-header-file="hack/boilerplate/boilerplate.go.txt" \
--output-base="." \
--output-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers"
# TODO: add the following line back once the tool has been upgraded
# --trim-path-prefix "github.com/project-codeflare/multi-cluster-app-dispatcher"
# TODO: remove the following lines once the tool has been upgraded and they are no longer needed.
# The `mv` and `rm` are necessary as the generators write to the gihub.com/... path.
mv -f github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned pkg/client/clientset/versioned
mv -f github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions pkg/client/informers/externalversions
mv -f github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1beta1 pkg/client/listers/controller/v1beta1
mv -f github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/quotasubtree/v1 pkg/client/listers/quotasubtree/v1
rm -rf github.com

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

.PHONY: code-generator
#TODO: add $(APPLYCONFIGURATION_GEN) as a dependency when the tool is supported
code-generator: $(CLIENT_GEN) $(LISTER_GEN) $(INFORMER_GEN) $(CONTROLLER_GEN)

# TODO: enable this target once the tools is supported
#.PHONY: applyconfiguration-gen
#applyconfiguration-gen: $(APPLYCONFIGURATION_GEN)
#$(APPLYCONFIGURATION_GEN): $(LOCALBIN)
# test -s $(LOCALBIN)/applyconfiguration-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/applyconfiguration-gen@$(CODEGEN_VERSION)

.PHONY: client-gen
client-gen: $(CLIENT_GEN)
$(CLIENT_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/client-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/client-gen@$(CODEGEN_VERSION)

.PHONY: lister-gen
lister-gen: $(LISTER_GEN)
$(LISTER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/lister-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/lister-gen@$(CODEGEN_VERSION)

.PHONY: informer-gen
informer-gen: $(INFORMER_GEN)
$(INFORMER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/informer-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/informer-gen@$(CODEGEN_VERSION)

.PHONY: manifests
manifests: controller-gen ## Generate CustomResourceDefinition objects.
$(CONTROLLER_GEN) crd:allowDangerousTypes=true paths="./pkg/apis/..." output:crd:artifacts:config=config/crd/bases
Expand Down
15 changes: 0 additions & 15 deletions hack/boilerplate/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
/*
Copyright YEAR The Kubernetes Authors.

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.
*/
/*
Copyright 2019, 2021, 2022, YEAR The Multi-Cluster App Dispatcher Authors.

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/controller/v1beta1/appwrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const AppWrapperPlural string = "appwrappers"
// which AppWrapper it belongs to.
const AppWrapperAnnotationKey = "appwrapper.mcad.ibm.com/appwrapper-name"

// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
/*
Copyright 2018 The Kubernetes Authors.
Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors.

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
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.
*/
/*
Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors.

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 clients
package client

import (
"k8s.io/apimachinery/pkg/runtime"
Expand Down
101 changes: 0 additions & 101 deletions pkg/client/clientset/controller-versioned/clients/queuejob.go

This file was deleted.

101 changes: 0 additions & 101 deletions pkg/client/clientset/controller-versioned/clients/schedulingspec.go

This file was deleted.

Loading