intellij-kubernetes icon indicating copy to clipboard operation
intellij-kubernetes copied to clipboard

Disable schema validation for multi-resource documents provide alternative means of validation

Open adietish opened this issue 7 months ago • 0 comments

follows up on #630

Steps:

  1. EXEC: open the following in a yaml editor:
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    app.quarkus.io/build-timestamp: 2023-06-30 - 12:24:49 +0000
  labels:
    app.kubernetes.io/name: openshift-quickstart
    app.kubernetes.io/version: 1.0.0-SNAPSHOT
    app.kubernetes.io/managed-by: quarkus
  name: openshift-quickstart
spec:
  ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: 8080
    - name: https
      port: 443
      protocol: TCP
      targetPort: 8443
  selector:
    app.kubernetes.io/name: openshift-quickstart
    app.kubernetes.io/version: 1.0.0-SNAPSHOT
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    app.quarkus.io/build-timestamp: 2023-06-30 - 12:24:49 +0000
  labels:
    app.kubernetes.io/managed-by: quarkus
    app.kubernetes.io/version: 1.0.0-SNAPSHOT
    app.kubernetes.io/name: openshift-quickstart
  name: openshift-quickstart
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/version: 1.0.0-SNAPSHOT
      app.kubernetes.io/name: openshift-quickstart
  template:
    metadata:
      annotations:
        app.quarkus.io/build-timestamp: 2023-06-30 - 12:24:49 +0000
      labels:
        app.kubernetes.io/managed-by: quarkus
        app.kubernetes.io/version: 1.0.0-SNAPSHOT
        app.kubernetes.io/name: openshift-quickstart
    spec:
      containers:
        - env:
            - name: KUBERNETES_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          image: adietish/openshift-quickstart:1.0.0-SNAPSHOT
          imagePullPolicy: Always
          name: openshift-quickstart
          ports:
            - containerPort: 8080
              name: http
              protocol: TCP
            - containerPort: 8443
              name: https
              protocol: TCP
  1. EXEC: put your cursor to the 2nd resource, a Deployment
  2. EXEC: inspect the schema that is applied. It is shown in the right corner of the status bar:

Result: The schema that is applied still is Service (first resource in the document) image

Expected result: Schema validation should work correctly but there's no way to achieve this currently. YAML/Json-plugins are not capable of applying more than 1 schema to a document. There's a 1:1 mapping between document and schema currently. The jetbrains kubernetes plugin is using other means obviously. The editor reports that no schema is applied but schema validation happens. If you provide an invalid value (ex. replicas only allows integer values. a is therefore an invalid value) this value is therefore renderered in red.

Image

adietish avatar Mar 26 '25 11:03 adietish