Created
November 13, 2017 18:03
-
-
Save mgoodness/31c2aec795489b191c59b290d89f3b50 to your computer and use it in GitHub Desktop.
Fish shell function for updating the CoreOS Tectonic license Secret
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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