Skip to content

Commit 2f3ef74

Browse files
authored
chore(version)!: remove 'hotpatch' versioning (#14510)
Hotpatch versions are unused. This change removes all references to hotpatch versions from the version package.
1 parent da4e194 commit 2f3ef74

File tree

4 files changed

+18
-79
lines changed

4 files changed

+18
-79
lines changed

pkg/version/channels_test.go

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
)
1212

1313
func TestGetLatestVersions(t *testing.T) {
14-
four := int64(4)
1514
testCases := []struct {
1615
name string
1716
resp interface{}
@@ -21,18 +20,16 @@ func TestGetLatestVersions(t *testing.T) {
2120
{
2221
"valid response",
2322
map[string]string{
24-
"foo": "foo-1.2.3",
25-
"fooHotpatch": "foo-1.2.3-4",
26-
"stable": "stable-2.1.0",
27-
"edge": "edge-2.1.0",
23+
"foo": "foo-1.2.3",
24+
"stable": "stable-2.1.0",
25+
"edge": "edge-2.1.0",
2826
},
2927
nil,
3028
Channels{
3129
[]channelVersion{
32-
{"foo", "1.2.3", nil, "foo-1.2.3"},
33-
{"foo", "1.2.3", &four, "foo-1.2.3-4"},
34-
{"stable", "2.1.0", nil, "stable-2.1.0"},
35-
{"edge", "2.1.0", nil, "edge-2.1.0"},
30+
{"foo", "1.2.3", "foo-1.2.3"},
31+
{"stable", "2.1.0", "stable-2.1.0"},
32+
{"edge", "2.1.0", "edge-2.1.0"},
3633
},
3734
},
3835
},
@@ -102,7 +99,7 @@ func channelsEqual(c1, c2 Channels) bool {
10299
for _, cv1 := range c1.array {
103100
found := false
104101
for _, cv2 := range c2.array {
105-
if cv1.channel == cv2.channel && cv1.version == cv2.version && cv1.hotpatchEqual(cv2) {
102+
if cv1.channel == cv2.channel && cv1.version == cv2.version {
106103
found = true
107104
break
108105
}
@@ -116,13 +113,12 @@ func channelsEqual(c1, c2 Channels) bool {
116113
}
117114

118115
func TestChannelsMatch(t *testing.T) {
119-
four := int64(4)
120116
channels := Channels{
121117
[]channelVersion{
122-
{"stable", "2.1.0", nil, "stable-2.1.0"},
123-
{"foo", "1.2.3", nil, "foo-1.2.3"},
124-
{"foo", "1.2.3", &four, "foo-1.2.3-4"},
125-
{"version", "3.2.1", nil, "version-3.2.1"},
118+
{"stable", "2.1.0", "stable-2.1.0"},
119+
{"foo", "1.2.3", "foo-1.2.3"},
120+
{"foo", "1.2.3", "foo-1.2.3-4"},
121+
{"version", "3.2.1", "version-3.2.1"},
126122
},
127123
}
128124

@@ -141,8 +137,7 @@ func TestChannelsMatch(t *testing.T) {
141137
fmt.Errorf("is running version 1.2.2 but the latest foo version is 1.2.3"),
142138
},
143139
{
144-
"foo-1.2.3-3",
145-
fmt.Errorf("is running version 1.2.3-3 but the latest foo version is 1.2.3-4"),
140+
"foo-1.2.3-3", nil,
146141
},
147142
{
148143
"unsupportedChannel-1.2.3",

pkg/version/channelversion.go

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package version
22

33
import (
44
"fmt"
5-
"strconv"
65
"strings"
76
)
87

@@ -11,53 +10,22 @@ import (
1110
type channelVersion struct {
1211
channel string
1312
version string
14-
hotpatch *int64
1513
original string
1614
}
1715

18-
// hotpatchSuffix is the suffix applied to channel names to indicate that the
19-
// version string includes a hotpatch number (e.g. dev-0.1.2-3)
20-
const hotpatchSuffix = "Hotpatch"
21-
2216
func (cv channelVersion) String() string {
2317
return cv.original
2418
}
2519

26-
// updateChannel returns the channel name to check for updates. if there's no
27-
// hotpatch number set, then it returns the channel name itself. otherwise it
28-
// returns the channel name suffixed with "Hotpatch" to indicate that a separate
29-
// update channel should be used.
20+
// updateChannel returns the channel name to check for updates, returning the
21+
// channel name.
3022
func (cv channelVersion) updateChannel() string {
31-
if cv.hotpatch != nil {
32-
return cv.channel + hotpatchSuffix
33-
}
3423
return cv.channel
3524
}
3625

37-
// versionWithHotpatch returns the version string, suffixed with the hotpatch
38-
// number if it exists.
39-
func (cv channelVersion) versionWithHotpatch() string {
40-
if cv.hotpatch == nil {
41-
return cv.version
42-
}
43-
return fmt.Sprintf("%s-%d", cv.version, *cv.hotpatch)
44-
}
45-
46-
func (cv channelVersion) hotpatchEqual(other channelVersion) bool {
47-
if cv.hotpatch == nil && other.hotpatch == nil {
48-
return true
49-
}
50-
if cv.hotpatch == nil || other.hotpatch == nil {
51-
return false
52-
}
53-
return *cv.hotpatch == *other.hotpatch
54-
}
55-
5626
// parseChannelVersion parses a build string into a channelVersion struct. it
5727
// expects the channel and version to be separated by a hyphen (e.g. dev-0.1.2).
58-
// the version may additionally include a hotpatch number, which is separated
59-
// from the base version by another hyphen (e.g. dev-0.1.2-3). if the version is
60-
// suffixed with any other non-numeric build info strings (e.g. dev-0.1.2-foo),
28+
// if the version is suffixed with any other non-numeric build info strings (e.g. dev-0.1.2-foo),
6129
// those strings are ignored.
6230
func parseChannelVersion(cv string) (channelVersion, error) {
6331
parts := strings.Split(cv, "-")
@@ -67,16 +35,8 @@ func parseChannelVersion(cv string) (channelVersion, error) {
6735

6836
channel := parts[0]
6937
version := parts[1]
70-
var hotpatch *int64
71-
72-
for _, part := range parts[2:] {
73-
if i, err := strconv.ParseInt(part, 10, 64); err == nil {
74-
hotpatch = &i
75-
break
76-
}
77-
}
7838

79-
return channelVersion{channel, version, hotpatch, cv}, nil
39+
return channelVersion{channel, version, cv}, nil
8040
}
8141

8242
// IsReleaseChannel returns true if the channel of the version is "edge" or

pkg/version/version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ func match(expectedVersion, actualVersion string) error {
6161
actual, expected)
6262
}
6363

64-
if actual.version != expected.version || !actual.hotpatchEqual(expected) {
64+
if actual.version != expected.version {
6565
return fmt.Errorf("is running version %s but the latest %s version is %s",
66-
actual.versionWithHotpatch(), actual.channel, expected.versionWithHotpatch())
66+
actual.version, actual.channel, expected.version)
6767
}
6868

6969
return nil

pkg/version/version_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ func TestMatch(t *testing.T) {
2727
expected: "dev-0.1.2-bar",
2828
actual: "dev-0.1.2-baz",
2929
},
30-
{
31-
name: "up-to-date with hotpatch",
32-
expected: "dev-0.1.2-3",
33-
actual: "dev-0.1.2-3",
34-
},
35-
{
36-
name: "up-to-date with hotpatch and different build info",
37-
expected: "dev-0.1.2-3-bar",
38-
actual: "dev-0.1.2-3-baz",
39-
},
4030
{
4131
name: "not up-to-date",
4232
expected: "dev-0.1.2",
@@ -49,12 +39,6 @@ func TestMatch(t *testing.T) {
4939
actual: "dev-0.1.1-bar",
5040
err: errors.New("is running version 0.1.1 but the latest dev version is 0.1.2"),
5141
},
52-
{
53-
name: "not up-to-date with hotpatch",
54-
expected: "dev-0.1.2-3",
55-
actual: "dev-0.1.2-2",
56-
err: errors.New("is running version 0.1.2-2 but the latest dev version is 0.1.2-3"),
57-
},
5842
{
5943
name: "mismatched channels",
6044
expected: "dev-0.1.2",

0 commit comments

Comments
 (0)