Merge pull request #23043 from miyamo2/feat/issues#23038

fix(diff): do not suggest `--latest` when runs on remote with no args
This commit is contained in:
openshift-merge-bot[bot]
2024-06-24 07:24:55 +00:00
committed by GitHub
2 changed files with 12 additions and 0 deletions

View File

@ -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

View File

@ -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"))
}
})
})