#!/bin/bash

# A wrapper for interacting with minikube.
#
# Example:
#  :; bin/mkube docker image ls

# If we're running under WSL then we have to use the Windows native Minikube
# as the Linux version doesn't work in WSL. Assume WSL is Microsoft's only
# Linux distro.
uname -r | grep "Microsoft" > /dev/null
if  [ $? -ne 0 ]; then
  MINIKUBE_EXE=minikube
else
  # This is where minikube-installer.exe puts it.
  MINIKUBE_EXE="${MINIKUBE_EXE:-/mnt/c/Program Files (x86)/Kubernetes/Minikube/minikube.exe}"
fi

# Rewrite Windows style paths "C:\\whatever\\whatever" to "/mnt/c/whatever/whatever".
eval $("${MINIKUBE_EXE}" docker-env --shell=bash | sed "s|C:\\\|/mnt/c/|g" | sed "s|\\\|/|g")

exec $@
