Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tools/cli/internal/changelog/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ func NewEntries(basePath, revisionPath, exceptionFilePath string) ([]*Entry, err
}

for _, version := range changelog.RevisionMetadata.Versions {
// Skip preview versions
if apiversion.IsPreviewStabilityLevel(version) {
// Skip preview and upcoming versions
if apiversion.IsPreviewStabilityLevel(version) || apiversion.IsUpcomingStabilityLevel(version) {
continue
}

Expand Down Expand Up @@ -229,6 +229,12 @@ func NewEntriesBetweenRevisionVersions(revisionPath, exceptionFilePath string) (
if apiversion.IsPreviewStabilityLevel(fromVersion) || apiversion.IsPreviewStabilityLevel(toVersion) {
continue
}

// Skip upcoming version. It will be included in CLOUDP-315486
if apiversion.IsUpcomingStabilityLevel(fromVersion) || apiversion.IsUpcomingStabilityLevel(toVersion) {
continue
}

entry, err := newEntriesBetweenVersion(revisionMetadata, fromVersion, toVersion, exceptionFilePath)
if err != nil {
return nil, err
Expand Down
7 changes: 5 additions & 2 deletions tools/cli/internal/cli/changelog/metadata/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"time"

"github.com/mongodb/openapi/tools/cli/internal/apiversion"
"github.com/mongodb/openapi/tools/cli/internal/changelog"
"github.com/mongodb/openapi/tools/cli/internal/cli/flag"
"github.com/mongodb/openapi/tools/cli/internal/cli/usage"
Expand Down Expand Up @@ -70,16 +71,18 @@ func (o *Opts) PreRun() error {
}
}

// Validate that the API version use the correct date format YYYY-MM-DD
for _, version := range o.versions {
if _, err := time.Parse("2006-01-02", version); err != nil {
if _, err := apiversion.New(apiversion.WithVersion(version)); err != nil {
return fmt.Errorf("invalid version date: %w. Make sure to use the format YYYY-MM-DD", err)
}
}

return nil
}

// changelog metadata create [--run-date=2024-09-22] --sha=e624d716e86f6910757b60cefdf3aa3181582d38 versions=2023-01-01,2023-02-01.
// CreateBuilder creates the Cobra command for changelog metadata create [--run-date=2024-09-22]
// --sha=e624d716e86f6910757b60cefdf3aa3181582d38 versions=2023-01-01,2023-02-01.
func CreateBuilder() *cobra.Command {
opts := &Opts{
fs: afero.NewOsFs(),
Expand Down
14 changes: 13 additions & 1 deletion tools/cli/internal/cli/changelog/metadata/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestCreateBuild_Run(t *testing.T) {
opts := &Opts{
specRevision: "11110c256dffdb163be71a3ca70854a57fad5f6f",
runDate: "2024-01-01",
versions: []string{"2024-01-01"},
versions: []string{"2024-01-01", "2024-01-01.upcoming"},
fs: fs,
}

Expand All @@ -47,6 +47,18 @@ func TestCreateBuild_PreRun_InvalidVersion(t *testing.T) {
require.ErrorContains(t, opts.PreRun(), "invalid version date")
}

func TestCreateBuild_PreRun_UpcomingVersion(t *testing.T) {
fs := afero.NewMemMapFs()
opts := &Opts{
specRevision: "test",
runDate: "2024-01-01",
versions: []string{"2024-01-01.upcoming", "2025-01-01"},
Copy link
Member

Choose a reason for hiding this comment

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

Q: is there chance for us to migrate from string to object with multiple keys in the future?
Not sure how much involved it would be, asking curious question.

Thinking of all code generation tools we need to invent some parser for custom date format and prefixes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we have already the version struct here. You can create a new version struct from a string with this piece of code: apiVersion, err := apiversion.New(apiversion.WithVersion(version));. I am updating foascli to use always this struct where possible

Copy link
Member

Choose a reason for hiding this comment

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

@andreaangiolillo Thank you. Awesome news! Unification can help platform and integrations team as well as we see questions to support stability levels through SDK + other generation methods.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

@andreaangiolillo andreaangiolillo Jun 9, 2025

Choose a reason for hiding this comment

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

no, it won't change. It will still be a JSON array. You will start to see upcoming entries like this one:

[
  "2023-01-01",
  "2023-02-01",
  "2023-10-01",
  "2023-11-15",
  "2024-05-30",
  "2024-08-05",
  "2024-10-23",
  "2024-11-13",
  "2025-02-19",
  "2025-03-12"
  "2025-03-12.upcoming"
]

There was an issue last week on the dev SDK about this change and was fixed: https://mongodb.slack.com/archives/CHEULRC9W/p1749200548092979?thread_ts=1749199877.955329&cid=CHEULRC9W

fs: fs,
}

require.NoError(t, opts.PreRun())
}

func TestCreateBuilder(t *testing.T) {
test.CmdValidator(
t,
Expand Down
Loading