#!/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)]/.." source "$(KUBE_ROOT)/hack/lib/init.sh" kube::golang::setup_env global SPECROOT := ""$(KUBE_ROOT)/federation/apis/openapi-spec"" global TMP_SPECROOT := ""$(KUBE_ROOT)/_tmp_federation/openapi-spec"" global _tmp := ""$(KUBE_ROOT)/_tmp_federation"" mkdir -p $(_tmp) cp -a $(SPECROOT) $(TMP_SPECROOT) trap "cp -a $(TMP_SPECROOT) $(SPECROOT)/..; rm -rf $(_tmp)" EXIT SIGINT rm $(SPECROOT)/* "$(KUBE_ROOT)/hack/update-federation-openapi-spec.sh" echo "diffing $(SPECROOT) against freshly generated federation openapi spec" global ret := '0' diff -Naupr -I 'Auto generated by' $(SPECROOT) $(TMP_SPECROOT) || global ret := $Status if [[ $ret -eq 0 ]] { echo "$(SPECROOT) up to date." } else { echo "$(SPECROOT) is out of date. Please run hack/update-federation-openapi-spec.sh" exit 1 } # ex: ts=2 sw=2 et filetype=sh (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)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SPECROOT) op: Equal rhs: {(DQ (${ VSub_Name KUBE_ROOT) (/federation/apis/openapi-spec))} spids: [94] ) ] spids: [94] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:TMP_SPECROOT) op: Equal rhs: {(DQ (${ VSub_Name KUBE_ROOT) (/_tmp_federation/openapi-spec))} spids: [102] ) ] spids: [102] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_tmp) op: Equal rhs: {(DQ (${ VSub_Name KUBE_ROOT) (/_tmp_federation))} spids: [110] ) ] spids: [110] ) (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name _tmp))}) (C {(cp)} {(-a)} {(DQ (${ VSub_Name SPECROOT))} {(DQ (${ VSub_Name TMP_SPECROOT))}) (C {(trap)} { (DQ ("cp -a ") (${ VSub_Name TMP_SPECROOT) (" ") (${ VSub_Name SPECROOT) ("/..; rm -rf ") (${ VSub_Name _tmp) ) } {(EXIT)} {(SIGINT)} ) (C {(rm)} {(${ VSub_Name SPECROOT) (/) (Lit_Other "*")}) (C {(DQ (${ VSub_Name KUBE_ROOT) (/hack/update-federation-openapi-spec.sh))}) (C {(echo)} { (DQ ("diffing ") (${ VSub_Name SPECROOT) (" against freshly generated federation openapi spec")) } ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:ret) op:Equal rhs:{(0)} spids:[192])] spids: [192] ) (AndOr children: [ (C {(diff)} {(-Naupr)} {(-I)} {(SQ <"Auto generated by">)} {(DQ (${ VSub_Name SPECROOT))} {(DQ (${ VSub_Name TMP_SPECROOT))} ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:ret) op:Equal rhs:{($ VSub_QMark "$?")} spids:[219])] spids: [219] ) ] op_id: Op_DPipe ) (If arms: [ (if_arm cond: [ (DBracket expr: (BoolBinary op_id:BoolBinary_eq left:{($ VSub_Name "$ret")} right:{(0)}) ) ] action: [(C {(echo)} {(DQ (${ VSub_Name SPECROOT) (" up to date."))})] spids: [-1 234] ) ] else_action: [ (C {(echo)} { (DQ (${ VSub_Name SPECROOT) (" is out of date. Please run hack/update-federation-openapi-spec.sh") ) } ) (C {(exit)} {(1)}) ] spids: [246 263] ) ] )