Skip to content

Errors ignore output string type #332

@mbaum0

Description

@mbaum0

If a configuration is missing 'apiversion', 'type', etc, keys, kubeval dumps the issue to log.Error, prints null, and exits.
When the -o flag is specified as json, I would expect kueval to report the error in json format.

Example

# test.yaml

apiVersion: apps/v1
#kind: Deployment
metadata:
  name: sandbox
spec:
  replicas: astring
  selector:
    matchLabels:
      app: sandbox
  template:
    metadata:
      labels:
        app: moda-sandbox
    spec:
      dnsPolicy: Default
      containers:
      - name: sandbox
        image: sandbox
        ports:
        - name: http
          containerPort: 8080
          protocol: TCP
        envFrom:
          - configMapRef:
              name: kube-cluster-metadata

Current output:

$ ./bin/kubeval -d test.yaml -o json
ERR  - test.yaml: Missing 'kind' key
null

Possible JSON output:

$ ./bin/kubeval -d test.yaml -o json
[
        {
                "filename": "test.yaml",
                "kind": "Deployment",
                "status": "invalid",
                "errors": [
                        "spec.replicas: Missing 'kind' key"
                ]
        }
]

Metadata

Metadata

Assignees

No one assigned

    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