Skip to content

Too much whitespace in new-app description #13492

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

Closed
smarterclayton opened this issue Mar 21, 2017 · 11 comments
Closed

Too much whitespace in new-app description #13492

smarterclayton opened this issue Mar 21, 2017 · 11 comments

Comments

@smarterclayton
Copy link
Contributor

This wasn't happening earlier in the release.

$ oc new-app --template=kube-system/heapster-standalone
--> Deploying template "kube-system/heapster-standalone" for "kube-system/heapster-standalone" to project myproject

     Heapster Metrics (Standalone)
     ---------
     A simple metrics solution for an OpenShift cluster. Expects to be installed in the 'kube-system' namespace.



     * With parameters:
        * MASTER_URL=https://kubernetes.default.svc
        * IMAGE_PREFIX=openshift/origin-
        * IMAGE_VERSION=latest
        * METRIC_RESOLUTION=15s
        * STARTUP_TIMEOUT=500
        * NAMESPACE=kube-system
@bparees
Copy link
Contributor

bparees commented Mar 21, 2017

you sure at least some of those newlines aren't in the template description? I only see 2:

$ oc new-app -f application-template-stibuild.json 
--> Deploying template "brokersdk/ruby-helloworld-sample" for "application-template-stibuild.json" to project brokersdk

     ruby-helloworld-sample
     ---------
     This example shows how to create a simple ruby application in openshift origin v3


     * With parameters:

@smarterclayton
Copy link
Contributor Author

This looks wrong: #13380

@bparees
Copy link
Contributor

bparees commented Mar 22, 2017

This looks wrong: #13380

@smarterclayton is that what you intended to link? it seems unrelated to this issue so i don't know if you're saying that PR (retrying pull image actions) is also wrong or you linked the wrong thing.

@bparees
Copy link
Contributor

bparees commented Mar 22, 2017

the only recent change that might affect the output is this:
https://github.com/openshift/origin/blame/master/pkg/generate/app/cmd/template.go#L44

perhaps the decode is injecting an empty message field in the result object that results in extra newlines being printed out.

@smarterclayton
Copy link
Contributor Author

smarterclayton commented Mar 22, 2017 via email

@bparees
Copy link
Contributor

bparees commented Mar 22, 2017

@smarterclayton yeah should be, the current code doesn't do that (just checks for len(0))

@gabemontero
Copy link
Contributor

There is a new line in the text being returned by description := result.Annotations["description"] at https://github.com/openshift/origin/blob/master/pkg/generate/app/cmd/template.go#L72

I confirmed by adding a temporary glog.V(0).Infof("Descr is %s additional text", description) ... the "additional text" was on a different line

Additional lines are inserted by https://github.com/openshift/origin/blob/master/pkg/generate/app/cmd/template.go#L80 and https://github.com/openshift/origin/blob/master/pkg/generate/app/cmd/template.go#L86 in this particular example.

There were no injections from the decode stuff that I could find.

Removing https://github.com/openshift/origin/blob/master/pkg/generate/app/cmd/template.go#L86 seems like a no brainer to me. It does look less awkward with just that change.

Do we want to chase down the new line in the annotation? In theory, we could make some of the fmt.Fprintln(out) conditional based on some analysis of the \n in the strings printed ... but perhaps that is excessive.

@bparees
Copy link
Contributor

bparees commented Mar 24, 2017

There were no injections from the decode stuff that I could find.

yeah in hindsight the decode is only operating on the objects, not the template fields themselves. but i see no other reason for this to have changed.

I do think it makes sense to just print the newline if the string itself does not end in a newline.

but i'm still not seeing how clayton's example gets to 3 blank lines:

somedescription\n (field value includes a newline)
blank (from fmt.Println after printing the description)
blank (from fmt.Println after printing message+description)
blank (from ??? possibly from printing an empty message?)

  • with parameters blah blah

your proposal would get us down to 2 blanks, but we really should be at one.

(assuming i'm reading all this correctly)

@gabemontero
Copy link
Contributor

gabemontero commented Mar 24, 2017 via email

@gabemontero
Copy link
Contributor

Yep formatString is also adding additional lines. Hope to have something to review before EOB today.

@gabemontero
Copy link
Contributor

Also, upon further review, I think formatString is trying to account for whether the string ends with a new line.

Between the fix I have there, plus the removal on one unneeded fmt.Fprintf(out) we should be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants