Skip to content

Commit

Permalink
Merge pull request #23043 from miyamo2/feat/issues#23038
Browse files Browse the repository at this point in the history
fix(diff): do not suggest `--latest` when runs on remote with no args
  • Loading branch information
openshift-merge-bot[bot] authored Jun 24, 2024
2 parents 57fe4c4 + 5d00971 commit 673dde9
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 673dde9

Please sign in to comment.