Kuadrant / kuadrantctl

Kuadrant configuration command line utility
Apache License 2.0
6 stars 12 forks source link

X-kuadrant section is not required #96

Open pehala opened 2 weeks ago

pehala commented 2 weeks ago

Version: 0.2.4-alpha If you use OAS from previous version (x-kuadrant), the x-kuadrant section will be missing and thus is will generate invalid HTTPRoute without name, which will get rejected by Kubernetes Server. Correct behaviour would be to make x-kuadrant section required and throw error in OAS parsing.

Current behavior makes it hard to deduce what is wrong.

apply returned an error: error: error when retrieving current configuration of:
Resource: "gateway.networking.k8s.io/v1, Resource=httproutes", GroupVersionKind: "gateway.networking.k8s.io/v1, Kind=HTTPRoute"
Name: "", Namespace: "kuadrant"
from server for: "STDIN": resource name may not be empty

Reproducer:

Input:

info:
  title: Httpbin
  version: 0.0.51
  x-kuadrant:
    route:
      hostnames:
      - hostname-phala--qwvt.test.com
      name: route-phala--b6zk
      parentRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: gw-phala--dnfu
        namespace: kuadrant
openapi: 3.1.0
paths:
  /anything:
    get:
      operationId: get_anything
      responses:
        '200':
          content:
            application/json:
              schema:
                type: string
          description: Successful Response
    put:
      operationId: put_anything
      responses:
        '200':
          content:
            application/json:
              schema:
                type: string
          description: Successful Response
  /get:
    get:
      operationId: get_get
      responses:
        '200':
          content:
            application/json:
              schema:
                type: string
          description: Successful Response

Output:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  creationTimestamp: null
spec:
  rules:
  - backendRefs:
    - group: ""
      kind: Service
      name: httpbin-phala--cxfq
      namespace: kuadrant
      port: 8080
    matches:
    - method: GET
      path:
        type: Exact
        value: /get
    matches:
    - method: GET
      path:
        type: Exact
        value: /anything
    matches:
    - method: PUT
      path:
        type: Exact
        value: /anything
status:
  parents: null