Skip to content

feat: create FOASCLI sunset diff command#1206

Merged
lovisaberggren merged 4 commits into
mainfrom
CLOUDP-391734
Apr 15, 2026
Merged

feat: create FOASCLI sunset diff command#1206
lovisaberggren merged 4 commits into
mainfrom
CLOUDP-391734

Conversation

@lovisaberggren

@lovisaberggren lovisaberggren commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

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:

./foascli sunset diff --spec oas-test.json --base oas.json

Example output:

[
  {
    "http_method": "GET",
    "path": "/api/atlas/v2/example/info",
    "version": "2023-01-01",
    "base_sunset_date": "2099-06-01",
    "spec_sunset_date": "2099-06-02",
    "team": "apix"
  },
  {
    "http_method": "GET",
    "path": "/api/atlas/v2/groups/{groupId}/clusters",
    "version": "2023-02-01",
    "base_sunset_date": "2027-07-02",
    "spec_sunset_date": "2027-07-01",
    "team": "Atlas Dedicated"
  },
  {
    "http_method": "GET",
    "path": "/api/atlas/v2/groups/{groupId}/clusters",
    "version": "2023-01-01",
    "base_sunset_date": "2027-07-02",
    "spec_sunset_date": "2027-07-01",
    "team": "Atlas Dedicated"
  },
  {
    "http_method": "POST",
    "path": "/api/atlas/v2/groups/{groupId}/clusters",
    "version": "2023-01-01",
    "base_sunset_date": "",
    "spec_sunset_date": "2027-07-01",
    "team": "Atlas Dedicated"
  },
  {
    "http_method": "GET",
    "path": "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}",
    "version": "2024-08-05",
    "base_sunset_date": "2027-03-01",
    "spec_sunset_date": "",
    "team": "Atlas Dedicated"
  }
]

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.

@lovisaberggren lovisaberggren changed the title CLOUDP-391734: create FOASCLI sunset diff command feat: create FOASCLI sunset diff command Apr 14, 2026
@lovisaberggren lovisaberggren marked this pull request as ready for review April 14, 2026 15:35
@lovisaberggren lovisaberggren requested a review from a team as a code owner April 14, 2026 15:35

type Diff struct {
Operation string `json:"http_method" yaml:"http_method"`
Path string `json:"path" yaml:"path"`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we also include the base and and target spec file name? I think it would be a useful info to see

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
  },
]

Comment on lines +49 to +50
basePath: "../../../test/data/base_spec.json",
specPath: "../../../test/data/base_spec_with_mismatching_sunset_dates.json",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@andreaangiolillo andreaangiolillo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lovisaberggren lovisaberggren merged commit 97f3498 into main Apr 15, 2026
9 checks passed
@lovisaberggren lovisaberggren deleted the CLOUDP-391734 branch April 15, 2026 13:38
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.

2 participants