Skip to content

Commit 229b409

Browse files
author
Chris Gilmer
committed
Make messages more readable. Replace fmt.Println with logger.
1 parent e137dde commit 229b409

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

cmd/setup.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func setupUserInitFlags(flag *pflag.FlagSet) {
4545
flag.String(AWSAccountIDFlag, "", "The AWS account ID")
4646
flag.String(IAMUserFlag, "", "The IAM user name to setup")
4747
flag.String(IAMRoleFlag, "", "The IAM role name assigned to the user being setup")
48-
flag.String(OutputFlag, "json", "The AWS CLI output format 'text' or 'json'")
48+
flag.String(OutputFlag, "json", "The AWS CLI output format")
4949

5050
// Verbose
5151
flag.BoolP(VerboseFlag, "v", false, "log messages at the debug level.")
@@ -171,7 +171,7 @@ func (u *User) newSession() (*session.Session, error) {
171171
}
172172

173173
func (u *User) newMFASession(logger *log.Logger) (*session.Session, error) {
174-
mfaToken := promptMFAtoken("", logger)
174+
mfaToken := promptMFAtoken("Third ", logger)
175175
basicSession, err := u.newSession()
176176
if err != nil {
177177
return nil, fmt.Errorf("unable to create new session: %w", err)
@@ -254,7 +254,7 @@ func promptMFAtoken(messagePrefix string, logger *log.Logger) string {
254254
}
255255
err = validate.Var(t, "numeric,len=6")
256256
if err != nil {
257-
fmt.Println("MFA token must be 6 digits. Please try again.")
257+
logger.Println("MFA token must be 6 digits. Please try again.")
258258
continue
259259
}
260260
token = t
@@ -265,7 +265,7 @@ func promptMFAtoken(messagePrefix string, logger *log.Logger) string {
265265
func getMFATokenPair(logger *log.Logger) MFATokenPair {
266266
var mfaTokenPair MFATokenPair
267267
for attempts := maxMFATokenPromptAttempts; attempts > 0; attempts-- {
268-
fmt.Printf("Two unique MFA tokens needed to activate MFA device (%d attempts remaining)\n", attempts)
268+
logger.Printf("Two unique MFA tokens needed to activate MFA device (%d attempts remaining)\n", attempts)
269269
authToken1 := promptMFAtoken("First ", logger)
270270
authToken2 := promptMFAtoken("Second ", logger)
271271

@@ -317,6 +317,7 @@ func (u *User) EnableVirtualMFADevice(logger *log.Logger) error {
317317
func (u *User) RotateAccessKeys(logger *log.Logger) error {
318318
logger.Println("Rotating AWS access keys")
319319

320+
logger.Println("A new unique MFA token is needed to rotate the AWS access keys")
320321
sess, err := u.newMFASession(logger)
321322
if err != nil {
322323
return fmt.Errorf("unable to get mfa session: %w", err)
@@ -504,7 +505,7 @@ func openQrCode(tempFile *os.File) error {
504505
}
505506

506507
func checkExistingAWSProfile(profileName string, config *vault.Config, logger *log.Logger) error {
507-
logger.Println("Checking whether profile exists in AWS config file")
508+
logger.Printf("Checking whether profile %q exists in AWS config file\n", profileName)
508509
_, exists := config.Profile(profileName)
509510
if exists {
510511
return fmt.Errorf("Profile already exists in AWS config file: %s", profileName)

0 commit comments

Comments
 (0)