Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue #4391; podman info --format '{{ json . }}' #4408

Merged
merged 1 commit into from
Nov 8, 2019

Conversation

slimjim2234
Copy link
Contributor

JSON Go template format now recognized through the info action.
Fixes issue #4391

@openshift-ci-robot
Copy link
Collaborator

Hi @slimjim2234. Thanks for your PR.

I'm waiting for a containers member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S labels Nov 1, 2019
@TomSweeneyRedHat
Copy link
Member

/approve

@TomSweeneyRedHat
Copy link
Member

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 1, 2019
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: slimjim2234, TomSweeneyRedHat

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 1, 2019
@@ -2,6 +2,7 @@ package main

import (
"fmt"
"strings"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a gofmt issue

@TomSweeneyRedHat
Copy link
Member

@slimjim2234 our ci requires that commits be signed. Please do git commit --amend -s and then repush.

Although I prefer the style you're using in cmd/podman/info.go for the switch, gofmt doesn't. Please do 'gofmt -s -w cmd/podman/info.go` and readd that, or just remove the added tabs.

@rhatdan
Copy link
Member

rhatdan commented Nov 1, 2019

Gofmt is not going to pass. I think we are using at least golang 1.12 or 1.13, so your gofmt might be out of date.

@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M and removed size/S needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 2, 2019
@@ -88,6 +89,9 @@ func infoCmd(c *cliconfig.InfoValues) error {

var out formats.Writer
infoOutputFormat := c.Format
if strings.Join(strings.Fields(infoOutputFormat), "") == "{{json.}}" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks strange, why do you need this strings processesing?
Whis is

if c.Format == "{{json.}}" {

Not enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the fix I used code from an approved merge found in PR #2688 which solved an nearly identical problem.
If that looks off to you then the other piece of code should change as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have verified that c.Format == "{{json.}}" does not work.
./bin/podman info --format '{{ json .}}'
Error: template parsing error: template: image:1: function "json" not defined

This fix is more-or-less a band-aid. Would it be worth investigating to determine the larger issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baude Why was this necessary? Is this just some because the c.Format is a StirngVarP? Versus a StringVar?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is special casing to support a strange Docker convention where --format '{{ json. }}' is the same as --format json.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for strings.Fields is whitespace removal.

@baude
Copy link
Member

baude commented Nov 2, 2019

could you add a test?

@slimjim2234
Copy link
Contributor Author

could you add a test?

What kind of test? I have committed a small and simple test validating the "{{ json . }}" format usage.

@rhatdan
Copy link
Member

rhatdan commented Nov 3, 2019

@slimjim2234 Thanks
Other then the question to @baude LGTM

@mheon
Copy link
Member

mheon commented Nov 3, 2019 via email

@rhatdan
Copy link
Member

rhatdan commented Nov 8, 2019

@mheon Any progress? @slimjim2234 Any chance of getting a test?

@mheon
Copy link
Member

mheon commented Nov 8, 2019

Code LGTM

@rhatdan
Copy link
Member

rhatdan commented Nov 8, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 8, 2019
@openshift-merge-robot openshift-merge-robot merged commit b713e53 into containers:master Nov 8, 2019
@mheon mheon mentioned this pull request Dec 2, 2019
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. ok-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants