-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Update iamserviceaccount role policies #3064
Changes from 15 commits
b03a113
9153a70
3768616
f768529
89ac242
2eeab55
1886f9c
23b6df5
0e338f8
471f21a
4d2b6ee
3c9a7f6
4262557
e20e643
47c3b30
9891acd
8dfe824
65d4c07
f303006
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package iam | ||
|
||
import ( | ||
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5" | ||
"github.com/weaveworks/eksctl/pkg/ctl/cmdutils" | ||
"github.com/weaveworks/eksctl/pkg/kubernetes" | ||
) | ||
|
||
func (a *Manager) CreateIAMServiceAccount(iamServiceAccounts []*api.ClusterIAMServiceAccount, plan bool) error { | ||
taskTree := a.stackManager.NewTasksToCreateIAMServiceAccounts(iamServiceAccounts, a.oidcManager, kubernetes.NewCachedClientSet(a.clientSet)) | ||
taskTree.PlanMode = plan | ||
|
||
err := doTasks(taskTree) | ||
|
||
cmdutils.LogPlanModeWarning(plan && len(iamServiceAccounts) > 0) | ||
|
||
return err | ||
} | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package iam | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/kris-nova/logger" | ||
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5" | ||
"github.com/weaveworks/eksctl/pkg/cfn/manager" | ||
"github.com/weaveworks/eksctl/pkg/eks" | ||
iamoidc "github.com/weaveworks/eksctl/pkg/iam/oidc" | ||
"github.com/weaveworks/eksctl/pkg/kubernetes" | ||
"github.com/weaveworks/eksctl/pkg/utils/tasks" | ||
kubeclient "k8s.io/client-go/kubernetes" | ||
) | ||
|
||
type Manager struct { | ||
clusterName string | ||
clusterProvider *eks.ClusterProvider | ||
oidcManager *iamoidc.OpenIDConnectManager | ||
stackManager StackManager | ||
clientSet kubeclient.Interface | ||
} | ||
|
||
//go:generate counterfeiter -o fakes/fake_stack_manager.go . StackManager | ||
type StackManager interface { | ||
ListStacksMatching(nameRegex string, statusFilters ...string) ([]*manager.Stack, error) | ||
UpdateStack(stackName, changeSetName, description string, templateData manager.TemplateData, parameters map[string]string) error | ||
NewTasksToCreateIAMServiceAccounts(serviceAccounts []*api.ClusterIAMServiceAccount, oidc *iamoidc.OpenIDConnectManager, clientSetGetter kubernetes.ClientSetGetter) *tasks.TaskTree | ||
} | ||
|
||
func New(clusterName string, clusterProvider *eks.ClusterProvider, stackManager StackManager, oidcManager *iamoidc.OpenIDConnectManager, clientSet kubeclient.Interface) *Manager { | ||
return &Manager{ | ||
clusterName: clusterName, | ||
clusterProvider: clusterProvider, | ||
oidcManager: oidcManager, | ||
stackManager: stackManager, | ||
clientSet: clientSet, | ||
} | ||
} | ||
|
||
func doTasks(taskTree *tasks.TaskTree) error { | ||
logger.Info(taskTree.Describe()) | ||
if errs := taskTree.DoAllSync(); len(errs) > 0 { | ||
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. hmm doesn't this exist in some form in the tasks package? 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. I couldn't see anything 🤔 |
||
logger.Info("%d error(s) occurred and IAM Role stacks haven't been updated properly, you may wish to check CloudFormation console", len(errs)) | ||
for _, err := range errs { | ||
logger.Critical("%s\n", err.Error()) | ||
} | ||
return fmt.Errorf("failed to create iamserviceaccount(s)") | ||
} | ||
return nil | ||
} |
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've left this here for now, if folks want me to remove this small refactor and put it into the refactor PR let me know.