Skip to content

Commit

Permalink
Check file delete root cause
Browse files Browse the repository at this point in the history
If the file doesn't exist there is no reason to display the error, but if the file is not missing, we can't continue
  • Loading branch information
jjmrocha committed Mar 20, 2023
1 parent 62a96f4 commit ad2e5d6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pkg/aws/sso.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import (
"context"
"errors"
"fmt"
"log"
"os"
"strings"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/sso"
"github.com/aws/aws-sdk-go-v2/service/sso/types"
"github.com/aws/aws-sdk-go-v2/service/ssooidc"
ssoOidcTypes "github.com/aws/aws-sdk-go-v2/service/ssooidc/types"
"github.com/skratchdot/open-golang/open"
"log"
"os"
"strings"
"time"
)

func GenerateConfig(ssoURL, region string, overwrite bool) error {
Expand All @@ -40,8 +41,8 @@ func GenerateConfig(ssoURL, region string, overwrite bool) error {
}
configPath := homeDir + "/.aws/config"
err = os.Remove(configPath)
if err != nil {
fmt.Println("File not found. Continue...", err)
if err != nil && !os.IsNotExist(err) {
return err
}
for _, acc := range accounts {
roles := GetRolesByAccount(ctx, client, acc, token.AccessToken)
Expand Down

0 comments on commit ad2e5d6

Please sign in to comment.