Skip to content

Commit f03cac8

Browse files
author
Paweł Wamej
committed
address review
1 parent ed7d8cb commit f03cac8

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

cmd/root.go

+2-7
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
@@ -43,10 +39,10 @@ func Execute() {
4339

4440
func init() {
4541
RootCmd.PersistentFlags().BoolVarP(&verboseFlag, "verbose", "v", false, "show more details")
46-
RootCmd.PersistentPreRunE = configureLogging
42+
RootCmd.PersistentPreRun = configureLogging
4743
}
4844

49-
func configureLogging(cmd *cobra.Command, args []string) error {
45+
func configureLogging(_ *cobra.Command, _ []string) {
5046
lvl := log.InfoLevel
5147
if verboseFlag {
5248
lvl = log.DebugLevel
@@ -55,5 +51,4 @@ func configureLogging(cmd *cobra.Command, args []string) error {
5551
log.SetFormatter(&easy.Formatter{
5652
LogFormat: "%msg%\n",
5753
})
58-
return nil
5954
}

pkg/utils/versions.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"github.com/Masterminds/semver/v3"
77
"github.com/hashicorp/go-retryablehttp"
8+
log "github.com/sirupsen/logrus"
89
"net/url"
910
"sort"
1011
"strings"
@@ -29,12 +30,12 @@ func GetAllVersions() ([]string, error) {
2930
u := buildUrl(params)
3031
httpRes, err := client.Get(u)
3132
if err != nil {
32-
return []string{}, err
33+
return nil, err
3334
}
3435

3536
var res listBucketResult
3637
if err := xml.NewDecoder(httpRes.Body).Decode(&res); err != nil {
37-
return []string{}, err
38+
return nil, err
3839
}
3940
more = res.IsTruncated
4041
if res.NextContinuationToken != "" {
@@ -44,7 +45,7 @@ func GetAllVersions() ([]string, error) {
4445
for _, o := range res.Contents {
4546
v, err := o.version()
4647
if err != nil {
47-
return []string{}, err
48+
return nil, err
4849
}
4950
versions = append(versions, v)
5051
}
@@ -74,7 +75,7 @@ func GetBinDownloadUrlForVersion(version, goos, goarch string) string {
7475
func buildUrl(params url.Values) string {
7576
u, err := url.Parse(repositoryUrl)
7677
if err != nil {
77-
panic(err)
78+
log.Fatalf("repositoryUrl %s invalid: %v", repositoryUrl, err)
7879
}
7980
u.RawQuery = params.Encode()
8081
return u.String()

0 commit comments

Comments
 (0)