#!/bin/bash # Copyright 2016 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 global KUBE_ROOT := "$[dirname $(BASH_SOURCE)]/.." global KUBE_REMOTE_RUNTIME_ROOT := ""$(KUBE_ROOT)/pkg/kubelet/apis/cri/v1alpha1/runtime/"" source "$(KUBE_ROOT)/hack/lib/init.sh" kube::golang::setup_env global BINS := '( 'vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo ) make -C $(KUBE_ROOT) WHAT="$(BINS[*])" if [[ -z "$(which protoc)" || "$(protoc --version)" != "libprotoc 3."* ]] { 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 } proc cleanup { rm -f $(KUBE_REMOTE_RUNTIME_ROOT)/api.pb.go.bak } trap cleanup EXIT global gogopath := $[dirname $[kube::util::find-binary "protoc-gen-gogo]] env PATH="$(gogopath):$(PATH)" \ protoc \ --proto_path="$(KUBE_REMOTE_RUNTIME_ROOT)" \ --proto_path="$(KUBE_ROOT)/vendor" \ --gogo_out=plugins=grpc:$(KUBE_REMOTE_RUNTIME_ROOT) $(KUBE_REMOTE_RUNTIME_ROOT)/api.proto # Update boilerplate for the generated file. echo $[cat hack/boilerplate/boilerplate.go.txt $(KUBE_REMOTE_RUNTIME_ROOT)/api.pb.go] > $(KUBE_REMOTE_RUNTIME_ROOT)/api.pb.go sed -i".bak" "s/Copyright YEAR/Copyright $[date '+%Y]/g" $(KUBE_REMOTE_RUNTIME_ROOT)/api.pb.go # Run gofmt to clean up the generated code. kube::golang::verify_go_version gofmt -l -s -w $(KUBE_REMOTE_RUNTIME_ROOT)/api.pb.go (CommandList children: [ (C {(set)} {(-o)} {(errexit)}) (C {(set)} {(-o)} {(nounset)}) (C {(set)} {(-o)} {(pipefail)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KUBE_ROOT) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(dirname)} {(DQ (${ VSub_Name BASH_SOURCE))})] ) left_token: spids: [64 72] ) (/..) } spids: [63] ) ] spids: [63] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KUBE_REMOTE_RUNTIME_ROOT) op: Equal rhs: {(DQ (${ VSub_Name KUBE_ROOT) (/pkg/kubelet/apis/cri/v1alpha1/runtime/))} spids: [75] ) ] spids: [75] ) (C {(source)} {(DQ (${ VSub_Name KUBE_ROOT) (/hack/lib/init.sh))}) (C {(kube) (Lit_Other ":") (Lit_Other ":") (golang) (Lit_Other ":") (Lit_Other ":") (setup_env)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BINS) op: Equal rhs: { (ArrayLiteralPart words: [{(vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo)}] ) } spids: [102] ) ] spids: [102] ) (C {(make)} {(-C)} {(DQ (${ VSub_Name KUBE_ROOT))} {(Lit_VarLike "WHAT=") (DQ (BracedVarSub token: bracket_op: (WholeArray op_id:Arith_Star) spids: [122 127] ) ) } ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalOr left: (BoolUnary op_id: BoolUnary_z child: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(which)} {(protoc)})]) left_token: spids: [138 142] ) ) } ) right: (BoolBinary op_id: BoolBinary_GlobNEqual left: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(protoc)} {(--version)})]) left_token: spids: [148 152] ) ) } right: {(DQ ("libprotoc 3.")) (Lit_Other "*")} ) ) ) terminator: ) ] action: [ (C {(echo)} { (DQ ("Generating protobuf requires protoc 3.0.0-beta1 or newer. Please download and")) } ) (C {(echo)} {(DQ ("install the platform appropriate Protobuf package for your OS: "))}) (C {(echo)}) (C {(echo)} {(DQ (" https://github.com/google/protobuf/releases"))}) (C {(echo)}) (C {(echo)} {(DQ ("WARNING: Protobuf changes are not being validated"))}) (C {(exit)} {(1)}) ] spids: [-1 165] ) ] spids: [-1 206] ) (FuncDef name: cleanup body: (BraceGroup children: [(C {(rm)} {(-f)} {(${ VSub_Name KUBE_REMOTE_RUNTIME_ROOT) (/api.pb.go.bak)})] spids: [213] ) spids: [209 212] ) (C {(trap)} {(cleanup)} {(EXIT)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:gogopath) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(dirname)} { (CommandSubPart command_list: (CommandList children: [ (C {(kube) (Lit_Other ":") (Lit_Other ":") (util) (Lit_Other ":") (Lit_Other ":") (find-binary) } {(DQ (protoc-gen-gogo))} ) ] ) left_token: spids: [239 251] ) } ) ] ) left_token: spids: [236 252] ) } spids: [235] ) ] spids: [235] ) (SimpleCommand words: [ {(protoc)} {(--proto_path) (Lit_Other "=") (DQ (${ VSub_Name KUBE_REMOTE_RUNTIME_ROOT))} {(--proto_path) (Lit_Other "=") (DQ (${ VSub_Name KUBE_ROOT) (/vendor))} {(--gogo_out) (Lit_Other "=") (Lit_VarLike "plugins=") (grpc) (Lit_Other ":") (${ VSub_Name KUBE_REMOTE_RUNTIME_ROOT) } {(${ VSub_Name KUBE_REMOTE_RUNTIME_ROOT) (/api.proto)} ] more_env: [ (env_pair name: PATH val: {(DQ (${ VSub_Name gogopath) (":") (${ VSub_Name PATH))} spids: [255] ) ] ) (SimpleCommand words: [ {(echo)} { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(cat)} {(hack/boilerplate/boilerplate.go.txt)} {(${ VSub_Name KUBE_REMOTE_RUNTIME_ROOT) (/api.pb.go)} ) ] ) left_token: spids: [314 323] ) ) } ] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(${ VSub_Name KUBE_REMOTE_RUNTIME_ROOT) (/api.pb.go)} spids: [326] ) ] ) (C {(sed)} {(-i) (DQ (.bak))} { (DQ ("s/Copyright YEAR/Copyright ") (CommandSubPart command_list: (CommandList children:[(C {(date)} {(SQ <"+%Y">)})]) left_token: spids: [342 348] ) (/g) ) } {(${ VSub_Name KUBE_REMOTE_RUNTIME_ROOT) (/api.pb.go)} ) (C {(kube) (Lit_Other ":") (Lit_Other ":") (golang) (Lit_Other ":") (Lit_Other ":") (verify_go_version) } ) (C {(gofmt)} {(-l)} {(-s)} {(-w)} {(${ VSub_Name KUBE_REMOTE_RUNTIME_ROOT) (/api.pb.go)}) ] )