File tree Expand file tree Collapse file tree 6 files changed +19
-11
lines changed Expand file tree Collapse file tree 6 files changed +19
-11
lines changed Original file line number Diff line number Diff line change 5
5
package cmd
6
6
7
7
import (
8
- "log"
9
-
8
+ log "github.com/sirupsen/logrus"
10
9
"github.com/spf13/cobra"
11
10
"github.com/spf13/cobra/doc"
12
11
)
@@ -18,7 +17,7 @@ var docsCmd = &cobra.Command{
18
17
Run : func (cmd * cobra.Command , args []string ) {
19
18
err := doc .GenMarkdownTree (rootCmd , "./docs" )
20
19
if err != nil {
21
- log .Fatal (err )
20
+ log .Fatalln (err )
22
21
}
23
22
},
24
23
}
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ package cmd
6
6
7
7
import (
8
8
"github.com/rayprogramming/toolsium/lib/config"
9
+ log "github.com/sirupsen/logrus"
9
10
"github.com/spf13/cobra"
10
11
)
11
12
@@ -14,11 +15,16 @@ var initCmd = &cobra.Command{
14
15
Use : "init" ,
15
16
Short : "Setup toolsium" ,
16
17
Run : func (cmd * cobra.Command , args []string ) {
18
+ log .Debugf ("init conf path: %v" , config .GetConfigFilePath ())
17
19
err := config .CreateConfig ()
18
20
cobra .CheckErr (err )
19
21
},
20
22
}
21
23
24
+ func runAWS () {
25
+ log .Debugln ("Done running AWS command" )
26
+ }
27
+
22
28
func init () {
23
29
rootCmd .AddCommand (initCmd )
24
30
Original file line number Diff line number Diff line change @@ -7,11 +7,11 @@ package cmd
7
7
import (
8
8
"context"
9
9
"errors"
10
- "log"
11
10
12
11
"github.com/aws/aws-sdk-go-v2/aws"
13
12
"github.com/aws/aws-sdk-go-v2/config"
14
13
"github.com/aws/aws-sdk-go-v2/service/sts"
14
+ log "github.com/sirupsen/logrus"
15
15
"github.com/spf13/cobra"
16
16
"github.com/spf13/viper"
17
17
)
@@ -38,7 +38,7 @@ to quickly create a Cobra application.`,
38
38
Run : func (cmd * cobra.Command , args []string ) {
39
39
cfg , err := config .LoadDefaultConfig (context .TODO ())
40
40
if err != nil {
41
- log .Fatal (err )
41
+ log .Fatalln (err )
42
42
}
43
43
44
44
client := sts .NewFromConfig (cfg )
@@ -48,11 +48,11 @@ to quickly create a Cobra application.`,
48
48
}
49
49
tokenOutput , err := client .GetSessionToken (context .TODO (), & sessionTokenInput )
50
50
if err != nil {
51
- log .Fatal (err )
51
+ log .Fatalln (err )
52
52
}
53
53
viper .Set ("session" , tokenOutput )
54
54
if err := viper .WriteConfig (); err != nil {
55
- log .Fatal (err )
55
+ log .Fatalln (err )
56
56
}
57
57
},
58
58
}
Original file line number Diff line number Diff line change @@ -7,13 +7,13 @@ package cmd
7
7
import (
8
8
"context"
9
9
"fmt"
10
- "log"
11
10
12
11
"github.com/aws/aws-sdk-go-v2/aws"
13
12
"github.com/aws/aws-sdk-go-v2/config"
14
13
"github.com/aws/aws-sdk-go-v2/service/ec2"
15
14
"github.com/aws/aws-sdk-go-v2/service/ec2/types"
16
15
"github.com/rayprogramming/toolsium/lib"
16
+ log "github.com/sirupsen/logrus"
17
17
"github.com/spf13/cobra"
18
18
)
19
19
@@ -33,7 +33,7 @@ to quickly create a Cobra application.`,
33
33
cfg .Credentials = aws .NewCredentialsCache (& lib.MfaProvider {})
34
34
35
35
if err != nil {
36
- log .Fatal (err )
36
+ log .Fatalln (err )
37
37
}
38
38
39
39
client := ec2 .NewFromConfig (cfg )
Original file line number Diff line number Diff line change 9
9
"os"
10
10
11
11
"github.com/rayprogramming/toolsium/lib/config"
12
+ log "github.com/sirupsen/logrus"
12
13
"github.com/spf13/cobra"
13
14
)
14
15
@@ -44,5 +45,6 @@ func init() {
44
45
45
46
// initConfig reads in config file and ENV variables if set.
46
47
func initConfig () {
48
+ log .Debugf ("cfgFile: %v" , cfgFile )
47
49
config .Configure (cfgFile )
48
50
}
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import (
19
19
func Configure (cfgFile string ) { t .Configure (cfgFile ) }
20
20
func (t * Toolsium ) Configure (cfgFile string ) {
21
21
if cfgFile != "" {
22
+ log .Debugf ("Using custom cfgFile %v" , cfgFile )
22
23
// Use config file from the flag.
23
24
t .Config .SetConfigFile (cfgFile )
24
25
} else {
@@ -48,7 +49,7 @@ func (t *Toolsium) GetConfigDir() (path string) {
48
49
func SetConfigDir (confDir string ) { t .SetConfigDir (confDir ) }
49
50
func (t * Toolsium ) SetConfigDir (confDir string ) {
50
51
if _ , osErr := os .Stat (confDir ); os .IsNotExist (osErr ) {
51
- log .Infof ("Provided config directory didn't exist. %v" , confDir )
52
+ log .Debugf ("Provided config directory didn't exist. %v" , confDir )
52
53
t .ConfigDir = t .DefaultConfigDirPath ()
53
54
}
54
55
t .ConfigDir = confDir
@@ -98,7 +99,7 @@ func (t *Toolsium) createConfigDirectory() {
98
99
if _ , err := os .Stat (path ); errors .Is (err , os .ErrNotExist ) {
99
100
err := os .Mkdir (path , os .ModePerm )
100
101
if err != nil {
101
- log .Errorln (err )
102
+ log .Fatalln (err )
102
103
}
103
104
}
104
105
}
You can’t perform that action at this time.
0 commit comments