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: add validation for invalid definition attribute #6029

Merged
merged 2 commits into from
May 24, 2023

Conversation

Somefive
Copy link
Collaborator

Description of your changes

For definition with invalid attributes, vela def apply will report error now.

$ cat <<EOF | vela def apply -                                                                  
"bad-trait": {
        type: "trait"
        annotations: {}
        labels: {
                "ui-hidden": "true"
        }
        description: "Bad trait."
        attributes: {
                podDisruptive: true
                attributes: { // wrong format
                        appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"]
                }
        }
}
template: {
        parameter: {}
}
EOF
Error: failed to parse CUE for definition: invalid definition spec: json: unknown field "attributes"

Fixes #4544

I have:

  • Read and followed KubeVela's contribution process.
  • Related Docs updated properly. In a new feature or configuration option, an update to the documentation is necessary.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

Special notes for your reviewer

@codecov
Copy link

codecov bot commented May 23, 2023

Codecov Report

Patch coverage: 75.00% and project coverage change: -0.02 ⚠️

Comparison is base (f080f80) 60.99% compared to head (b4790dc) 60.98%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6029      +/-   ##
==========================================
- Coverage   60.99%   60.98%   -0.02%     
==========================================
  Files         225      225              
  Lines       31368    31391      +23     
==========================================
+ Hits        19134    19143       +9     
- Misses      10459    10474      +15     
+ Partials     1775     1774       -1     
Flag Coverage Δ
core-unittests 56.11% <75.00%> (-0.03%) ⬇️
e2e-multicluster-test 25.04% <0.00%> (+0.02%) ⬆️
e2etests 25.20% <ø> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/definition/definition.go 72.47% <75.00%> (+0.07%) ⬆️

... and 9 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Signed-off-by: Somefive <yd219913@alibaba-inc.com>
@Somefive Somefive force-pushed the feat/definition-validate branch 2 times, most recently from 29bd3db to 28a1192 Compare May 23, 2023 10:07
Signed-off-by: Somefive <yd219913@alibaba-inc.com>
@Somefive Somefive merged commit 0df7803 into kubevela:master May 24, 2023
22 checks passed
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.

[Feature] Enhance vela def for definition validation
3 participants