mirror of
https://github.com/docker/compose.git
synced 2026-08-31 23:03:55 +00:00
Allow docker context ls —formatter {{json.}} to not delegate to Moby and include context type in the json
Signed-off-by: Guillaume Tardif <guillaume.tardif@docker.com>
This commit is contained in:
parent
0cea91c555
commit
a1bb2d5abe
4 changed files with 19 additions and 3 deletions
|
|
@ -69,7 +69,8 @@ func runList(cmd *cobra.Command, opts lsOpts) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if opts.format != "" && opts.format != formatter.JSON && opts.format != formatter.PRETTY {
|
||||
format := strings.ToLower(strings.ReplaceAll(opts.format, " ", ""))
|
||||
if format != "" && format != formatter.JSON && format != formatter.PRETTY && format != formatter.TemplateJSON {
|
||||
mobycli.Exec(cmd.Root())
|
||||
return nil
|
||||
}
|
||||
|
|
@ -93,7 +94,7 @@ func runList(cmd *cobra.Command, opts lsOpts) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if opts.json {
|
||||
if opts.json || format == formatter.JSON || format == formatter.TemplateJSON {
|
||||
opts.format = formatter.JSON
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ func runVersion(cmd *cobra.Command, version string) {
|
|||
case formatter.PRETTY, "":
|
||||
versionString = strings.Replace(getOutFromMoby(cmd, fixedPrettyArgs(os.Args[1:])...),
|
||||
"\n Version:", "\n Cloud integration: "+displayedVersion+"\n Version:", 1)
|
||||
case formatter.JSON, "{{json.}}": // Try to catch full JSON formats
|
||||
case formatter.JSON, formatter.TemplateJSON: // Try to catch full JSON formats
|
||||
versionString = strings.Replace(getOutFromMoby(cmd, fixedJSONArgs(os.Args[1:])...),
|
||||
`"Version":`, fmt.Sprintf(`"CloudIntegration":%q,"Version":`, displayedVersion), 1)
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue