#!/bin/bash # Copyright 2015 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. # Verifies that api reference docs are up to date. 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 API_REFERENCE_DOCS_ROOT := ""$(KUBE_ROOT)/docs/api-reference"" global OUTPUT_DIR := ""$(KUBE_ROOT)/_tmp/api-reference"" mkdir -p $(OUTPUT_DIR) global TMP_ROOT := ""$(KUBE_ROOT)/_tmp"" trap "rm -rf $(TMP_ROOT)" EXIT SIGINT # Generate API reference docs in tmp. "./hack/update-api-reference-docs.sh" $(OUTPUT_DIR) echo "diffing $(API_REFERENCE_DOCS_ROOT) against freshly generated docs" global ret := '0' diff -NauprB -I 'Last update' --exclude=*.md $(API_REFERENCE_DOCS_ROOT) $(OUTPUT_DIR) || global ret := $Status if [[ $ret -eq 0 ]] { echo "$(API_REFERENCE_DOCS_ROOT) up to date." } else { echo "$(API_REFERENCE_DOCS_ROOT) is out of date. Please run hack/update-api-reference-docs.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: [68 76] ) (/..) } spids: [67] ) ] spids: [67] ) (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:API_REFERENCE_DOCS_ROOT) op: Equal rhs: {(DQ (${ VSub_Name KUBE_ROOT) (/docs/api-reference))} spids: [98] ) ] spids: [98] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:OUTPUT_DIR) op: Equal rhs: {(DQ (${ VSub_Name KUBE_ROOT) (/_tmp/api-reference))} spids: [106] ) ] spids: [106] ) (C {(mkdir)} {(-p)} {(${ VSub_Name OUTPUT_DIR)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:TMP_ROOT) op: Equal rhs: {(DQ (${ VSub_Name KUBE_ROOT) (/_tmp))} spids: [122] ) ] spids: [122] ) (C {(trap)} {(DQ ("rm -rf ") (${ VSub_Name TMP_ROOT))} {(EXIT)} {(SIGINT)}) (C {(DQ (./hack/update-api-reference-docs.sh))} {(DQ (${ VSub_Name OUTPUT_DIR))}) (C {(echo)} {(DQ ("diffing ") (${ VSub_Name API_REFERENCE_DOCS_ROOT) (" against freshly generated docs"))} ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:ret) op:Equal rhs:{(0)} spids:[168])] spids: [168] ) (AndOr children: [ (C {(diff)} {(-NauprB)} {(-I)} {(SQ <"Last update">)} {(--exclude) (Lit_Other "=") (Lit_Other "*") (.md)} {(DQ (${ VSub_Name API_REFERENCE_DOCS_ROOT))} {(DQ (${ VSub_Name OUTPUT_DIR))} ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:ret) op:Equal rhs:{($ VSub_QMark "$?")} spids:[200])] spids: [200] ) ] 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 API_REFERENCE_DOCS_ROOT) (" up to date."))})] spids: [-1 215] ) ] else_action: [ (C {(echo)} { (DQ (${ VSub_Name API_REFERENCE_DOCS_ROOT) (" is out of date. Please run hack/update-api-reference-docs.sh") ) } ) (C {(exit)} {(1)}) ] spids: [227 244] ) ] )