From 6681cc4b943439bb788d6ac968d875cf93bc8b84 Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Sun, 21 Nov 2021 11:37:25 +0800 Subject: [PATCH] ctr/snapshots/diff: don't show the media-type in output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default, diff subcommand will print tar(.gz) on stdout. If we print the media-type in stdout, the output will create invalid tar(.gz) data. ``` // before ➜ containerd git:(move_stdout_to_stderr) sudo ctr snapshot diff sha256:9f54eef412758095c8079ac465d494a2872e02e90bf1fb5f12a1641c0d1bb78b > /tmp/1.tar ➜ containerd git:(move_stdout_to_stderr) file /tmp/1.tar /tmp/1.tar: data // after change ➜ containerd git:(move_stdout_to_stderr) make bin/ctr + bin/ctr ➜ containerd git:(move_stdout_to_stderr) sudo bin/ctr snapshot diff sha256:9f54eef412758095c8079ac465d494a2872e02e90bf1fb5f12a1641c0d1bb78b > /tmp/2.tar ➜ containerd git:(move_stdout_to_stderr) file /tmp/2.tar /tmp/2.tar: gzip compressed data, original size modulo 2^32 75155456 ``` Signed-off-by: Wei Fu --- cmd/ctr/commands/snapshots/snapshots.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmd/ctr/commands/snapshots/snapshots.go b/cmd/ctr/commands/snapshots/snapshots.go index d36c85802..a1ef3c1ec 100644 --- a/cmd/ctr/commands/snapshots/snapshots.go +++ b/cmd/ctr/commands/snapshots/snapshots.go @@ -133,8 +133,6 @@ var diffCommand = cli.Command{ labels := commands.LabelArgs(context.StringSlice("label")) snapshotter := client.SnapshotService(context.GlobalString("snapshotter")) - fmt.Println(context.String("media-type")) - if context.Bool("keep") { labels["containerd.io/gc.root"] = time.Now().UTC().Format(time.RFC3339) }