@@ -7,25 +7,17 @@ import (
77 "github.com/docker/cli/cli/command"
88 "github.com/docker/cli/cli/command/completion"
99 "github.com/docker/cli/cli/command/formatter"
10- "github.com/pkg/errors"
1110 "github.com/spf13/cobra"
1211)
1312
14- type diffOptions struct {
15- container string
16- }
17-
1813// NewDiffCommand creates a new cobra.Command for `docker diff`
1914func NewDiffCommand (dockerCli command.Cli ) * cobra.Command {
20- var opts diffOptions
21-
2215 return & cobra.Command {
2316 Use : "diff CONTAINER" ,
2417 Short : "Inspect changes to files or directories on a container's filesystem" ,
2518 Args : cli .ExactArgs (1 ),
2619 RunE : func (cmd * cobra.Command , args []string ) error {
27- opts .container = args [0 ]
28- return runDiff (cmd .Context (), dockerCli , & opts )
20+ return runDiff (cmd .Context (), dockerCli , args [0 ])
2921 },
3022 Annotations : map [string ]string {
3123 "aliases" : "docker container diff, docker diff" ,
@@ -34,16 +26,13 @@ func NewDiffCommand(dockerCli command.Cli) *cobra.Command {
3426 }
3527}
3628
37- func runDiff (ctx context.Context , dockerCli command.Cli , opts * diffOptions ) error {
38- if opts .container == "" {
39- return errors .New ("Container name cannot be empty" )
40- }
41- changes , err := dockerCli .Client ().ContainerDiff (ctx , opts .container )
29+ func runDiff (ctx context.Context , dockerCLI command.Cli , containerID string ) error {
30+ changes , err := dockerCLI .Client ().ContainerDiff (ctx , containerID )
4231 if err != nil {
4332 return err
4433 }
4534 diffCtx := formatter.Context {
46- Output : dockerCli .Out (),
35+ Output : dockerCLI .Out (),
4736 Format : NewDiffFormat ("{{.Type}} {{.Path}}" ),
4837 }
4938 return DiffFormatWrite (diffCtx , changes )
0 commit comments