Skip to content

Commit cebc24e

Browse files
committed
CLOUDP-297221: Add preview support to split command
1 parent 82d24b8 commit cebc24e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tools/cli/internal/apiversion/version.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"fmt"
1919
"log"
2020
"regexp"
21+
"strings"
2122
"time"
2223

2324
"github.com/getkin/kin-openapi/openapi3"
@@ -54,6 +55,13 @@ func New(opts ...Option) (*APIVersion, error) {
5455
// WithVersion sets the version on the APIVersion.
5556
func WithVersion(version string) Option {
5657
return func(v *APIVersion) error {
58+
if strings.EqualFold(version, PreviewStabilityLevel) {
59+
v.version = version
60+
v.stabilityVersion = PreviewStabilityLevel
61+
v.versionDate = time.Now() // make preview look like the latest version
62+
return nil
63+
}
64+
5765
versionDate, err := DateFromVersion(version)
5866
if err != nil {
5967
return err
@@ -87,6 +95,7 @@ func WithContent(contentType string) Option {
8795
v.stabilityVersion = StableStabilityLevel
8896
if version == PreviewStabilityLevel {
8997
v.stabilityVersion = PreviewStabilityLevel
98+
v.versionDate = time.Now() // make preview look like the latest version
9099
return nil
91100
}
92101

tools/cli/internal/apiversion/version_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ func TestParseVersion(t *testing.T) {
4848
expectedMatch: "2030-02-20",
4949
wantErr: false,
5050
},
51+
{
52+
name: "preview",
53+
contentType: "application/vnd.atlas.preview+json",
54+
expectedMatch: "preview",
55+
wantErr: false,
56+
},
5157
{
5258
name: "invalid",
5359
contentType: "application/vnd.test.2023-01-01",
@@ -94,6 +100,12 @@ func TestNewAPIVersionFromContentType(t *testing.T) {
94100
expectedMatch: "2030-02-20",
95101
wantErr: false,
96102
},
103+
{
104+
name: "preview",
105+
contentType: "application/vnd.atlas.preview+json",
106+
expectedMatch: "preview",
107+
wantErr: false,
108+
},
97109
{
98110
name: "invalid",
99111
contentType: "application/vnd.test.2023-01-01",

0 commit comments

Comments
 (0)