WoozyMasta / kube-dump

Backup a Kubernetes cluster as a yaml manifest
https://kube-dump.woozymasta.ru
GNU General Public License v3.0
325 stars 67 forks source link

Replace realpath with realpath() #26

Open rschoultz opened 2 years ago

rschoultz commented 2 years ago

The script relies on the existence of "realpath". That does not exist in MacOS, and there does not exist a ready made package to install that holds realpath.

However, it seems as if this could be replaced by a combination of readlink/dirpath/basename, like this:

realpath() (
  OURPWD=$PWD
  cd "$(dirname "$1")"
  LINK=$(readlink "$(basename "$1")")
  while [ "$LINK" ]; do
    cd "$(dirname "$LINK")"
    LINK=$(readlink "$(basename "$1")")
  done
  REALPATH="$PWD/$(basename "$1")"
  cd "$OURPWD"
  echo "$REALPATH"
)

(from https://stackoverflow.com/questions/3572030/bash-script-absolute-path-with-os-x/18443300#18443300)

WoozyMasta commented 2 years ago

Another issue related to macOS https://github.com/WoozyMasta/kube-dump/issues/14

I don't think this is a critical issue yet, since there is a docker container. I'll try to do it when I have free time, or consider a pull request

vitaliytv commented 3 months ago

Also can help for mac users with this issue:

 brew install coreutils