Skip to content

Commit

Permalink
Merge #113314
Browse files Browse the repository at this point in the history
113314: clusterversion: cockroach versions cleanup r=RaduBerinde a=RaduBerinde

This commit cleans up the code and constants in
`cockroach_versions.go`:
 - we separate out the "dev offset" code and improve the documentation;
 - we replace the key-to-version slice with a table (array). This makes the declaration much cleaner and makes the lookup easier.
 - we replace `ByKey()` with a method, to make the call site less messy, e.g. `clusterversion.ByKey(clusterversion.V23_2)` becomes `clusterversion.V23_2.Version()`;
 - we deprecate `BinaryMinSupportedVersionKey` in favor of `MinSupported`;
 - we deprecate `BinaryVersionKey` in favor of `Latest`;
 - we remove `roachpb.Version` "constants" in favor of using the `Version()` method.

Informs: #112629
Release note: None

Co-authored-by: Radu Berinde <[email protected]>
  • Loading branch information
craig[bot] and RaduBerinde committed Nov 3, 2023
2 parents d41e3eb + 9f4a5d8 commit 694861a
Show file tree
Hide file tree
Showing 16 changed files with 364 additions and 670 deletions.
4 changes: 1 addition & 3 deletions pkg/clusterversion/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ go_library(
srcs = [
"clusterversion.go",
"cockroach_versions.go",
"keyed_versions.go",
"dev_offset.go",
"setting.go",
"testutils.go",
"utilversions.go",
Expand All @@ -25,7 +25,6 @@ go_library(
"//pkg/util/timeutil",
"@com_github_cockroachdb_errors//:errors",
"@com_github_cockroachdb_redact//:redact",
"@com_github_kr_pretty//:pretty",
],
)

Expand All @@ -48,7 +47,6 @@ go_test(
"//pkg/util/protoutil",
"@com_github_cockroachdb_errors//:errors",
"@com_github_cockroachdb_redact//:redact",
"@com_github_dustin_go_humanize//:go-humanize",
"@com_github_stretchr_testify//require",
],
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/clusterversion/clusterversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ var _ Handle = (*handleImpl)(nil)
// supported versions initialized to this binary's build and it's minimum
// supported versions respectively.
func MakeVersionHandle(sv *settings.Values) Handle {
return MakeVersionHandleWithOverride(sv, binaryVersion, binaryMinSupportedVersion)
return MakeVersionHandleWithOverride(sv, Latest.Version(), MinSupported.Version())
}

// MakeVersionHandleWithOverride returns a Handle that has its
Expand Down
2 changes: 1 addition & 1 deletion pkg/clusterversion/clusterversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestClusterVersionOnChange(t *testing.T) {
"test description",
&cvs.VersionSetting)

handle := newHandleImpl(cvs, &sv, binaryVersion, binaryMinSupportedVersion)
handle := newHandleImpl(cvs, &sv, Latest.Version(), MinSupported.Version())
newCV := ClusterVersion{
Version: roachpb.Version{
Major: 1,
Expand Down
Loading

0 comments on commit 694861a

Please sign in to comment.