Skip to content

Instantly share code, notes, and snippets.

@mgoodness
Created November 13, 2017 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgoodness/31c2aec795489b191c59b290d89f3b50 to your computer and use it in GitHub Desktop.
Save mgoodness/31c2aec795489b191c59b290d89f3b50 to your computer and use it in GitHub Desktop.
Fish shell function for updating the CoreOS Tectonic license Secret
function update-tectonic-license -d 'Updates the Tectonic license secret' -a license_file contexts
set -l license_secrets tectonic-license tectonic-license-secret
set -l current_context (kubectl config current-context)
if test -z "$license_file"
echo "usage: update-tectonic-license <path/to/license_file> [<contexts>]"
end
if test -z "$contexts"
set contexts (kubectl config view -o go-template="{{ range .contexts }}{{ .name | println }}{{ end }}")
end
for context in $contexts
kubectl config use-context $context
for secret in (kubectl -n tectonic-system get secrets \
-o go-template="{{ range .items }}{{ .metadata.name | println }}{{ end }}")
if contains $secret $license_secrets
kubectl -n tectonic-system delete secret $secret
kubectl -n tectonic-system create secret generic $secret \
--from-file license=$license_file
end
end
echo
end
kubectl config use-context $current_context
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment