Skip to content

Commit

Permalink
If autoupdate channel is not set, do not use new autoupdater
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Sep 25, 2023
1 parent c5af653 commit 362c710
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
11 changes: 3 additions & 8 deletions pkg/autoupdate/tuf/library_lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ type autoupdateConfig struct {
localDevelopmentPath string
}

var channelsUsingLegacyAutoupdate = map[string]bool{
"stable": true,
"beta": true,
"alpha": true,
"nightly": true,
}
var channelsUsingNewAutoupdater = map[string]bool{}

// CheckOutLatestWithoutConfig returns information about the latest downloaded executable for our binary,
// searching for launcher configuration values in its config file.
Expand Down Expand Up @@ -123,8 +118,8 @@ func CheckOutLatest(binary autoupdatableBinary, rootDirectory string, updateDire
}

func usingNewAutoupdater(channel string) bool {
_, ok := channelsUsingLegacyAutoupdate[channel]
return !ok
_, ok := channelsUsingNewAutoupdater[channel]
return ok
}

// findExecutableFromRelease looks at our local TUF repository to find the release for our
Expand Down
12 changes: 8 additions & 4 deletions pkg/autoupdate/tuf/library_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
)

func TestCheckOutLatest_withTufRepository(t *testing.T) { //nolint: paralleltest
delete(channelsUsingLegacyAutoupdate, "nightly")
channelsUsingNewAutoupdater["nightly"] = true
defer func() {
channelsUsingLegacyAutoupdate["nightly"] = true
delete(channelsUsingNewAutoupdater, "nightly")
}()

for _, binary := range binaries { //nolint: paralleltest
Expand Down Expand Up @@ -54,9 +54,9 @@ func TestCheckOutLatest_withTufRepository(t *testing.T) { //nolint: paralleltest
}

func TestCheckOutLatest_withoutTufRepository(t *testing.T) { // nolint:paralleltest
delete(channelsUsingLegacyAutoupdate, "nightly")
channelsUsingNewAutoupdater["nightly"] = true
defer func() {
channelsUsingLegacyAutoupdate["nightly"] = true
delete(channelsUsingNewAutoupdater, "nightly")
}()

for _, binary := range binaries { //nolint: paralleltest
Expand Down Expand Up @@ -221,6 +221,10 @@ func Test_usingNewAutoupdater(t *testing.T) {
channelName: "beta",
usesNewAutoupdater: false,
},
{
channelName: "",
usesNewAutoupdater: false,
},
}

for _, channel := range channelsForTest {
Expand Down

0 comments on commit 362c710

Please sign in to comment.