-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Adding a field to templates to allow them to deliver a user message w… #9708
Adding a field to templates to allow them to deliver a user message w… #9708
Conversation
Consider the following template: https://gist.github.com/jupierce/4ce49e0f46f8647d798c3db5b6fa42e9
In addition to new-app changes, the feature seemed to call for the PostProcessMessage to be displayed after "oc process", but the existing output of 'process' does not lend itself to that behavior. "oc process" presently displays the list of objects extracted from the transformed template instead of the full template: https://gist.github.com/jupierce/74dab02e628f80d55fc9d94c8086dc9a I could see us doing any of the following for oc process:
|
Please let me know your thoughts @bparees @smarterclayton |
@@ -13,6 +13,9 @@ type Template struct { | |||
unversioned.TypeMeta | |||
kapi.ObjectMeta | |||
|
|||
// Optional: An instructional message for the user processing this template (escaped parameters will be substitued). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
escaped parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing to "An instructional message for the user processing this template (parameter substitution will be performed)." for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about: "An instructional message for the user that will be displayed when the template is instantiated (parameter substitution will be performed)."
(technically it is true that the message is handled during processing, but the only clients that are going to display the message are clients that are doing actual instantiation. If the user just runs "oc process" on the template, the message will not be explicitly displayed).
a few nits/open question but mostly looks good. please update one of the existing tests to also validate this new logic (hopefully we have an appropriate one that does parameter substitution testing already). |
@@ -24841,6 +24841,10 @@ | |||
"$ref": "v1.ObjectMeta", | |||
"description": "Standard object's metadata." | |||
}, | |||
"postProcessMessage": { | |||
"type": "string", | |||
"description": "Optional: An instructional message for the user processing this template (escaped parameters will be substitued)." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any good go spell-checkers out there? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not to worry, we have a large contingent of high-functioning OCD sufferers in this org.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you mean CDO (alphabetized, like it should be)
|
@@ -946,6 +955,8 @@ func (d *TemplateDescriber) DescribeTemplate(template *templateapi.Template) (st | |||
formatMeta(out, template.ObjectMeta) | |||
out.Write([]byte("\n")) | |||
out.Flush() | |||
d.DescribePostProcessMessage(template.PostProcessMessage, out) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the parameters seem more important than the post process message, and the message is likely to be longish, so I'd put it after the params
@bparees @jupierece As a good developer that I am I usually just look at the end of the output of new-app so I would move this mage right to the end to make it easier to catch attention of the user. |
@jorgemoralespou That was definitely my intent at the outset; however, new-app has two characteristics which pointed me to the current implementation: |
+1 @jupierce, was going to say something similar. you could also new-app multiple things, some of which are templates and some are not. |
// Objects is an array of objects to include in this template. Required. | ||
// PostProcessMessage is an optional instructional message for the user | ||
// processing this template (parameter substitution will be performed). | ||
PostProcessMessage string `json:"postProcessMessage,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PostProcess is too technical, I'd want someone who is a brand new user to figure it out. Message is probably sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a longer description that captures why someone would use this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the lowercase names in godoc so the messages in swagger match the JSON
We already need to do better error detection in new-app (for instance, new app should not run without --confirm if objects already exist). So in the future we'll have a better idea of whether we'll fail or not before we do the actual processing. We're not optimizing for the multiple template case, but we should be aware of it. If the experience is better for an end user on the single template case if it's at the end, that's where we should show it. |
it's better until:
|
On Jul 6, 2016, at 7:12 PM, Ben Parees [email protected] wrote: If the experience is better for an end user on the single template case if it's better until:
We can fix new-app. Making the code better is a time thing, but usability
I don't think I agree. Anyone who provides a template message almost — |
i fully expect a significant portion will contain "this is my template message" or whatever content we put in a sample template that they copied. or "creates a foo and a bar" i don't think you can assume that just because the template message field is non empty, it's therefore properly spec'd and useful. and in any case my argument is primarily one of expediency. We have finite time, this isn't worth the refactoring effort/code complexity. (particularly in light of this being turned into some sort of magic special case that only happens when we're instantiating a single template, because for any other case it's absolutely the wrong thing to do). |
in case it is still not clear: i am not disagreeing that for the single scenario of "i'm using new-app to instantiate a single template that has a useful message and nothing else" printing the message last is preferable. I am arguing that it's not worth the code churn, particularly in light of all the cases in which is not useful which we'd either have to special case out (more code churn), or accept resulted in a worse experience for those cases. |
I don't, and we aren't designing for that. We do not add features and then On Wed, Jul 6, 2016 at 7:47 PM, Ben Parees [email protected] wrote:
|
I'm not a big fan of "well, we didn't have much time, so we did a hack job On Wed, Jul 6, 2016 at 8:29 PM, Clayton Coleman [email protected] wrote:
|
The current implementation is not a "hack job", it positions the output in the same location as the other output related to the template that was processed.. And i'm not a big fan of "we spent 3 days moving a line of text down slightly in the output instead of fixing 3 other issues in the product, and in the process we ensured that the next time we have to touch this code, it's going to consume extra time for someone because now it's more complicated than it needed to be" here are 21 open CLI issues that contain the word "new-app" that we could work on instead of reworking this implementation because we don't think our users are capable of reading 10 lines of text: |
regarding oc process, yes it should be left as is, it's primary use case is to be piped into oc create or oc apply, so it does not make sense to have it outputting this message. The message is intended for new-app instantiation and web console instantiation. oc process is definitely an advanced user flow at this point. |
If we add a message intended for end users, and we put it in the wrong On Wed, Jul 6, 2016 at 8:49 PM, Ben Parees [email protected] wrote:
|
i think we should split the new-app updates out of this PR so we can move forward w/ the api+parameter substitution changes, regardless of what we decide to do w/ the new-app output. that way @jwforres can pick up this change for the web console sooner than later. |
Changes: |
lgtm, can you remove the new-app change for now, we'll get api sign-off and merge this, and then @smarterclayton and I will resume our battle royale in your follow-up PR? |
New commit removes changes from new-app. As a new user of the system I will throw in my impression: it doesn't seem like I should have needed to use new-app at all. I would have expected an incarnation of "oc create" to allow me to process a local template file and the user message to be printed as its last step. |
@@ -14,15 +14,23 @@ type Template struct { | |||
// Standard object's metadata. | |||
kapi.ObjectMeta `json:"metadata,omitempty"` | |||
|
|||
// Objects is an array of objects to include in this template. Required. | |||
// message is an optional instructional message that will | |||
// be displayed when this template is instantiated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by instantiated? You can't output this message in the oc process template | oc create -f
flow, right? We're adding a template API field for the the new-app
only flow? @jwforres would need to special case this in the webconsole too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you be happier with "optional message that may be displayed depending which client you use and whether it bothers to support this field"?
Yeah, along with, "in our default client, we ignore this in the default processing/creation workflow".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
our default client is new-app and it's not going to ignore it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
our default client is new-app and it's not going to ignore it.
As opposed the oc process
command we built specifically to instantiate templates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct. oc process got deprecated when @smarterclayton decided to add template processing to new-app.
oc process is for advanced users who want to pipe to oc apply or something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Instantiated - my initial wording was "processed", but it was suggested that the only reason we process templates is to instantiate the underlying objects in etcd.
- Correct, the present implementation does not attempt to output the message during "oc process" (or create). Only targeting new-app and the web console with @jwforres 's help.
oc create is not going to instantiate a template, because oc create creates resources, and a template definition is a resource, so oc create template will always create a template resource, not instantiate them. I agree it's slightly confusing to a new user to distinguish between "creating a template" (which we called "registering" or "installing" it) and instantiating a template, but I don't see us special casing oc create behavior in the case of a template resource because you'd still need a way to declare your intention to register the template when that is what you want to do. |
Neither do I. I would picture having an |
Having it on individual objects would also give a spot for anyone at any later date to have a field that amounts to a description of what the resource actually is or is trying to do. Putting it on a template instead means you get it once and you better pay attention. |
@bparees Completely agree on preserving the behavior of "oc create -f" to allow advanced users to create a Template resource. Merely suggesting a short-cut for new users: |
interesting, though I wouldn't want a getting started message that included a substituted in admin username and generated password to be persisted as an object annotation |
You could do worse than, "... (default username/password is admin/admin". Also, I'd expect people to be at least trying to use their SA as an oauth client, so it would be "... login with your openshift credentials". |
@deads2k: can you take this topic to another issue/proposal? |
I see it as a replacement for this pull, not an addition to it. Why would I want this feature if I had descriptions or creation messages on any API object and the existing template substitution logic? |
because what you're proposing is way more tedious for a template author. "this template creates a route with hostname vs putting all that stuff on random resources within the template and who knows how it gets displayed to the user. |
Do you have a better example? That just turns into an annotation on the route:
Looks like the same amount of work. |
you haven't solved the problem of how all these random annotations get presented to the user in a cohesive way. |
Let's have an in person discussion. |
@@ -870,6 +870,15 @@ type TemplateDescriber struct { | |||
kctl.ObjectDescriber | |||
} | |||
|
|||
// DescribePostProcessMessage prints the message that will be parameter substituted and displayed to the | |||
// user when this template is processed. | |||
func (d *TemplateDescriber) DescribePostProcessMessage(msg string, out *tabwriter.Writer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to DescribeMessage(...)
API approved but one minor code change |
…ith parameters substituted
// Parameter substitution will be performed on the message before being | ||
// displayed so that generated credentials and other parameters can be | ||
// included in the output. | ||
Message string `json:"message,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to start this godoc w/ "message"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bparees It appears to in my view of the commit. There are several inline comments that split the full godoc in half in the github diff view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, you're right, it was just such a natural start to the comment I didn't think to scroll up, my bad.
one nit and lgtm. |
Evaluated for origin test up to 34a3c56 |
[merge] |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/6071/) (Image: devenv-rhel7_4567) |
Evaluated for origin merge up to 34a3c56 |
continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/6054/) |
…ith parameters substituted