github.com/umeshredd/helm@v3.0.0-alpha.1+incompatible/scripts/update-docs.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # Copyright The Helm Authors.
     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
    38  mkdir -p docs/helm
    39  mkdir -p ${KUBE_TEMP}/docs/helm
    40  bin/helm docs --dir ${KUBE_TEMP}/docs/helm
    41  HELM_HOME=$OLD_HELM_HOME
    42  
    43  FILES=$(find ${KUBE_TEMP} -type f)
    44  
    45  ${SED} -i -e "s:${HOME}:~:" ${FILES}
    46  
    47  for i in ${FILES}; do
    48    ret=0
    49    truepath=$(echo ${i} | ${SED} "s:${KUBE_TEMP}/::")
    50    diff -NauprB -I 'Auto generated' "${i}" "${truepath}" > /dev/null || ret=$?
    51    if [[ $ret -ne 0 ]]; then
    52      echo "${truepath} changed. Updating.."
    53      cp "${i}" "${truepath}"
    54    fi
    55  done