Skip to content

Instantly share code, notes, and snippets.

@Duologic
Last active October 29, 2020 15:18
Show Gist options
  • Select an option

  • Save Duologic/257f52453957c051c3014d2030467ede to your computer and use it in GitHub Desktop.

Select an option

Save Duologic/257f52453957c051c3014d2030467ede to your computer and use it in GitHub Desktop.
cleaner diff with tanka/kubectl
#!/usr/bin/env sh
# Usage: export KUBECTL_EXTERNAL_DIFF=/path/to/diff.sh
function warning() {
ORANGE='\033[0;33m'
NC='\033[0m' # No Color
>&2 printf "${ORANGE}WARNING: ${1}${NC}\n"
}
warning "last-applied-configuration <redacted>"
find $1 -type f | xargs sed -i '/kubectl.kubernetes.io\/last-applied-configuration/!b;n;c<redacted>'
find $2 -type f | xargs sed -i '/kubectl.kubernetes.io\/last-applied-configuration/!b;n;c<redacted>'
warning "ignoring fluxcd.io/* annotations"
find $1 -type f | xargs sed -i '/fluxcd.io\//d'
warning "ignoring generation: [0-9]+"
find $1 -type f | xargs sed -i '/generation: [0-9]\+/d'
find $2 -type f | xargs sed -i '/generation: [0-9]\+/d'
#icdiff -r --no-bold --head=5000 --line-numbers --cols $(tput cols) $@
diff --minimal -u -N $@
#!/usr/bin/env sh
# Put his on your PATH - see https://github.com/grafana/tanka/pull/412
export KUBECTL_EXTERNAL_DIFF=/path/to/diff.sh
${EXECUTABLE} diff $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment