-
Notifications
You must be signed in to change notification settings - Fork 14
/
pull-k8s-protos.sh
executable file
·85 lines (67 loc) · 3.01 KB
/
pull-k8s-protos.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
# Copyright 2017 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.
#
# Derived from original files
# https://github.com/kubernetes-client/gen/blob/master/proto/dependencies.sh
# https://github.com/kubernetes-client/gen/blob/master/proto/generate.sh
#
release=${1:-"master"}
echo Downloading proto files for ${release}
mkdir -p k8s.io/api/core/v1
mkdir -p k8s.io/apimachinery/pkg/api/resource
mkdir -p k8s.io/apimachinery/pkg/apis/meta/v1
mkdir -p k8s.io/apimachinery/pkg/util/intstr
mkdir -p k8s.io/apimachinery/pkg/runtime/schema
mkdir -p k8s.io/apis/meta/v1
base=https://raw.githubusercontent.com/kubernetes
machinery_base=${base}/apimachinery/${release}
curl -s ${machinery_base}/pkg/api/resource/generated.proto \
> k8s.io/apimachinery/pkg/api/resource/generated.proto
curl -s ${machinery_base}/pkg/apis/meta/v1/generated.proto \
> k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto
curl -s ${machinery_base}/pkg/util/intstr/generated.proto \
> k8s.io/apimachinery/pkg/util/intstr/generated.proto
curl -s ${machinery_base}/pkg/runtime/generated.proto \
> k8s.io/apimachinery/pkg/runtime/generated.proto
curl -s ${machinery_base}/pkg/runtime/schema/generated.proto \
> k8s.io/apimachinery/pkg/runtime/schema/generated.proto
base=https://raw.githubusercontent.com/kubernetes
curl -s ${base}/api/master/core/v1/generated.proto > k8s.io/api/core/v1/generated.proto
# The format here is <file-name>;<generated-class-name>
files="k8s.io/api/core/v1/generated.proto;V1 \
k8s.io/apimachinery/pkg/api/resource/generated.proto;Resource \
k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto;Meta \
k8s.io/apimachinery/pkg/runtime/generated.proto;Runtime \
k8s.io/apimachinery/pkg/runtime/schema/generated.proto;RuntimeSchema \
k8s.io/apimachinery/pkg/util/intstr/generated.proto;IntStr"
proto_files=""
echo 'Munging proto file packages'
# This is a little hacky, but we know the go_package directive is in the
# right place, so add a marker, and then append more package declarations.
# Sorry, I like perl.
for info in ${files}; do
file=$(echo ${info} | cut -d ";" -f 1)
class=$(echo ${info} | cut -d ";" -f 2)
proto_files="${file} ${proto_files}"
perl -pi -e \
's/option go_package = "(.*)";/option go_package = "$1";\n\/\/ PKG/' \
${file}
# perl -pi -e \
# 's/\/\/ PKG/\/\/ PKG\noption java_package = "io.kubernetes.client.proto";/' \
# ${file}
# perl -pi -e \
# "s/\/\/ PKG/\/\/ PKG\noption java_outer_classname = \"${class}\";/" \
# ${file}
done