-
Notifications
You must be signed in to change notification settings - Fork 15
CLOUDP-306576: IPA-119: Multi-Cloud Support by Default #643
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new Spectral rule (IPA-119) to enforce that API producers do not set default values for cloud provider fields or parameters, thereby supporting multi-cloud by default.
- Implements the rule function in IPA119NoDefaultForCloudProviders.js
- Updates rule definitions in IPA-119.yaml and documentation in README.md
- Adds comprehensive tests in IPA119NoDefaultForCloudProviders.test.js and updates the overall rule suite in ipa-spectral.yaml
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tools/spectral/ipa/rulesets/functions/IPA119NoDefaultForCloudProviders.js | Implements the logic for detecting default values on provider fields or parameters with exception handling. |
| tools/spectral/ipa/rulesets/README.md | Documents the new rule and its usage. |
| tools/spectral/ipa/rulesets/IPA-119.yaml | Provides the rule metadata and configuration. |
| tools/spectral/ipa/ipa-spectral.yaml | Updates the rule suite to include the new IPA-119 rule. |
| tools/spectral/ipa/tests/IPA119NoDefaultForCloudProviders.test.js | Contains tests validating the new rule’s behavior. |
Comments suppressed due to low confidence (1)
tools/spectral/ipa/rulesets/functions/IPA119NoDefaultForCloudProviders.js:41
- Consider checking whether propertyObject.schema exists before accessing its 'default' property to avoid potential runtime exceptions when the schema is missing.
if (propertyObject.name === propertyNameToLookFor && propertyObject.schema.default !== undefined) {
wtrocki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - on behalf of copilot ;)
| severity: warn | ||
| message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-119-no-default-for-cloud-providers' | ||
| given: | ||
| # Target properties with "cloudProvider" in their name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw some examples of providerName is the spec as well, perhaps these can be included as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the enum check will capture the providerName parameters. For example: paths//api/atlas/v2/groups/{groupId}/containers/get/parameters/6
| ) { | ||
| try { | ||
| if (fieldType === 'properties') { | ||
| if (propertyName === propertyNameToLookFor && propertyObject.default !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: If there are no properties with the name cloudProvider, will this collect an adoption? Perhaps we should filter these out before the collectAndReturnViolation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's a good point! Let me open a PR for it
Proposed changes
Jira ticket: CLOUDP-306576
Found 8 violations, all of them input parameters
Checklist
Changes to Spectral
Further comments