Skip to content

Commit

Permalink
change from OtherAccounts to AllAccounts (#10)
Browse files Browse the repository at this point in the history
This matches the semantics of sicc.
  • Loading branch information
ryanking committed Jun 27, 2018
1 parent 9b96aa7 commit 61474e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions plan/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
type account struct {
AccountID *int64
AccountName string
AllAccounts map[string]int64
AWSProfileBackend string
AWSProfileProvider string
AWSProviderVersion string
AWSRegion string
AWSRegions []string
InfraBucket string
OtherAccounts map[string]int64
Owner string
Project string
TerraformVersion string
Expand Down Expand Up @@ -108,8 +108,8 @@ func Print(p *Plan) error {
fmt.Printf("\t\tproject: %v\n", account.Project)
fmt.Printf("\t\tterraform_version: %v\n", account.TerraformVersion)

fmt.Printf("\t\tother_accounts:\n")
for acct, id := range account.OtherAccounts {
fmt.Printf("\t\tall_accounts:\n")
for acct, id := range account.AllAccounts {
fmt.Printf("\t\t\t%s: %d\n", acct, id)
}

Expand Down Expand Up @@ -177,7 +177,7 @@ func buildAccounts(c *config.Config) map[string]account {
accountPlan.AWSProfileBackend = resolveRequired(defaults.AWSProfileBackend, config.AWSProfileBackend)
accountPlan.AWSProfileProvider = resolveRequired(defaults.AWSProfileProvider, config.AWSProfileProvider)
accountPlan.AWSProviderVersion = resolveRequired(defaults.AWSProviderVersion, config.AWSProviderVersion)
accountPlan.OtherAccounts = resolveOtherAccounts(c.Accounts, name)
accountPlan.AllAccounts = resolveAccounts(c.Accounts)
accountPlan.TerraformVersion = resolveRequired(defaults.TerraformVersion, config.TerraformVersion)
accountPlan.InfraBucket = resolveRequired(defaults.InfraBucket, config.InfraBucket)
accountPlan.Owner = resolveRequired(defaults.Owner, config.Owner)
Expand Down Expand Up @@ -287,12 +287,12 @@ func resolveOptionalInt(def *int64, override *int64) *int64 {
return def
}

func resolveOtherAccounts(accounts map[string]config.Account, currentAccount string) map[string]int64 {
other := make(map[string]int64)
func resolveAccounts(accounts map[string]config.Account) map[string]int64 {
a := make(map[string]int64)
for name, account := range accounts {
if name != currentAccount && account.AccountID != nil {
other[name] = *account.AccountID
if account.AccountID != nil {
a[name] = *account.AccountID
}
}
return other
return a
}
6 changes: 3 additions & 3 deletions plan/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestResolveRequired(t *testing.T) {
assert.Equal(t, "over", resolved)
}

func TestResolveOtherAccounts(t *testing.T) {
func TestResolveAccounts(t *testing.T) {
foo, bar := int64(123), int64(456)

accounts := map[string]config.Account{
Expand All @@ -30,9 +30,9 @@ func TestResolveOtherAccounts(t *testing.T) {
"baz": {},
}

other := resolveOtherAccounts(accounts, "foo")
other := resolveAccounts(accounts)
assert.NotNil(t, other)
assert.Equal(t, map[string]int64{"bar": bar}, other)
assert.Equal(t, map[string]int64{"bar": bar, "foo": foo}, other)
}

func TestResolveStringArray(t *testing.T) {
Expand Down

0 comments on commit 61474e3

Please sign in to comment.