+++ This bug was initially created as a clone of Bug #1776479 +++ Given a slightly incorrect block of YAML, within the ConsoleEXAMPLEYaml resource: ``````` apiVersion: console.openshift.io/v1 kind: ConsoleYAMLSample metadata: name: foo-pod-example spec: targetResource: apiVersion: v1 kind: Pod title: foo pod example description: our company's preferred foo pod yaml: >- apiVersion: v1 kind: Pod metadata: name: foo-pod-example labels: app: web foo: bar bar: baz spec: containers: - name: foo-pod-example image: foopod/example command: ["foo"] args: ["--example", "1"] ``````` Both the web console ConsoleYAMLSample create page && oc create -f - will accept the above as valid. However, when you attempt to use the example within the page (for example, go to create a Pod after creating the above sample), nothing happens. - Try It button does nothing. Page is not unresponsive, and there is no console error. - Download button does nothing. Again, no console error. It appears that the console is broken, when in fact, the YAML Sample is incorrect, but there is no indication that something needs to be fixed. How reproducible: Always Steps to Reproduce: 1. echo "the-above-text" | oc create -f - 2. alternatively, paste the above text into the custom resource create form 3. navigate to the pods page 4. click "create pod" 5. click "try it" in the sample sidebar Actual results: Console appears to do nothing Expected results: Console should either use my sample, or notify me that something is preventing the use of the sample. Note that I don't think we can truly validate the yaml prior to use. It is valid YAML (generically), but is invalid for the Pod use case. I imagine the console should just always use, but when the user submits the YAML we should show the validation error. --- Additional comment from Robb Hamilton on 2019-11-25 21:12:04 UTC --- The example(In reply to bpeterse from comment #0) > ``````` > apiVersion: console.openshift.io/v1 > kind: ConsoleYAMLSample > metadata: > name: foo-pod-example > spec: > targetResource: > apiVersion: v1 > kind: Pod > title: foo pod example > description: our company's preferred foo pod > yaml: >- > apiVersion: v1 > kind: Pod > metadata: > name: foo-pod-example > labels: > app: web > foo: bar > bar: baz > spec: > containers: > - name: foo-pod-example > image: foopod/example > command: ["foo"] > args: ["--example", "1"] > ``````` This should be: ``` apiVersion: console.openshift.io/v1 kind: ConsoleYAMLSample metadata: name: foo-pod-example spec: targetResource: apiVersion: v1 kind: Pod title: foo pod example description: our company's preferred foo pod yaml: >- apiVersion: v1 kind: Pod metadata: name: foo-pod-example labels: app: web foo: bar bar: baz spec: containers: - name: foo-pod-example image: foopod/example command: ["foo"] args: ["--example", "1"] ``` --- Additional comment from Robb Hamilton on 2019-11-25 21:22:25 UTC --- I believe this bug is occurring because Ben's example uses the yaml folded style block style indicator (`>`) instead of the literal block style indicator (`|`) in the yaml value, so the new lines get stripped. Not sure how we go about enforcing the use of the literal block style indicator... --- Additional comment from Samuel Padgett on 2019-12-02 14:12:14 UTC --- It looks like the indentation is wrong is the provided YAML. The `yaml` property should not be under `targetResource`, but one level up. It should be a required property, though. I'd expect that to fail validation. --- Additional comment from Samuel Padgett on 2019-12-02 14:14:42 UTC --- I get an error when I try to create that resource. > Error "Required value" for field "spec.description". Is there a copy/paste error in the YAML in the description? --- Additional comment from Robb Hamilton on 2019-12-02 14:16:45 UTC --- (In reply to Samuel Padgett from comment #3) > It looks like the indentation is wrong is the provided YAML. The `yaml` > property should not be under `targetResource`, but one level up. It should > be a required property, though. I'd expect that to fail validation. Ben's example is incorrect and does fail validation. I provided a corrected example in https://bugzilla.redhat.com/show_bug.cgi?id=1776479#c1. However, this corrected example fails due to the use of the folded style block indicator (see https://bugzilla.redhat.com/show_bug.cgi?id=1776479#c2).
*** This bug has been marked as a duplicate of bug 1779681 ***