-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Template examples do not have metadata:name field #7071
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
Conversation
dev_guide/templates.adoc
Outdated
objects: | ||
- kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
annotations: | ||
template.openshift.io/expose-username: "{.data['my\.username']}" | ||
template.openshift.io/expose-username: "{.data['my.username']}" |
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 suspect the backslash was intentional/necessary. @jim-minter ?
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.
(perhaps it needs to be double escaped, however)
need @jim-minter to weigh in on the blacklash, the rest seems ok to me. |
@bparees @jim-minter I get the following error with the \
|
Hold this for a little while please. The backslash is intentional, it is illustrating a comment in the document immediately above it. If doubled up, the backslash is accepted by |
No client error (https://blog.plover.com/prog/compiler-error.html), and I've learned a new detail about yaml 😬 From http://www.yaml.org/spec/current.html#id2517668: "escape sequences are only interpreted in double quoted scalars. In all other scalar styles, the “\” character has no special meaning and non-printable characters are not available." So OpenShift's behaviour here is correct; I got our documentation wrong. @mburke5678 please could I ask you to:
Depending on how the JSONPath expression is then written in YAML, an additional backslash may be required, e.g. `"{.data['my\\.key']}"`. Thanks! |
@jim-minter @bparees PTAL |
/lgtm :) |
thanks! |
@xiuwang Is this your area? Can you take a look at my changes? |
@@ -671,12 +676,14 @@ The following is an example of different objects' fields being exposed: | |||
---- | |||
kind: Template | |||
apiVersion: v1 | |||
metadata: | |||
name: my-template | |||
objects: | |||
- kind: ConfigMap | |||
apiVersion: v1 | |||
metadata: |
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 define objects.metadata.name here
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.
@xiuwang PTAL
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.
@mburke5678 Other objects in this template also need add objects.metadata.name
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.
@xiuwang I added an objects.metadata.nameto each object in the template. Is name required? The
oc create -f`appears to have worked without the names.
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.
@mburke5678 LGTM now
No error when 'oc create -f ' without objects.metadata.name, but will prompt error when 'oc new-app <above_template>'
error: ConfigMap "" is invalid: metadata.name: Required value: name or generateName is required
error: Secret "" is invalid: metadata.name: Required value: name or generateName is required
error: Service "" is invalid: metadata.name: Required value: name or generateName is required
error: Route "" is invalid: [metadata.name: Required value: name or generateName is required, spec.path: Invalid value: "mypath": path must begin with /, spec.to.name: Required value]
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.
@jim-minter i think we should first determine which version of oc client it effects. "oc create -f" is effectively doing server side validation. "oc new-app" is effectively doing client side validation, so if you're using a 3.5 client and a 3.7 server, you're getting different validation versions.
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.
More coffee needed. I don't think there's a bug here. oc create <template object>
doesn't verify that objects[*].metadata.name exist (in any case, any could be parameterised, and the parameter could be left empty at process time). oc process <template object> | oc create -f -
will error out if any object has no name. oc new-app
is correctly effectively doing the latter.
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.
+1
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 missed the nuance of what object was actually being created also)
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.
@mburke5678 Thanks all of you, LGTM now
[rev_history] |
092daa5
to
b904e40
Compare
@openshift/team-documentation PTAL |
LGTM! 🎆 |
(cherry picked from commit b904e40) xref:openshift#7071
(cherry picked from commit b904e40) xref:openshift#7071
…BA-2017-31888-for-3-6 Added release notes for 3.6.173.0.96 async release xref:openshift#7071
(cherry picked from commit b904e40) xref:openshift#7071
(cherry picked from commit b904e40) xref:openshift#7071
….6-stage [online-3.6] correct documented 'git clone' behaviour xref:openshift#7071
(cherry picked from commit b904e40) xref:openshift#7071
(cherry picked from commit b904e40) xref:openshift#7071
(cherry picked from commit b904e40) xref:openshift#7071
@mfojtik @bparees If this is in your area, please advise if these changes are correct:
I was working with the templates topic in the Dev Guide and was getting an error for a few examples:
The Template "" is invalid: metadata.name: Required value: name or generateName is required
I added a metadata:name field and the template was created.
Also, I got a YAML error on one example, and I needed to remove the \ in "{.data['my.username']}"