Skip to content

Commit 208172c

Browse files
committed
fix: solve errors and minor adjustments
Signed-off-by: brunopadz <bpadz@protonmail.com>
1 parent 8fe7035 commit 208172c

File tree

5 files changed

+10
-17
lines changed

5 files changed

+10
-17
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Binaries
2+
amictl*

cmd/aws.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import (
88
var awsCmd = &cobra.Command{
99
Use: "aws",
1010
Short: "Manages AWS AMIs",
11-
Long: "Manages AWS AMIs by account and region. It's possible to list used, not used and also inspect AMIs.",
11+
Long: `Manages AWS AMIs by account and region.
12+
It's possible to list used, not used, deregister/delete and also inspect AMIs.
13+
`,
1214
Run: func(cmd *cobra.Command, args []string) {
1315
cmd.Println(cmd.Long)
1416
},

cmd/awsDeregister.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import (
44
"context"
55
"fmt"
66

7-
"github.com/pterm/pterm"
8-
97
"github.com/aws/aws-sdk-go-v2/aws"
10-
118
"github.com/aws/aws-sdk-go-v2/service/ec2"
129
cfg "github.com/brunopadz/amictl/config"
1310
aaws "github.com/brunopadz/amictl/pkg/providers/aws"
11+
"github.com/pterm/pterm"
1412
"github.com/spf13/cobra"
1513
"github.com/spf13/viper"
1614
)

cmd/awsListUnused.go

+3
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ func runUnused(cmd *cobra.Command, _ []string) error {
103103
l := len(d) - 1
104104

105105
err = pterm.DefaultTable.WithHasHeader().WithData(d).Render()
106+
if err != nil {
107+
fmt.Println("Couldn't print message. Try again or check your AWS credentials.")
108+
}
106109

107110
if l <= 20 {
108111
pterm.Println(pterm.Green(fmt.Sprintf("%d AMIs are not being utilized.", l)))

cmd/root.go

+1-13
Original file line numberDiff line numberDiff line change
@@ -32,39 +32,27 @@ func Execute() {
3232
func init() {
3333
cobra.OnInitialize(initConfig)
3434

35-
// Here you will define your flags and configuration settings.
36-
// Cobra supports persistent flags, which, if defined here,
37-
// will be global for your application.
38-
3935
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.amictl.yaml)")
40-
41-
// Cobra also supports local flags, which will only run
42-
// when this action is called directly.
4336
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
4437
}
4538

46-
// initConfig reads in config file and ENV variables if set.
4739
func initConfig() {
4840

4941
var c cfg.Config
5042

5143
if cfgFile != "" {
52-
// Use config file from the flag.
5344
viper.SetConfigFile(cfgFile)
5445
} else {
55-
// Find home directory.
5646
home, err := os.UserHomeDir()
5747
cobra.CheckErr(err)
5848

59-
// Search config in home directory with name ".amictl" (without extension).
6049
viper.AddConfigPath(home)
6150
viper.SetConfigType("yaml")
6251
viper.SetConfigName(".amictl")
6352
}
6453

65-
viper.AutomaticEnv() // read in environment variables that match
54+
viper.AutomaticEnv()
6655

67-
// If a config file is found, read it in.
6856
err := viper.ReadInConfig()
6957
if err != nil {
7058
fmt.Println(err)

0 commit comments

Comments
 (0)