Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
e6a210ca
Commit
e6a210ca
authored
Aug 11, 2017
by
Renaud Gaubert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added script to generate the Device Plugin API
Signed-off-by:
Renaud Gaubert
<
rgaubert@nvidia.com
>
parent
c4402469
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
133 additions
and
0 deletions
+133
-0
protoc.sh
hack/lib/protoc.sh
+80
-0
update-generated-device-plugin-dockerized.sh
hack/update-generated-device-plugin-dockerized.sh
+26
-0
update-generated-device-plugin.sh
hack/update-generated-device-plugin.sh
+27
-0
No files found.
hack/lib/protoc.sh
0 → 100644
View file @
e6a210ca
#!/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.
set
-o
errexit
set
-o
nounset
set
-o
pipefail
# The root of the build/dist directory
KUBE_ROOT
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
}
"
)
/../.."
&&
pwd
-P
)
"
source
"
${
KUBE_ROOT
}
/hack/lib/init.sh"
# Generates $1/api.pb.go from the protobuf file $1/api.proto
# and formats it correctly
# $1: Full path to the directory where the api.proto file is
function
kube::protoc::generate_proto
()
{
kube::golang::setup_env
local
bins
=(
vendor/k8s.io/kube-gen/cmd/go-to-protobuf/protoc-gen-gogo
)
make
-C
"
${
KUBE_ROOT
}
"
WHAT
=
"
${
bins
[*]
}
"
kube::protoc::check_protoc
local
package
=
${
1
}
kube::protoc::protoc
${
package
}
kube::protoc::format
${
package
}
}
# Checks that the current protoc version is at least version 3.0.0-beta1
# exit 1 if it's not the case
function
kube::protoc::check_protoc
()
{
if
[[
-z
"
$(
which protoc
)
"
||
"
$(
protoc
--version
)
"
!=
"libprotoc 3."
*
]]
;
then
echo
"Generating protobuf requires protoc 3.0.0-beta1 or newer. Please download and"
echo
"install the platform appropriate Protobuf package for your OS: "
echo
echo
" https://github.com/google/protobuf/releases"
echo
echo
"WARNING: Protobuf changes are not being validated"
exit
1
fi
}
# Generates $1/api.pb.go from the protobuf file $1/api.proto
# $1: Full path to the directory where the api.proto file is
function
kube::protoc::protoc
()
{
local
package
=
${
1
}
gogopath
=
$(
dirname
$(
kube::util::find-binary
"protoc-gen-gogo"
))
PATH
=
"
${
gogopath
}
:
${
PATH
}
"
protoc
\
--proto_path
=
"
${
package
}
"
\
--proto_path
=
"
${
KUBE_ROOT
}
/vendor"
\
--gogo_out
=
plugins
=
grpc:
${
package
}
${
package
}
/api.proto
}
# Formats $1/api.pb.go, adds the boilerplate comments and run gofmt on it
# $1: Full path to the directory where the api.proto file is
function
kube::protoc::format
()
{
local
package
=
${
1
}
# Update boilerplate for the generated file.
echo
"
$(
cat
hack/boilerplate/boilerplate.go.txt
${
package
}
/api.pb.go
)
"
>
${
package
}
/api.pb.go
sed
-i
".bak"
"s/Copyright YEAR/Copyright
$(
date
'+%Y'
)
/g"
${
package
}
/api.pb.go
# Run gofmt to clean up the generated code.
kube::golang::verify_go_version
gofmt
-l
-s
-w
${
package
}
/api.pb.go
}
hack/update-generated-device-plugin-dockerized.sh
0 → 100755
View file @
e6a210ca
#!/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.
set
-o
errexit
set
-o
nounset
set
-o
pipefail
KUBE_ROOT
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
}
"
)
/../"
&&
pwd
-P
)
"
DEVICE_PLUGIN_ROOT
=
"
${
KUBE_ROOT
}
/pkg/kubelet/apis/deviceplugin/v1alpha1/"
source
"
${
KUBE_ROOT
}
/hack/lib/protoc.sh"
kube::protoc::generate_proto
${
DEVICE_PLUGIN_ROOT
}
hack/update-generated-device-plugin.sh
0 → 100755
View file @
e6a210ca
#!/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.
set
-o
errexit
set
-o
nounset
set
-o
pipefail
KUBE_ROOT
=
$(
dirname
"
${
BASH_SOURCE
}
"
)
/..
# NOTE: All output from this script needs to be copied back to the calling
# source tree. This is managed in kube::build::copy_output in build/common.sh.
# If the output set is changed update that function.
${
KUBE_ROOT
}
/build/run.sh hack/update-generated-device-plugin-dockerized.sh
"
$@
"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment