Skip to content

Commit 4a4a18e

Browse files
Merge pull request #73 from tnierman/fix_rosa_install
Update 'rosa' tool install/upgrade logic to account for new release assets
2 parents 6395c4f + 9844306 commit 4a4a18e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pkg/tools/rosa/rosa.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ func (t *Tool) Install() error {
3434
return err
3535
}
3636

37-
matches := github.FindAssetsExcluding([]string{".sha256"}, github.FindAssetsForArchAndOS(release.Assets))
37+
matches := github.FindAssetsForArchAndOS(release.Assets)
3838
if len(matches) != 1 {
39-
return fmt.Errorf("unexpected number of assets found matching system spec: expected 1, got %d.\nMatching assets: %v", len(matches), matches)
39+
return fmt.Errorf("unexpected number of executable assets found matching system spec: expected 1, got %d.\nMatching assets: %v", len(matches), matches)
4040
}
4141
toolAsset := matches[0]
4242

43-
matches = github.FindAssetsContaining([]string{".sha256"}, github.FindAssetsForArchAndOS(release.Assets))
43+
matches = github.FindAssetsContaining([]string{"checksums.txt"}, release.Assets)
4444
if len(matches) != 1 {
45-
return fmt.Errorf("unexpected number of assets found matching system spec: expected 1, got %d.\nMatching assets: %v", len(matches), matches)
45+
return fmt.Errorf("unexpected number of checksum assets found matching system spec: expected 1, got %d.\nMatching assets: %v", len(matches), matches)
4646
}
4747
checksumAsset := matches[0]
4848

@@ -81,14 +81,19 @@ func (t *Tool) Install() error {
8181
return fmt.Errorf("warning: Checksum for '%s' does not match the calculated value. Please retry installation. If issue persists, this tool can be downloaded manually at %s", *toolAsset.Name, toolAsset.GetBrowserDownloadURL())
8282
}
8383

84+
err = utils.Unarchive(toolArchiveFilepath, versionedDir)
85+
if err != nil {
86+
return fmt.Errorf("failed to unarchive the '%s' asset file '%s': %w", t.Name(), toolArchiveFilepath, err)
87+
}
88+
8489
// Link as latest
8590
latestFilePath := t.SymlinkPath()
8691
err = os.Remove(latestFilePath)
8792
if err != nil && !os.IsNotExist(err) {
8893
return fmt.Errorf("failed to remove existing '%s' binary at '%s': %w", *toolAsset.Name, base.LatestDir, err)
8994
}
9095

91-
toolBinaryFilepath := filepath.Join(versionedDir, *toolAsset.Name)
96+
toolBinaryFilepath := filepath.Join(versionedDir, t.ExecutableName())
9297
err = os.Symlink(toolBinaryFilepath, latestFilePath)
9398
if err != nil {
9499
return fmt.Errorf("failed to link new '%s' binary to '%s': %w", *toolAsset.Name, base.LatestDir, err)

0 commit comments

Comments
 (0)