-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manage IAM instance profiles #39
Merged
mtibben
merged 7 commits into
99designs:master
from
envato:andrewjhumphrey-manage-instance-profiles
Nov 14, 2017
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fdfaa81
Manage IAM instance profiles
andrewjhumphrey 043328d
Fix whitespace problems
andrewjhumphrey 728fc67
Remove unnecessary guard test, golang range does the right thing
andrewjhumphrey 2d2144a
More whitespace fixes
andrewjhumphrey 4b08e46
Found it! Fixed
andrewjhumphrey a0ccc80
go fmt? Who knew! *blush*
andrewjhumphrey c351b24
Use ARN standard of - instead of _
andrewjhumphrey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,6 +113,15 @@ type Role struct { | |
Policies []string `json:"Policies,omitempty"` | ||
} | ||
|
||
type InstanceProfile struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we probably want to fix the alignment on this one type InstanceProfile struct {
iamService `json:"-"`
Roles []string `json:"Roles,omitempty"`
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's aligned if your tabs are set to 8 :-) |
||
iamService `json:"-"` | ||
Roles []string `json:"Roles,omitempty"` | ||
} | ||
|
||
func (ip InstanceProfile) ResourceType() string { | ||
return "instance-profile" | ||
} | ||
|
||
func (r Role) ResourceType() string { | ||
return "role" | ||
} | ||
|
@@ -139,21 +148,23 @@ func (bp BucketPolicy) ResourcePath() string { | |
} | ||
|
||
type AccountData struct { | ||
Account *Account | ||
Users []*User | ||
Groups []*Group | ||
Roles []*Role | ||
Policies []*Policy | ||
BucketPolicies []*BucketPolicy | ||
Account *Account | ||
Users []*User | ||
Groups []*Group | ||
Roles []*Role | ||
Policies []*Policy | ||
BucketPolicies []*BucketPolicy | ||
InstanceProfiles []*InstanceProfile | ||
} | ||
|
||
func NewAccountData(account string) *AccountData { | ||
return &AccountData{ | ||
Account: NewAccountFromString(account), | ||
Users: []*User{}, | ||
Groups: []*Group{}, | ||
Roles: []*Role{}, | ||
Policies: []*Policy{}, | ||
Account: NewAccountFromString(account), | ||
Users: []*User{}, | ||
Groups: []*Group{}, | ||
Roles: []*Role{}, | ||
Policies: []*Policy{}, | ||
InstanceProfiles: []*InstanceProfile{}, | ||
} | ||
} | ||
|
||
|
@@ -173,6 +184,10 @@ func (a *AccountData) addPolicy(p *Policy) { | |
a.Policies = append(a.Policies, p) | ||
} | ||
|
||
func (a *AccountData) addInstanceProfile(p *InstanceProfile) { | ||
a.InstanceProfiles = append(a.InstanceProfiles, p) | ||
} | ||
|
||
func (a *AccountData) addBucketPolicy(bp *BucketPolicy) { | ||
a.BucketPolicies = append(a.BucketPolicies, bp) | ||
} | ||
|
@@ -217,6 +232,16 @@ func (a *AccountData) FindPolicyByName(name, path string) (bool, *Policy) { | |
return false, nil | ||
} | ||
|
||
func (a *AccountData) FindInstanceProfileByName(name, path string) (bool, *InstanceProfile) { | ||
for _, p := range a.InstanceProfiles { | ||
if p.Name == name && p.Path == path { | ||
return true, p | ||
} | ||
} | ||
|
||
return false, nil | ||
} | ||
|
||
func (a *AccountData) FindBucketPolicyByBucketName(name string) (bool, *BucketPolicy) { | ||
for _, p := range a.BucketPolicies { | ||
if p.BucketName == name { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this need to be here? looks like you've already got a check for this on L136.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's right, the L136 is to escape the iterator function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it needs to be there.
The function that includes line 136 is called by the paging function a.iam.ListInstanceProfilesPages with each back results. So the return false is effectively the break.