Kuadrant / kuadrantctl

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

[BREAKING CHANGE] root level kuadrant extensions #78

Closed eguzki closed 1 month ago

eguzki commented 2 months ago

What

[BREAKING CHANGE] Openapi info level kuadrant extensions moved to root level

Requires #77 first

Added some happy path tests

Verification Steps

jasonmadigan commented 2 months ago

cheers for verification steps, looks good:

cat << EOF > openapi.yaml            git:(openapi-kuadrant-extensions-at-root|⚑3)
---
openapi: "3.0.3"
info:
  title: "Pet Store API"
  version: "1.0.0"
x-kuadrant:
  route:
    name: "petstore"
    namespace: "petstore-ns"
    hostnames:
      - example.com
    parentRefs:
      - name: gw
        namespace: gw-ns
servers:
  - url: https://example.io/v1
paths:
  /cat:
    x-kuadrant:  ## Path level Kuadrant Extension
      backendRefs:
        - name: petstore
          port: 80
          namespace: petstore
    get:  # Added to the route and rate limited
      operationId: "getCat"
      responses:
        405:
          description: "invalid input"
  /dog:
    get:  # Added to the route and rate limited
      x-kuadrant:  ## Operation level Kuadrant Extension
        backendRefs:
          - name: petstore
            port: 80
            namespace: petstore
      operationId: "getDog"
      responses:
        405:
          description: "invalid input"
EOF

➜  kuadrantctl git:(openapi-kuadrant-extensions-at-root -> upstream/openapi-kuadrant-extensions-at-root) ✗ cat openapi.yaml                  git:(openapi-kuadrant-extensions-at-root|…1⚑3
---
openapi: "3.0.3"
info:
  title: "Pet Store API"
  version: "1.0.0"
x-kuadrant:
  route:
    name: "petstore"
    namespace: "petstore-ns"
    hostnames:
      - example.com
    parentRefs:
      - name: gw
        namespace: gw-ns
servers:
  - url: https://example.io/v1
paths:
  /cat:
    x-kuadrant:  ## Path level Kuadrant Extension
      backendRefs:
        - name: petstore
          port: 80
          namespace: petstore
    get:  # Added to the route and rate limited
      operationId: "getCat"
      responses:
        405:
          description: "invalid input"
  /dog:
    get:  # Added to the route and rate limited
      x-kuadrant:  ## Operation level Kuadrant Extension
        backendRefs:
          - name: petstore
            port: 80
            namespace: petstore
      operationId: "getDog"
      responses:
        405:
          description: "invalid input"
➜  kuadrantctl git:(openapi-kuadrant-extensions-at-root -> upstream/openapi-kuadrant-extensions-at-root) ✗ make install                      git:(openapi-kuadrant-extensions-at-root|…1⚑3
go fmt ./...
go vet ./...
GOBIN=/Users/jmadigan/Work/kuadrantctl/bin go install

➜  kuadrantctl git:(openapi-kuadrant-extensions-at-root -> upstream/openapi-kuadrant-extensions-at-root) ✗ bin/kuadrantctl generate gatewayapi httproute --oas openapi.yaml

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  creationTimestamp: null
  name: petstore
  namespace: petstore-ns
spec:
  hostnames:
  - example.com
  parentRefs:
  - name: gw
    namespace: gw-ns
  rules:
  - backendRefs:
    - name: petstore
      namespace: petstore
      port: 80
    matches:
    - method: GET
      path:
        type: Exact
        value: /v1/cat
  - backendRefs:
    - name: petstore
      namespace: petstore
      port: 80
    matches:
    - method: GET
      path:
        type: Exact
        value: /v1/dog
status:
  parents: null
eguzki commented 2 months ago

Given the backwards compat change, we'll tag as 0.3.0?

Following semantic versioning rules, we can't. But it is not ready yet for v1.0.0, is it?

I believe that v0.X.Y means alpha and braking changes can occur. So, semantic versioning should start on v1.X.Y. But whatever is fine with me

jasonmadigan commented 1 month ago

I believe that v0.X.Y means alpha and braking changes can occur. So, semantic versioning should start on v1.X.Y. But whatever is fine with me

Yeah, you're right - I'd forgotten that everything in v0 in semver is considered unstable. Patch version bump probably fine.