Skip to content

Commit 1e0016d

Browse files
authored
Merge pull request #13 from armory/CDAAS-2594
feat: download releases from S3 repository
2 parents 262833c + 79cd836 commit 1e0016d

File tree

15 files changed

+283
-680
lines changed

15 files changed

+283
-680
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
- uses: actions/setup-go@v2
1414
with:
15-
go-version: 1.16.5
15+
go-version-file: go.mod
1616

1717
- name: Cache Dependencies
1818
uses: actions/cache@v2
@@ -32,4 +32,3 @@ jobs:
3232
name: avm-cli-reports
3333
path: |
3434
build/reports/*
35-

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090

9191
- uses: actions/setup-go@v2
9292
with:
93-
go-version: '^1.16.5'
93+
go-version-file: 'go.mod'
9494

9595
- name: Cache Dependencies
9696
uses: actions/cache@v2

avm

9.78 MB
Binary file not shown.

cmd/install.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
package cmd
32

43
import (
@@ -16,8 +15,8 @@ import (
1615
var installCmd = &cobra.Command{
1716
Use: "install [version]",
1817
Short: "install an Armory CLI version, if version is omitted latest will be used and it will be linked to as default",
19-
Run: execInstallCmd,
20-
Args: cobra.MaximumNArgs(1),
18+
Run: execInstallCmd,
19+
Args: cobra.MaximumNArgs(1),
2120
}
2221

2322
func execInstallCmd(cmd *cobra.Command, args []string) {
@@ -26,7 +25,11 @@ func execInstallCmd(cmd *cobra.Command, args []string) {
2625
useVersionAsDefault, _ := cmd.Flags().GetBool("default")
2726
var version string
2827
if len(args) == 0 {
29-
version = utils.GetLatestVersion()
28+
var err error
29+
version, err = utils.GetLatestVersion()
30+
if err != nil {
31+
log.Fatal(err)
32+
}
3033
useVersionAsDefault = true
3134
} else {
3235
version = args[0]
@@ -46,7 +49,7 @@ func execInstallCmd(cmd *cobra.Command, args []string) {
4649
}
4750

4851
path := filepath.Join(dir, "armory")
49-
err = downloadRelease(path, utils.GetBinDownloadUrlForVersion(version))
52+
err = downloadRelease(path, utils.GetBinDownloadUrlForVersion(version, goos, goarch))
5053
if err != nil {
5154
log.Fatalf("Failed to download release, err: %s", err.Error())
5255
}
@@ -84,4 +87,4 @@ func downloadRelease(filepath string, url string) error {
8487
// Write the body to file
8588
_, err = io.Copy(out, resp.Body)
8689
return err
87-
}
90+
}

cmd/listall.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ import (
1010
var listallCmd = &cobra.Command{
1111
Use: "listall",
1212
Short: "list available versions",
13-
Run: execListAllCmd,
13+
Run: execListAllCmd,
1414
}
1515

1616
func execListAllCmd(cmd *cobra.Command, args []string) {
17-
allReleases := utils.GetAllReleases()
18-
for _, release := range allReleases {
19-
log.Infof(*release.TagName)
17+
versions, err := utils.GetAllVersions()
18+
if err != nil {
19+
log.Fatalf(err.Error())
20+
}
21+
for _, version := range versions {
22+
log.Infof(version)
2023
}
2124
}
2225

cmd/root.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ import (
99
"runtime"
1010
)
1111

12-
const (
13-
COMMAND = "armory"
14-
)
15-
1612
var verboseFlag bool
1713

1814
// RootCmd represents the base command when called without any subcommands
@@ -21,7 +17,8 @@ var RootCmd = &cobra.Command{
2117
Short: "Armory Version Manager",
2218
}
2319

24-
func Execute() {
20+
func Execute() {
21+
//goland:noinspection GoBoolExpressions because incorrectly detects as "always false"
2522
if runtime.GOOS == "windows" {
2623
log.Fatalf("avm only supports OS X and GNU+Linux")
2724
}
@@ -42,17 +39,16 @@ func Execute() {
4239

4340
func init() {
4441
RootCmd.PersistentFlags().BoolVarP(&verboseFlag, "verbose", "v", false, "show more details")
45-
RootCmd.PersistentPreRunE = configureLogging
42+
RootCmd.PersistentPreRun = configureLogging
4643
}
4744

48-
func configureLogging(cmd *cobra.Command, args []string) error {
45+
func configureLogging(_ *cobra.Command, _ []string) {
4946
lvl := log.InfoLevel
5047
if verboseFlag {
5148
lvl = log.DebugLevel
5249
}
5350
log.SetLevel(lvl)
5451
log.SetFormatter(&easy.Formatter{
55-
LogFormat: "%msg%\n",
52+
LogFormat: "%msg%\n",
5653
})
57-
return nil
58-
}
54+
}

go.mod

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
module github.com/armory/avm
22

3-
go 1.17
3+
go 1.20
44

55
require (
6-
github.com/google/go-github/v39 v39.1.0
7-
github.com/sirupsen/logrus v1.8.1
8-
github.com/spf13/cobra v1.2.1
6+
github.com/Masterminds/semver/v3 v3.2.1
7+
github.com/hashicorp/go-retryablehttp v0.7.4
8+
github.com/jarcoal/httpmock v1.3.1
9+
github.com/sirupsen/logrus v1.9.3
10+
github.com/spf13/cobra v1.7.0
11+
github.com/stretchr/testify v1.8.4
12+
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
913
)
1014

1115
require (
12-
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
13-
github.com/google/go-querystring v1.1.0 // indirect
14-
github.com/inconshreveable/mousetrap v1.0.0 // indirect
15-
github.com/russross/blackfriday/v2 v2.0.1 // indirect
16-
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
16+
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
17+
github.com/davecgh/go-spew v1.1.1 // indirect
18+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
19+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
20+
github.com/pmezard/go-difflib v1.0.0 // indirect
21+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
22+
github.com/samber/lo v1.38.1 // indirect
1723
github.com/spf13/pflag v1.0.5 // indirect
18-
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 // indirect
19-
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
20-
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf // indirect
21-
gopkg.in/yaml.v2 v2.4.0 // indirect
24+
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
25+
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
26+
gopkg.in/yaml.v3 v3.0.1 // indirect
2227
)

0 commit comments

Comments
 (0)