github.com/migueleliasweb/helm@v2.6.1+incompatible/scripts/verify-docs.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # Copyright 2017 The Kubernetes Authors All rights reserved.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  set -euo pipefail
    18  
    19  source scripts/util.sh
    20  
    21  if LANG=C sed --help 2>&1 | grep -q GNU; then
    22    SED="sed"
    23  elif which gsed &>/dev/null; then
    24    SED="gsed"
    25  else
    26    echo "Failed to find GNU sed as sed or gsed. If you are on Mac: brew install gnu-sed." >&2
    27    exit 1
    28  fi
    29  
    30  kube::util::ensure-temp-dir
    31  
    32  export HELM_NO_PLUGINS=1
    33  
    34  # Reset Helm Home because it is used in the generation of docs.
    35  OLD_HELM_HOME=${HELM_HOME:-}
    36  HELM_HOME="$HOME/.helm"
    37  bin/helm init --client-only
    38  mkdir -p ${KUBE_TEMP}/docs/helm
    39  bin/helm docs --dir ${KUBE_TEMP}/docs/helm
    40  HELM_HOME=$OLD_HELM_HOME
    41  
    42  
    43  FILES=$(find ${KUBE_TEMP} -type f)
    44  
    45  ${SED} -i -e "s:${HOME}:~:" ${FILES}
    46  ret=0
    47  for i in ${FILES}; do
    48    diff -NauprB -I 'Auto generated' ${i} $(echo ${i} | ${SED} "s:${KUBE_TEMP}/::") || ret=$?
    49  done
    50  if [[ $ret -eq 0 ]]; then
    51    echo "helm docs up to date."
    52  else
    53    echo "helm docs are out of date. Please run \"make docs\""
    54    exit 1
    55  fi