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

Fix stuttering output when supplying multiple files as input #172

Merged
merged 3 commits into from
Aug 13, 2019

Conversation

brendanjryan
Copy link
Contributor

Fixes a logging control flow bug which would result in multiple "output sets" being produced when supplying multiple input files. For example, an invocation with three files and -o json would produce three distinct arrays of output, instead of a single array.

Before:

⇒  ./bin/kubeval -o json fixtures/valid.yaml fixtures/invalid.yaml
[
        {
                "filename": "fixtures/valid.yaml",
                "kind": "ReplicationController",
                "status": "valid",
                "errors": []
        }
]
[
        {
                "filename": "fixtures/invalid.yaml",
                "kind": "ReplicationController",
                "status": "invalid",
                "errors": [
                        "spec.replicas: Invalid type. Expected: [integer,null], given: string"
                ]
        }
]

After:

⇒  bin/kubeval -o json fixtures/valid.yaml fixtures/valid.yaml
[
        {
                "filename": "fixtures/valid.yaml",
                "kind": "ReplicationController",
                "status": "valid",
                "errors": []
        },
        {
                "filename": "fixtures/valid.yaml",
                "kind": "ReplicationController",
                "status": "valid",
                "errors": []
        }
]
⇒  ./bin/kubeval -o json fixtures/valid.yaml fixtures/invalid.yaml fixtures/multi_valid.yaml 
[
        {
                "filename": "fixtures/valid.yaml",
                "kind": "ReplicationController",
                "status": "valid",
                "errors": []
        },
        {
                "filename": "fixtures/invalid.yaml",
                "kind": "ReplicationController",
                "status": "invalid",
                "errors": [
                        "spec.replicas: Invalid type. Expected: [integer,null], given: string"
                ]
        },
        {
                "filename": "fixtures/multi_valid.yaml",
                "kind": "Service",
                "status": "valid",
                "errors": []
        },
        {
                "filename": "fixtures/multi_valid.yaml",
                "kind": "ReplicationController",
                "status": "valid",
                "errors": []
        },
        {
                "filename": "fixtures/multi_valid.yaml",
                "kind": "Service",
                "status": "valid",
                "errors": []
        },
        {
                "filename": "fixtures/multi_valid.yaml",
                "kind": "ReplicationController",
                "status": "valid",
                "errors": []
        },
        {
                "filename": "fixtures/multi_valid.yaml",
                "kind": "Service",
                "status": "valid",
                "errors": []
        },
        {
                "filename": "fixtures/multi_valid.yaml",
                "kind": "ReplicationController",
                "status": "valid",
                "errors": []
        },
        {
                "filename": "fixtures/multi_valid.yaml",
                "kind": "",
                "status": "skipped",
                "errors": []
        },
        {
                "filename": "fixtures/multi_valid.yaml",
                "kind": "",
                "status": "skipped",
                "errors": []
        }
]

@brendanjryan
Copy link
Contributor Author

cc @garethr

@garethr
Copy link
Collaborator

garethr commented Aug 13, 2019

Thanks for catching, and the fix.

@garethr garethr merged commit 34b303a into instrumenta:master Aug 13, 2019
@brendanjryan brendanjryan deleted the bjr-multi-json branch August 19, 2019 18:27
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

Successfully merging this pull request may close these issues.

2 participants