Skip to content

Incorrectly parsing Knative Service YAML in 1.4.0 #2670

@0x5457

Description

@0x5457

Describe the bug
When using the loadYaml method to parse a Knative Service YAML, version 1.4.0 incorrectly handles the parsing and loses the spec content. This appears to be a regression as it works correctly in version 1.3.0.

Client Version
e.g. 1.4.0

Server Version
e.g. N/A

To Reproduce
Steps to reproduce the behavior:

const k8s = require('@kubernetes/client-node');

const x = k8s.loadYaml(`apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: hello-world
spec:
  template:
    spec:
      containers:
        - image: ghcr.io/knative/helloworld-go:latest
          ports:
            - containerPort: 8080
          env:
            - name: TARGET
              value: "World"`);
console.log(JSON.stringify(x, null, 2));

Actual Behavior (1.4.0)

{
  "apiVersion": "serving.knative.dev/v1",
  "kind": "Service",
  "metadata": {
    "name": "hello-world"
  },
  "spec": {}
}

Expected behavior (1.3.0)
The parsed object maintains the complete structure including all spec content:

{
  "apiVersion": "serving.knative.dev/v1",
  "kind": "Service",
  "metadata": {
    "name": "hello-world"
  },
  "spec": {
    "template": {
      "spec": {
        "containers": [
          {
            "image": "ghcr.io/knative/helloworld-go:latest",
            "ports": [
              {
                "containerPort": 8080
              }
            ],
            "env": [
              {
                "name": "TARGET",
                "value": "World"
              }
            ]
          }
        ]
      }
    }
  }
}

It appears that the parser might be incorrectly treating the Knative Service as a native Kubernetes Service, causing it to lose the Knative-specific spec configuration.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions