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

feat: convert output to framework results #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

abdalazizmoh
Copy link

Hi 👋

This PR is for converting Json error output to Yaml format to be more readable

Build the tool

go build -o 'dist/kubeconformvalidator' .

Testing using /example directory :

cat example/krm-function-input.yaml| ./dist/kubeconformvalidator

The output display in framework.Results format:

apiVersion: config.kubernetes.io/v1
kind: ResourceList
items: []
functionConfig:
  kind: KubeconformValidator
  apiVersion: validators.kustomize.aabouzaid.com/v1alpha1
  metadata:
    name: validate
  spec:
    config:
      output: json
    args:
    - -strict
    - -output
    - text
results:
- message: expected integer, but got string
  severity: error
  resourceRef:
    kind: Service
    name: service-invalid
  field:
    path: /spec/ports/0/port
    proposedValue: 1
- message: expected integer, but got string
  severity: error
  resourceRef:
    kind: Service
    name: service2-invalid
  field:
    path: /spec/ports/0/port
    proposedValue: 1

Thanks

@aabouzaid aabouzaid self-requested a review June 15, 2023 22:10
@aabouzaid aabouzaid added the enhancement New feature or request label Jun 15, 2023
@aabouzaid
Copy link
Collaborator

aabouzaid commented Jul 23, 2023

@abdalazizmoh Your code looks good to me, but there is something odd when it's used in Kustomize (it could be a bug in Kustomize itself).

As I understand, if the plugin returned a non-empty ".results" and one of the items has a severity error, then Kustomize should exit with non-zero. 🤔

Maybe we need to verify that and understand what is the expected behavior in Kustomize.
Could you please make a PoC and open an issue in the Kustomize project? (after searching in case that's a known issue).

@aabouzaid aabouzaid changed the title Feat/convert output framework results feat: convert output to framework results Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants