Add a check around default-cr (apply) to check to ensure the JSON is properly embedded in a "data" named element. #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Added a validation around user input to the
splicectl apply default-cr
command. The input specified by --file will now be validated for a top level 'data' element. No actual validation of the contents of the data element occurs, only the verification that it exists and that there is no 'data' element as its immediate child, which would likely indicate an accidental double nesting of the default-cr.Motivation and Context
This will prevent the passing of some potentially invalid default-crs to the splicectl/api and serve as an early warning that the input file is invalid. Specific errors are returned based on what splicectl is able to identify is wrong with the input, which should help users be able to quickly identify and fix their issue.
See DBAAS-5601
Dependencies
How Has This Been Tested?
A test case for each unique type of error that is to be expected has been created and exists in the apply_test.TestValidateDefaultCR() function. I also manually tested this with the splicectl tool on a live db as well and get the expected errors when providing invalid inputs.
Checklist
If the pull request includes user-facing changes, extra documentation is required:
Changelog Inclusions
Changes
--file input for the
splicectl apply default-cr
command is now partially validated before being sent to the splicectl/api.Checklist