github.com/flant/helm@v2.8.1+incompatible/scripts/update-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  FILES=$(find ${KUBE_TEMP} -type f)
    43  
    44  ${SED} -i -e "s:${HOME}:~:" ${FILES}
    45  
    46  for i in ${FILES}; do
    47    ret=0
    48    truepath=$(echo ${i} | ${SED} "s:${KUBE_TEMP}/::")
    49    diff -NauprB -I 'Auto generated' "${i}" "${truepath}" > /dev/null || ret=$?
    50    if [[ $ret -ne 0 ]]; then
    51      echo "${truepath} changed. Updating.."
    52      cp "${i}" "${truepath}"
    53    fi
    54  done