Skip to content

Instantly share code, notes, and snippets.

@hoanga
Created March 11, 2018 23:45
Show Gist options
  • Save hoanga/8c36fe98c9d322bbbd29cf722bb139fa to your computer and use it in GitHub Desktop.
Save hoanga/8c36fe98c9d322bbbd29cf722bb139fa to your computer and use it in GitHub Desktop.
Powershell helper functions for kubernetes
FROM kterada0509/docker-revel:latest
EXPOSE 9000
ADD . /go/src/myapp-revel
WORKDIR $GOPATH
CMD revel run myapp-revel
# A utility function for setting relevant kubernetes variables in
# a powershell process
function set-dockerenv
{
$res = minikube docker-env | select-string "^export (DOCKER_\S*?)\s*=\s*(.*)$"
$res | foreach-object -process {
if ($_ -match '^export (DOCKER_\S*?)\s*=\s*(.*)$')
{ set-item -force -path "env:$($matches[1])" -value $matches[2].replace('"', ''); }
else
{ write-error "Error setting $matches[1] to $matches[2]" }
}
}
# A utility function for clearing relevant kubernetes env variables from
# powershell
function unset-dockerenv
{
$res = minikube docker-env -u
$res | foreach-object -process {
if ($_ -match '^unset (DOCKER_\S*?)$')
{ set-item -force -path "env:$($matches[1])" -value ''; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment