Skip to content

Instantly share code, notes, and snippets.

@imjasonh
Created January 11, 2023 16:26
Show Gist options
  • Save imjasonh/ce437a40160acab17030d024d4680fd2 to your computer and use it in GitHub Desktop.
Save imjasonh/ce437a40160acab17030d024d4680fd2 to your computer and use it in GitHub Desktop.
image inspection helpers
# Diff two image filesystems
function cdiff-fs() {
diff \
<(crane export $1 - --platform ${3:-linux/amd64} | tar -tvf - | sort) \
<(crane export $2 - --platform ${3:-linux/amd64} | tar -tvf - | sort)
}
# Diff two image configs
function cdiff-cfg() {
diff \
<(crane config $1 --platform ${3:-linux/amd64} | jq) \
<(crane config $2 --platform ${3:-linux/amd64} | jq)
}
# Diff two image manifests
function cdiff-mf() {
diff \
<(crane manifest $1 --platform ${3:-linux/amd64} | jq) \
<(crane manifest $2 --platform ${3:-linux/amd64} | jq)
}
# Get image size
function imgsize() {
crane manifest $1 --platform ${2:-linux/amd64} | jq '.config.size + ([.layers[].size] | add)' | numfmt --to=iec
}
# List files in image
function cls() {
crane export $1 --platform ${2:-linux/amd64} | tar -tvf -
}
# Cat file in image
function ccat() {
crane export $1 --platform ${3:-linux/amd64} - | tar -Oxf - $2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment