Skip to content

Commit

Permalink
added check for registry.IsRemote(). and correct error message.
Browse files Browse the repository at this point in the history
Signed-off-by: miyamo2 <[email protected]>
  • Loading branch information
miyamo2 committed Jun 23, 2024
1 parent b8d95a5 commit 5d00971
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/podman/diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ func ValidateContainerDiffArgs(cmd *cobra.Command, args []string) error {
return errors.New("--latest and containers cannot be used together")
}
if len(args) == 0 && !given {
if registry.IsRemote() {
return fmt.Errorf("%q requires a name or id", cmd.CommandPath())
}
return fmt.Errorf("%q requires a name, id, or the \"--latest\" flag", cmd.CommandPath())
}
return nil
Expand Down
9 changes: 9 additions & 0 deletions test/e2e/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,13 @@ RUN touch %s`, ALPINE, imagefile)
Expect(session.OutputToString()).To(ContainSubstring(confile))
})

It("podman diff without args", func() {
session := podmanTest.Podman([]string{"diff"})
session.WaitWithDefaultTimeout()
if IsRemote() {
Expect(session).Should(ExitWithError(125, " requires a name or id"))
} else {
Expect(session).Should(ExitWithError(125, " requires a name, id, or the \"--latest\" flag"))
}
})
})

0 comments on commit 5d00971

Please sign in to comment.