feat: create FOASCLI sunset diff command#1206
Conversation
|
|
||
| type Diff struct { | ||
| Operation string `json:"http_method" yaml:"http_method"` | ||
| Path string `json:"path" yaml:"path"` |
There was a problem hiding this comment.
could we also include the base and and target spec file name? I think it would be a useful info to see
There was a problem hiding this comment.
Done, added to output diff, example:
[
{
"http_method": "GET",
"path": "/api/atlas/v2/groups/{groupId}/serverless",
"version": "2023-01-01",
"base_sunset_date": "2027-01-15",
"spec_sunset_date": "2027-01-18",
"base_spec": "../../../openapi/.raw/v2.json",
"spec": "../../../openapi/.raw/v2-qa.json",
"team": "Atlas Clusters Security III"
},
{
"http_method": "GET",
"path": "/api/atlas/v2/groups/{groupId}/serverless/{name}",
"version": "2023-01-01",
"base_sunset_date": "2027-01-15",
"spec_sunset_date": "2027-01-18",
"base_spec": "../../../openapi/.raw/v2.json",
"spec": "../../../openapi/.raw/v2-qa.json",
"team": "Atlas Clusters Security III"
},
]
| basePath: "../../../test/data/base_spec.json", | ||
| specPath: "../../../test/data/base_spec_with_mismatching_sunset_dates.json", |
There was a problem hiding this comment.
This looks more like an e2e test than a unit test. Typically, unit tests live in a _test file alongside the command they're testing. Could you move this to the e2e folder?
That said, I don't think an e2e test is necessary here; unit tests should be sufficient. The added benefit is that you won't need to include a large file in the test data folder either
There was a problem hiding this comment.
I see, thanks! I'll move it to the e2e folder since we have it, and add some unit tests. Let me know what you think
Proposed changes
Adds new command to FOASCLI to list all endpoints with sunset date drifts between two OpenAPI specs. This can be used to check the diff in sunset dates for specific endpoints of a specific version, between OASes on different branches/envs for example.
The check will output an endpoint if the sunset dates are different, but also when the sunset date is present in one spec and not the other.
Usage:
Example output:
Jira ticket: CLOUDP-391734
Testing
Added go tests for the new command, and tested manually with two specs as well.
Follow-up
Add a GH action check to run once a day, checking the sunset diffs between dev and QA/prod OASes. In case of a diff, open a ticket and link a runbook entry for the action.