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.
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"] ```
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...
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.
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?
(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).
1. Create ConsoleYAMLSample instance with yaml in comment #1 2. Goes to Workloads -> Pods -> Create Pods -> click Try It button in Samples An error modal will prompt and show Failed to Parse YAML Sample Verified on 4.4.0-0.nightly-2019-12-15-184910
Created attachment 1645420 [details] ModalShowingError
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2020:0581