Skip to content

Commit 6e38338

Browse files
committed
fix: update deps
remove versions from root add version command update readme
1 parent 11c7ff7 commit 6e38338

File tree

17 files changed

+283
-144
lines changed

17 files changed

+283
-144
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
NAME := aws-cli-auth
2-
VERSION := v0.4.0
2+
VERSION := v0.6.0
33
REVISION := $(shell git rev-parse --short HEAD)
44

5-
LDFLAGS := -ldflags="-s -w -X \"github.com/dnitsch/aws-cli-auth/version.Version=$(VERSION)\" -X \"github.com/dnitsch/aws-cli-auth/version.Revision=$(REVISION)\" -extldflags -static"
5+
LDFLAGS := -ldflags="-s -w -X \"github.com/dnitsch/aws-cli-auth/cmd.Version=$(VERSION)\" -X \"github.com/dnitsch/aws-cli-auth/cmd.Revision=$(REVISION)\" -extldflags -static"
66

77
.PHONY: test test_ci tidy install buildprep build buildmac buildwin
88

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,22 @@ Download from [Releases page](https://github.com/dnitsch/aws-cli-auth/releases).
2525
MacOS
2626

2727
```bash
28-
curl -L https://github.com/dnitsch/aws-cli-auth/releases/download/v0.3.0/aws-cli-auth-darwin -o aws-cli-auth
28+
curl -L https://github.com/dnitsch/aws-cli-auth/releases/download/v0.6.0/aws-cli-auth-darwin -o aws-cli-auth
2929
chmod +x aws-cli-auth
3030
sudo mv aws-cli-auth /usr/local/bin
3131
```
3232

3333
Linux
3434
```bash
35-
curl -L https://github.com/dnitsch/aws-cli-auth/releases/download/v0.3.0/aws-cli-auth-linux -o aws-cli-auth
35+
curl -L https://github.com/dnitsch/aws-cli-auth/releases/download/v0.6.0/aws-cli-auth-linux -o aws-cli-auth
3636
chmod +x aws-cli-auth
3737
sudo mv aws-cli-auth /usr/local/bin
3838
```
3939

40+
Windows
41+
```posh
42+
iwr -Uri "https://github.com/dnitsch/aws-cli-auth/releases/download/v0.6.0/aws-cli-auth-windows.exe" -OutFile "aws-cli-auth"
43+
```
4044

4145

4246
## Usage

cmd/clear.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func init() {
2323

2424
func clear(cmd *cobra.Command, args []string) {
2525
web := web.New()
26+
secretStore := util.NewSecretStore("")
2627

2728
if force {
2829

@@ -31,6 +32,6 @@ func clear(cmd *cobra.Command, args []string) {
3132
}
3233
util.Writeln("Chromium Cache cleared")
3334
}
34-
util.Clear()
35+
secretStore.ClearAll()
3536

3637
}

cmd/root.go

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/dnitsch/aws-cli-auth/internal/config"
88
"github.com/dnitsch/aws-cli-auth/internal/util"
99
"github.com/spf13/cobra"
10-
"github.com/spf13/viper"
1110
)
1211

1312
var (
@@ -40,26 +39,11 @@ func init() {
4039
}
4140

4241
func initConfig() {
43-
if cfgFile != "" {
44-
// Use config file from the flag.
45-
viper.SetConfigFile(cfgFile)
46-
} else {
47-
// Find home directory.
48-
home, err := os.UserHomeDir()
49-
cobra.CheckErr(err)
50-
51-
// Search config in home directory with name ".cobra" (without extension).
52-
viper.AddConfigPath(home)
53-
viper.SetConfigType("yaml")
54-
viper.SetConfigName(fmt.Sprintf(".%s", config.SELF_NAME))
55-
}
56-
57-
viper.AutomaticEnv()
58-
viper.WriteConfig()
59-
6042
util.IsTraceEnabled = verbose
61-
62-
if err := viper.ReadInConfig(); err == nil {
63-
util.Traceln("Using config file:", viper.ConfigFileUsed())
43+
if _, err := os.Stat(util.ConfigIniFile()); err != nil {
44+
// creating a file
45+
rolesInit := []byte(fmt.Sprintf("[%s]\n", config.INI_CONF_SECTION))
46+
err := os.WriteFile(util.ConfigIniFile(), rolesInit, 0644)
47+
cobra.CheckErr(err)
6448
}
6549
}

cmd/saml.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ func init() {
2626
samlCmd.PersistentFlags().StringVarP(&acsUrl, "acsurl", "a", "https://signin.aws.amazon.com/saml", "Override the default ACS Url, used for checkin the post of the SAMLResponse")
2727
samlCmd.PersistentFlags().IntVarP(&duration, "max-duration", "d", 900, "Override default max session duration, in seconds, of the role session [900-43200]")
2828
rootCmd.AddCommand(samlCmd)
29-
3029
}
3130

3231
func getSaml(cmd *cobra.Command, args []string) {

cmd/specific.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ Returns the same JSON object as the call to the AWS cli for any of the sts Assum
2222
}
2323
)
2424

25-
// var strategy map[string]func
26-
2725
func init() {
28-
specificCmd.PersistentFlags().StringVarP(&method, "method", "m", "WEB_ID", "Runs a specific credentialProvider as opposed to rel")
26+
specificCmd.PersistentFlags().StringVarP(&method, "method", "m", "WEB_ID", "Runs a specific credentialProvider as opposed to relying on the default chain provider fallback")
2927
rootCmd.AddCommand(specificCmd)
3028
}
3129

cmd/version.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/dnitsch/aws-cli-auth/internal/config"
7+
"github.com/spf13/cobra"
8+
)
9+
10+
var (
11+
Version string = "0.0.1"
12+
Revision string = "1111aaaa"
13+
)
14+
15+
func init() {
16+
rootCmd.AddCommand(versionCmd)
17+
}
18+
19+
var versionCmd = &cobra.Command{
20+
Use: "version",
21+
Short: fmt.Sprintf("Get version number %s", config.SELF_NAME),
22+
Long: `Version and Revision number of the installed CLI`,
23+
Run: func(cmd *cobra.Command, args []string) {
24+
fmt.Printf("Version: %s\nRevision: %s\n", Version, Revision)
25+
},
26+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/pkg/errors v0.9.1
99
github.com/spf13/cobra v1.3.0
1010
github.com/spf13/viper v1.10.1
11-
github.com/zalando/go-keyring v0.2.0
11+
github.com/zalando/go-keyring v0.2.1
1212
)
1313

1414
require (

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
612612
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
613613
github.com/zalando/go-keyring v0.2.0 h1:IZOFhp3Gw5WeaGTVpKtKD2o/s+BeeqQkKUhtMDTQ190=
614614
github.com/zalando/go-keyring v0.2.0/go.mod h1:cu3uCHLkG4H4ali7PdTkEWoq2p07YHHoI+oi16YT5x8=
615+
github.com/zalando/go-keyring v0.2.1 h1:MBRN/Z8H4U5wEKXiD67YbDAr5cj/DOStmSga70/2qKc=
616+
github.com/zalando/go-keyring v0.2.1/go.mod h1:g63M2PPn0w5vjmEbwAX3ib5I+41zdm4esSETOn9Y6Dw=
615617
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
616618
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
617619
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=

internal/auth/saml.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@ import (
88
"github.com/dnitsch/aws-cli-auth/internal/web"
99
)
1010

11+
// GetSamlCreds
1112
func GetSamlCreds(conf config.SamlConfig) {
1213
if conf.BaseConfig.CfgSectionName == "" && conf.BaseConfig.StoreInProfile {
1314
util.Writeln("Config-Section name must be provided if store-profile is enabled")
1415
util.Exit(nil)
1516
}
1617

1718
web := web.New()
19+
secretStore := util.NewSecretStore(conf.BaseConfig.Role)
1820
var awsCreds *util.AWSCredentials
21+
1922
var err error
2023

2124
// Try to reuse stored credential in secret
2225
if !conf.BaseConfig.StoreInProfile {
23-
awsCreds, err = util.AWSCredential(conf.BaseConfig.Role)
26+
awsCreds, err = secretStore.AWSCredential()
2427
}
2528

2629
if !util.IsValid(awsCreds) || err != nil {
@@ -43,7 +46,7 @@ func GetSamlCreds(conf config.SamlConfig) {
4346
}
4447

4548
awsCreds.Version = 1
46-
util.SaveAWSCredential(conf.BaseConfig.Role, awsCreds)
49+
secretStore.SaveAWSCredential(awsCreds)
4750
}
4851

4952
util.SetCredentials(awsCreds, conf)

0 commit comments

Comments
 (0)