Skip to content

Commit 71eb3be

Browse files
committed
mod/modfile: deprecate LatestKnownSchemaVersion
The "latest known schema version" is defined to be the current language version which is now available as part of the cue API. This function is not used, so deprecate it, making it return `cueversion.LanguageVersion()` instead. Signed-off-by: Roger Peppe <[email protected]> Change-Id: Ie77d8225fbc5e12c888a7bff3d453c6e061fdf0f Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196821 Reviewed-by: Paul Jolly <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent a9009e8 commit 71eb3be

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

mod/modfile/modfile.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -232,32 +232,31 @@ func lookup(v cue.Value, sels ...cue.Selector) cue.Value {
232232
// should be at least this, because that's when we added the language.version
233233
// field itself.
234234
func EarliestClosedSchemaVersion() string {
235-
return schemaVersionLimits()[0]
235+
return earliestClosedSchemaVersion()
236236
}
237237

238-
// LatestKnownSchemaVersion returns the language version
239-
// associated with the most recent known schema.
240-
func LatestKnownSchemaVersion() string {
241-
return schemaVersionLimits()[1]
242-
}
243-
244-
var schemaVersionLimits = sync.OnceValue(func() [2]string {
245-
limits, _ := moduleSchemaDo(func(info *schemaInfo) ([2]string, error) {
238+
var earliestClosedSchemaVersion = sync.OnceValue(func() string {
239+
earliest, _ := moduleSchemaDo(func(info *schemaInfo) (string, error) {
246240
earliest := ""
247-
latest := ""
248241
for v := range info.Versions {
249242
if earliest == "" || semver.Compare(v, earliest) < 0 {
250243
earliest = v
251244
}
252-
if latest == "" || semver.Compare(v, latest) > 0 {
253-
latest = v
254-
}
255245
}
256-
return [2]string{earliest, latest}, nil
246+
return earliest, nil
257247
})
258-
return limits
248+
return earliest
259249
})
260250

251+
// LatestKnownSchemaVersion returns the language version
252+
// associated with the most recent known schema.
253+
//
254+
// Deprecated: use [cuelang.org/go/cue.LanguageVersion] instead. This
255+
// function will be removed in v0.11.
256+
func LatestKnownSchemaVersion() string {
257+
return cueversion.LanguageVersion()
258+
}
259+
261260
// Parse verifies that the module file has correct syntax
262261
// and follows the schema following the required language.version field.
263262
// The file name is used for error messages.

mod/modfile/modfile_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"cuelang.org/go/cue/errors"
2525
"cuelang.org/go/internal/cuetest"
26+
"cuelang.org/go/internal/cueversion"
2627
"cuelang.org/go/mod/module"
2728
)
2829

@@ -545,7 +546,7 @@ func TestEarliestClosedSchemaVersion(t *testing.T) {
545546
}
546547

547548
func TestLatestKnownSchemaVersion(t *testing.T) {
548-
qt.Assert(t, qt.Equals(LatestKnownSchemaVersion(), "v0.9.0-alpha.0"))
549+
qt.Assert(t, qt.Equals(LatestKnownSchemaVersion(), cueversion.LanguageVersion()))
549550
}
550551

551552
func parseVersions(vs ...string) []module.Version {

0 commit comments

Comments
 (0)