Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors ignore output string type #332

Open
mbaum0 opened this issue Mar 1, 2022 · 1 comment
Open

Errors ignore output string type #332

mbaum0 opened this issue Mar 1, 2022 · 1 comment

Comments

@mbaum0
Copy link

mbaum0 commented Mar 1, 2022

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"
                ]
        }
]
@mbaum0
Copy link
Author

mbaum0 commented Mar 1, 2022

It looks like if apiversion or type aren't specified, it isn't possible to build the URL to download the appropriate schema. So kubeval fails fast and makes these checks before even testing against the schema

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant