#!/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 global KUBE_ROOT := "$[dirname $(BASH_SOURCE)]/.." source "$(KUBE_ROOT)/hack/lib/init.sh" kube::golang::setup_env make -C $(KUBE_ROOT) WHAT=cmd/genswaggertypedocs # Find binary global genswaggertypedocs := $[kube::util::find-binary "genswaggertypedocs] if [[ ! -x "$genswaggertypedocs" ]] { do { echo "It looks as if you don't have a compiled genswaggertypedocs binary" echo echo "If you are running from a clone of the git repo, please run" echo "'make WHAT=cmd/genswaggertypedocs'." } >&2 exit 1 } global DIFFROOT := ""$(KUBE_ROOT)/federation"" global TMP_DIFFROOT := ""$(KUBE_ROOT)/_tmp/federation"" global _tmp := ""$(KUBE_ROOT)/_tmp_federation"" proc cleanup { rm -rf $(_tmp) } trap "cleanup" EXIT SIGINT cleanup mkdir -p $(TMP_DIFFROOT) cp -a "$(DIFFROOT)"/* "$(TMP_DIFFROOT)/" "$(KUBE_ROOT)/hack/update-federation-generated-swagger-docs.sh" echo "diffing $(DIFFROOT) against freshly generated swagger type documentation" global ret := '0' diff -Naupr -I 'Auto generated by' $(DIFFROOT) $(TMP_DIFFROOT) || global ret := $Status cp -a "$(TMP_DIFFROOT)"/* "$(DIFFROOT)/" if [[ $ret -eq 0 ]] { echo "$(DIFFROOT) up to date." } else { echo "$(DIFFROOT) is out of date. Please run hack/update-federation-generated-swagger-docs.sh" exit 1 } (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] ) (C {(source)} {(DQ (${ VSub_Name KUBE_ROOT) (/hack/lib/init.sh))}) (C {(kube) (Lit_Other ":") (Lit_Other ":") (golang) (Lit_Other ":") (Lit_Other ":") (setup_env)}) (C {(make)} {(-C)} {(DQ (${ VSub_Name KUBE_ROOT))} {(Lit_VarLike "WHAT=") (cmd/genswaggertypedocs)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:genswaggertypedocs) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(kube) (Lit_Other ":") (Lit_Other ":") (util) (Lit_Other ":") (Lit_Other ":") (find-binary) } {(DQ (genswaggertypedocs))} ) ] ) left_token: spids: [112 124] ) } spids: [111] ) ] spids: [111] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalNot child: (BoolUnary op_id: BoolUnary_x child: {(DQ ($ VSub_Name "$genswaggertypedocs"))} ) ) ) terminator: ) ] action: [ (BraceGroup children: [ (C {(echo)} {(DQ ("It looks as if you don't have a compiled genswaggertypedocs binary"))} ) (C {(echo)}) (C {(echo)} {(DQ ("If you are running from a clone of the git repo, please run"))}) (C {(echo)} {(DQ ("'make WHAT=cmd/genswaggertypedocs'."))}) ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[174])] spids: [145] ) (C {(exit)} {(1)}) ] spids: [-1 142] ) ] spids: [-1 182] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DIFFROOT) op: Equal rhs: {(DQ (${ VSub_Name KUBE_ROOT) (/federation))} spids: [185] ) ] spids: [185] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:TMP_DIFFROOT) op: Equal rhs: {(DQ (${ VSub_Name KUBE_ROOT) (/_tmp/federation))} spids: [193] ) ] spids: [193] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_tmp) op: Equal rhs: {(DQ (${ VSub_Name KUBE_ROOT) (/_tmp_federation))} spids: [201] ) ] spids: [201] ) (FuncDef name: cleanup body: (BraceGroup children:[(C {(rm)} {(-rf)} {(DQ (${ VSub_Name _tmp))})] spids:[214]) spids: [210 213] ) (C {(trap)} {(DQ (cleanup))} {(EXIT)} {(SIGINT)}) (C {(cleanup)}) (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name TMP_DIFFROOT))}) (C {(cp)} {(-a)} {(DQ (${ VSub_Name DIFFROOT)) (/) (Lit_Other "*")} {(DQ (${ VSub_Name TMP_DIFFROOT) (/))} ) (C {(DQ (${ VSub_Name KUBE_ROOT) (/hack/update-federation-generated-swagger-docs.sh))}) (C {(echo)} { (DQ ("diffing ") (${ VSub_Name DIFFROOT) (" against freshly generated swagger type documentation") ) } ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:ret) op:Equal rhs:{(0)} spids:[290])] spids: [290] ) (AndOr children: [ (C {(diff)} {(-Naupr)} {(-I)} {(SQ <"Auto generated by">)} {(DQ (${ VSub_Name DIFFROOT))} {(DQ (${ VSub_Name TMP_DIFFROOT))} ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:ret) op:Equal rhs:{($ VSub_QMark "$?")} spids:[317])] spids: [317] ) ] op_id: Op_DPipe ) (C {(cp)} {(-a)} {(DQ (${ VSub_Name TMP_DIFFROOT)) (/) (Lit_Other "*")} {(DQ (${ VSub_Name DIFFROOT) (/))} ) (If arms: [ (if_arm cond: [ (DBracket expr: (BoolBinary op_id:BoolBinary_eq left:{($ VSub_Name "$ret")} right:{(0)}) ) ] action: [(C {(echo)} {(DQ (${ VSub_Name DIFFROOT) (" up to date."))})] spids: [-1 351] ) ] else_action: [ (C {(echo)} { (DQ (${ VSub_Name DIFFROOT) (" is out of date. Please run hack/update-federation-generated-swagger-docs.sh") ) } ) (C {(exit)} {(1)}) ] spids: [363 380] ) ] )