k8s-operatorhub / operatorhub.io

The OperatorHub.io website
Apache License 2.0
17 stars 12 forks source link

Operator preview CRD tiles do not display the correct examples for CRDs with more than 1 apiVersion #56

Open fanny-jiang opened 11 months ago

fanny-jiang commented 11 months ago

Describe the bug We maintain the Datadog Agent Operator and one of its CRDs (DatadogAgent) has two versions,v2alpha1 (new) and v1alpha1 (old). Both CRDs are included in the clusterserviceversion.yaml and when alm-examples are provided for each CRD version, only the 1st listed example is displayed. This issue occurs in the https://operatorhub.io/preview page. I haven't pushed an updated clusterserviceversion.yaml file containing the new examples, so I haven't been able to confirm whether the problem occurs in the http://operatorhub.io listed operator tiles, but I can update the issue if I do see it happening

What did you do? A clear and concise description of the steps you took. For example, steps to reproduce the behavior:

  1. Go to 'https://operatorhub.io/preview'
  2. Paste contents of a clusterserviceversion.yaml file of CRDs containing more than 1 apiVersion for a given CRD kind. Example: https://gist.github.com/fanny-jiang/4f1829eb3262d47ebd64050a59fd7ec4
  3. Scroll down to 'Custom Resource Definitions'
  4. Click each tile for the given CRD (i.e. DatadogAgent).
  5. Observe that the 1st tile displays the 1st defined YAML example of the alm-examples list for the given CRD kind: DatadogAgent, showing apiVersion: v1alpha1
  6. Observe that the 2nd tile also displays the YAML example for apiVersion: v1alpha1

What did you expect to see? I expected to see one CRD tile for each apiVersion of a given CRD kind name displaying the YAML example corresponding to its apiVersion. Tile 1 with name DatadogAgent should display a YAML example for apiVersion: v1alpha1. Tile 2 with the name DatadogAgent should display a YAML example for apiVersion: v2alpha.

What did you see instead? Instead, I see 2 CRD tiles with the kind: DatadogAgent, both displaying YAML examples for apiVersion: v1alpha1.

Additional context I notice that when I switch the order of the examples in the alm-examples list, whichever is listed first is displayed in the UI. For example, if the example for v2alpha1 is listed before v1alpha1, the UI displays v2alpha1, and vice versa.

alm-examples: |-
      [
        <v2alpha2_example>,   <= displayed in UI
        <v1alpha1_example>,
        ...
      ]