Skip to content

Commit

Permalink
Merge pull request #13 from armory/CDAAS-2594
Browse files Browse the repository at this point in the history
feat: download releases from S3 repository
  • Loading branch information
aelath authored Nov 3, 2023
2 parents 262833c + 79cd836 commit 1e0016d
Show file tree
Hide file tree
Showing 15 changed files with 283 additions and 680 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

- uses: actions/setup-go@v2
with:
go-version: 1.16.5
go-version-file: go.mod

- name: Cache Dependencies
uses: actions/cache@v2
Expand All @@ -32,4 +32,3 @@ jobs:
name: avm-cli-reports
path: |
build/reports/*
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:

- uses: actions/setup-go@v2
with:
go-version: '^1.16.5'
go-version-file: 'go.mod'

- name: Cache Dependencies
uses: actions/cache@v2
Expand Down
Binary file added avm
Binary file not shown.
15 changes: 9 additions & 6 deletions cmd/install.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

package cmd

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

func execInstallCmd(cmd *cobra.Command, args []string) {
Expand All @@ -26,7 +25,11 @@ func execInstallCmd(cmd *cobra.Command, args []string) {
useVersionAsDefault, _ := cmd.Flags().GetBool("default")
var version string
if len(args) == 0 {
version = utils.GetLatestVersion()
var err error
version, err = utils.GetLatestVersion()
if err != nil {
log.Fatal(err)
}
useVersionAsDefault = true
} else {
version = args[0]
Expand All @@ -46,7 +49,7 @@ func execInstallCmd(cmd *cobra.Command, args []string) {
}

path := filepath.Join(dir, "armory")
err = downloadRelease(path, utils.GetBinDownloadUrlForVersion(version))
err = downloadRelease(path, utils.GetBinDownloadUrlForVersion(version, goos, goarch))
if err != nil {
log.Fatalf("Failed to download release, err: %s", err.Error())
}
Expand Down Expand Up @@ -84,4 +87,4 @@ func downloadRelease(filepath string, url string) error {
// Write the body to file
_, err = io.Copy(out, resp.Body)
return err
}
}
11 changes: 7 additions & 4 deletions cmd/listall.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ import (
var listallCmd = &cobra.Command{
Use: "listall",
Short: "list available versions",
Run: execListAllCmd,
Run: execListAllCmd,
}

func execListAllCmd(cmd *cobra.Command, args []string) {
allReleases := utils.GetAllReleases()
for _, release := range allReleases {
log.Infof(*release.TagName)
versions, err := utils.GetAllVersions()
if err != nil {
log.Fatalf(err.Error())
}
for _, version := range versions {
log.Infof(version)
}
}

Expand Down
16 changes: 6 additions & 10 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import (
"runtime"
)

const (
COMMAND = "armory"
)

var verboseFlag bool

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

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

func init() {
RootCmd.PersistentFlags().BoolVarP(&verboseFlag, "verbose", "v", false, "show more details")
RootCmd.PersistentPreRunE = configureLogging
RootCmd.PersistentPreRun = configureLogging
}

func configureLogging(cmd *cobra.Command, args []string) error {
func configureLogging(_ *cobra.Command, _ []string) {
lvl := log.InfoLevel
if verboseFlag {
lvl = log.DebugLevel
}
log.SetLevel(lvl)
log.SetFormatter(&easy.Formatter{
LogFormat: "%msg%\n",
LogFormat: "%msg%\n",
})
return nil
}
}
31 changes: 18 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
module github.com/armory/avm

go 1.17
go 1.20

require (
github.com/google/go-github/v39 v39.1.0
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.2.1
github.com/Masterminds/semver/v3 v3.2.1
github.com/hashicorp/go-retryablehttp v0.7.4
github.com/jarcoal/httpmock v1.3.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.4
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
)

require (
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/samber/lo v1.38.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 1e0016d

Please sign in to comment.