-
Notifications
You must be signed in to change notification settings - Fork 1
/
accountId.go
34 lines (26 loc) · 1.01 KB
/
accountId.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/******************************************************************************
Cloud Resource Counter
File: accountId.go
Summary: Retrieve account ID (assumed to be a single value) for the current
user session.
******************************************************************************/
package main
import (
color "github.com/logrusorgru/aurora"
)
// GetAccountID returns the Amazon Account ID for the supplied session, showing activity
// in the process and handling potential errors.
// It relies a supplied AccountIDService struct which has a single method: Account.
// It also relies on a supplied ActivityMonitor which it uses to inform the user of
// what it is doing.
func GetAccountID(cis *AccountIDService, am ActivityMonitor) string {
// Indicate activity
am.StartAction("Retrieving Account ID")
// Get the caller's identity
accountID, err := cis.Account()
// Check for error
am.CheckError(err)
// Indicate end of activity
am.EndAction("OK (%s)", color.Bold(accountID))
return accountID
}