Skip to content

Commit 75742b0

Browse files
committed
Add Makefile for Maistra client generation
This adds a Makefile with tasks for generating the Maistra specific clients. It is adapted from the one in the Istio client-go repository.
1 parent fda0384 commit 75742b0

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

Makefile.core.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,3 +626,5 @@ include tests/istio.mk
626626
include tests/integration/tests.mk
627627

628628
include common/Makefile.common.mk
629+
630+
include pkg/servicemesh/maistra.mk

pkg/servicemesh/header.go.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright Istio Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+

pkg/servicemesh/maistra.mk

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2019 Istio Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
client_gen = client-gen
16+
lister_gen = lister-gen
17+
informer_gen = informer-gen
18+
19+
kube_base_output_package = istio.io/istio/pkg/servicemesh
20+
kube_api_base_package = $(kube_base_output_package)/apis
21+
kube_api_packages = $(kube_api_base_package)/servicemesh/v1
22+
kube_clientset_package = $(kube_base_output_package)/clientset
23+
24+
# file header text
25+
kube_go_header_text = pkg/servicemesh/header.go.txt
26+
# clientset name used by kubernetes client-gen
27+
kube_clientset_name = versioned
28+
# base output package used by kubernetes client-gen
29+
kube_clientset_package = $(kube_base_output_package)/client/clientset
30+
# base output package used by kubernetes lister-gen
31+
kube_listers_package = $(kube_base_output_package)/client/listers
32+
# base output package used by kubernetes informer-gen
33+
kube_informers_package = $(kube_base_output_package)/client/informers
34+
35+
ifeq ($(IN_BUILD_CONTAINER),1)
36+
# k8s code generators rely on GOPATH, using $GOPATH/src as the base package
37+
# directory. Using --output-base . does not work, as that ends up generating
38+
# code into ./<package>, e.g. ./istio.io/client-go/pkg/apis/... To work
39+
# around this, we'll just let k8s generate the code where it wants and copy
40+
# back to where it should have been generated.
41+
move_generated=cp -r $(GOPATH)/src/$(kube_base_output_package)/ ./pkg && rm -rf $(GOPATH)/src/$(kube_base_output_package)/
42+
else
43+
# nothing special for local builds
44+
move_generated=
45+
endif
46+
47+
.PHONY: maistra-gen-k8s-client
48+
maistra-gen-k8s-client:
49+
@$(client_gen) --clientset-name $(kube_clientset_name) --input-base "" --input $(kube_api_packages) --output-package $(kube_clientset_package) -h $(kube_go_header_text)
50+
@$(lister_gen) --input-dirs $(kube_api_packages) --output-package $(kube_listers_package) -h $(kube_go_header_text)
51+
@$(informer_gen) --input-dirs $(kube_api_packages) --versioned-clientset-package $(kube_clientset_package)/$(kube_clientset_name) --listers-package $(kube_listers_package) --output-package $(kube_informers_package) -h $(kube_go_header_text)
52+
@$(move_generated)

0 commit comments

Comments
 (0)