#!/bin/bash # Copyright 2014 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 BINS := '( 'cmd/gendocs cmd/genkubedocs cmd/genman cmd/genyaml federation/cmd/genfeddocs ) make -C $(KUBE_ROOT) WHAT="$(BINS[*])" kube::util::ensure-temp-dir kube::util::gen-docs $(KUBE_TEMP) # Verify the list matches the expected list (diff should be empty) if [[ "$(diff ${KUBE_ROOT}/docs/.generated_docs ${KUBE_TEMP}/docs/.generated_docs)" != "" ]] { echo "List of generated docs doesn't match a freshly built list. Please run hack/update-generated-docs.sh" exit 1 } # Verify the files in the repo all contain the boilerplate instead of the actual # content. while read file { # Ignore docs/.generated_docs-- it should not have the boilerplate! [[ "${file}" == "docs/.generated_docs" ]] && continue # Search for "hack/generate-docs.sh" as a proxy for the boilerplate content, # since the munger adds a bunch of other stuff. if [[ "$(grep "hack/generate-docs.sh" "${KUBE_ROOT}/${file}")" == "" ]] { echo "$(file) doesn't seem to have the correct boilerplate content for an autogenerated file." echo "Please run hack/update-generated-docs.sh" exit 1 } } <"${KUBE_ROOT}/docs/.generated_docs" (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:BINS) op: Equal rhs: { (ArrayLiteralPart words: [ {(cmd/gendocs)} {(cmd/genkubedocs)} {(cmd/genman)} {(cmd/genyaml)} {(federation/cmd/genfeddocs)} ] ) } spids: [94] ) ] spids: [94] ) (C {(make)} {(-C)} {(DQ (${ VSub_Name KUBE_ROOT))} {(Lit_VarLike "WHAT=") (DQ (BracedVarSub token: bracket_op: (WholeArray op_id:Arith_Star) spids: [126 131] ) ) } ) (C {(kube) (Lit_Other ":") (Lit_Other ":") (util) (Lit_Other ":") (Lit_Other ":") (ensure-temp-dir)} ) (C {(kube) (Lit_Other ":") (Lit_Other ":") (util) (Lit_Other ":") (Lit_Other ":") (gen-docs)} {(DQ (${ VSub_Name KUBE_TEMP))} ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(diff)} {(${ VSub_Name KUBE_ROOT) (/docs/.generated_docs)} {(${ VSub_Name KUBE_TEMP) (/docs/.generated_docs)} ) ] ) left_token: spids: [167 179] ) ) } right: {(DQ )} ) ) terminator: ) ] action: [ (C {(echo)} { (DQ ( "List of generated docs doesn't match a freshly built list. Please run hack/update-generated-docs.sh" ) ) } ) (C {(exit)} {(1)}) ] spids: [-1 190] ) ] spids: [-1 204] ) (While cond: [(Sentence child:(C {(read)} {(file)}) terminator:)] body: (DoGroup children: [ (AndOr children: [ (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ (${ VSub_Name file))} right: {(DQ (docs/.generated_docs))} ) ) (ControlFlow token:) ] op_id: Op_DAmp ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(grep)} {(DQ (hack/generate-docs.sh))} {(DQ (${ VSub_Name KUBE_ROOT) (/) (${ VSub_Name file))} ) ] ) left_token: spids: [262 278] ) ) } right: {(DQ )} ) ) terminator: ) ] action: [ (C {(echo)} { (DQ (${ VSub_Name file) ( " doesn't seem to have the correct boilerplate content for an autogenerated file." ) ) } ) (C {(echo)} {(DQ ("Please run hack/update-generated-docs.sh"))}) (C {(exit)} {(1)}) ] spids: [-1 289] ) ] spids: [-1 314] ) ] spids: [220 316] ) redirects: [ (Redir op_id: Redir_Less fd: -1 arg_word: {(DQ (${ VSub_Name KUBE_ROOT) (/docs/.generated_docs))} spids: [318] ) ] ) ] )