Skip to content

Commit 7efacd3

Browse files
fix: request body for preview is empty (#466)
1 parent 7101319 commit 7efacd3

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

tools/cli/internal/apiversion/version.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ type APIVersion struct {
3232
}
3333

3434
const (
35-
dateFormat = "2006-01-02"
35+
dateFormat = "2006-01-02"
36+
previewDate = "3000-01-01"
3637
)
3738

3839
var contentPattern = regexp.MustCompile(`application/vnd\.atlas\.((\d{4})-(\d{2})-(\d{2})|preview)\+(.+)`)
@@ -57,7 +58,6 @@ func (v *APIVersion) newVersion(version string, date time.Time) {
5758
v.versionDate = date
5859

5960
if IsPreviewStabilityLevel(version) {
60-
v.versionDate = time.Now().AddDate(10, 0, 0) // set preview date to the future
6161
v.stabilityVersion = PreviewStabilityLevel
6262
}
6363
}
@@ -119,7 +119,7 @@ func WithFullContent(contentType string, contentValue *openapi3.MediaType) Optio
119119

120120
func DateFromVersion(version string) (time.Time, error) {
121121
if IsPreviewStabilityLevel(version) {
122-
return time.Now(), nil
122+
return time.Parse(dateFormat, previewDate)
123123
}
124124
return time.Parse(dateFormat, version)
125125
}

tools/cli/internal/apiversion/version_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,18 @@ func TestApiVersion_GreaterThan(t *testing.T) {
312312
version2: "2023-01-02",
313313
expected: false,
314314
},
315+
{
316+
name: "not greater",
317+
version1: "preview",
318+
version2: "preview",
319+
expected: false,
320+
},
321+
{
322+
name: "not greater",
323+
version1: "private-preview-charts-dashboards",
324+
version2: "private-preview-charts-dashboards",
325+
expected: false,
326+
},
315327
}
316328

317329
for _, tt := range testCases {

tools/cli/internal/openapi/filter/versioning.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
1415
package filter
1516

1617
import (

0 commit comments

Comments
 (0)