Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 preview 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: 6 additions & 1 deletion tools/cli/internal/cli/changelog/metadata/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package metadata
import (
"encoding/json"
"fmt"
"strings"
"time"

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

// Validate that the API version use the correct date format YYYY-MM-DD
for _, version := range o.versions {
// Upcoming version has the format YYYY-MM-DD.upcoming, here we remove .upcoming to validate the date format.
version = strings.ReplaceAll(version, ".upcoming", "")
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is where I suggested to simply try to use apiversion.go and create a new version, throwing an error if it's invalid, that way you don't need to maintain two different logics to parse versions

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, good point. I updated the logic to reuse apiversion.go

if _, err := time.Parse("2006-01-02", version); err != nil {
return fmt.Errorf("invalid version date: %w. Make sure to use the format YYYY-MM-DD", err)
}
Expand All @@ -79,7 +83,8 @@ func (o *Opts) PreRun() error {
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