Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ed4a99
commit 1645925
Showing
22 changed files
with
517 additions
and
206 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
package iam | ||
package irsa | ||
|
||
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), false) | ||
taskTree := a.stackManager.NewTasksToCreateIAMServiceAccounts(iamServiceAccounts, a.oidcManager, kubernetes.NewCachedClientSet(a.clientSet)) | ||
taskTree.PlanMode = plan | ||
|
||
err := doTasks(taskTree) | ||
|
||
cmdutils.LogPlanModeWarning(plan && len(iamServiceAccounts) > 0) | ||
logPlanModeWarning(plan && len(iamServiceAccounts) > 0) | ||
|
||
return err | ||
} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package irsa | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/kris-nova/logger" | ||
"github.com/weaveworks/eksctl/pkg/kubernetes" | ||
) | ||
|
||
func (m *Manager) Delete(shouldDelete func(string) bool, plan, wait bool) error { | ||
taskTree, err := m.stackManager.NewTasksToDeleteIAMServiceAccounts(shouldDelete, kubernetes.NewCachedClientSet(m.clientSet), wait) | ||
if err != nil { | ||
return err | ||
} | ||
taskTree.PlanMode = plan | ||
|
||
logger.Info(taskTree.Describe()) | ||
if errs := taskTree.DoAllSync(); len(errs) > 0 { | ||
logger.Info("%d error(s) occurred and IAM Role stacks haven't been deleted 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 delete iamserviceaccount(s)") | ||
} | ||
|
||
logPlanModeWarning(plan && taskTree.Len() > 0) | ||
return nil | ||
} |
175 changes: 163 additions & 12 deletions
175
pkg/actions/iam/fakes/fake_stack_manager.go → pkg/actions/irsa/fakes/fake_stack_manager.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package irsa | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5" | ||
) | ||
|
||
func (m *Manager) Get(namespace, name string) ([]*api.ClusterIAMServiceAccount, error) { | ||
remoteServiceAccounts, err := m.stackManager.GetIAMServiceAccounts() | ||
if err != nil { | ||
return nil, errors.Wrap(err, "getting iamserviceaccounts") | ||
} | ||
|
||
if namespace != "" { | ||
remoteServiceAccounts = filterByNamespace(remoteServiceAccounts, namespace) | ||
} | ||
|
||
if name != "" { | ||
remoteServiceAccounts = filterByName(remoteServiceAccounts, name) | ||
} | ||
|
||
return remoteServiceAccounts, nil | ||
} | ||
|
||
func filterByNamespace(serviceAccounts []*api.ClusterIAMServiceAccount, namespace string) []*api.ClusterIAMServiceAccount { | ||
var serviceAccountsMatching []*api.ClusterIAMServiceAccount | ||
for _, sa := range serviceAccounts { | ||
if sa.Namespace == namespace { | ||
serviceAccountsMatching = append(serviceAccountsMatching, sa) | ||
} | ||
} | ||
return serviceAccountsMatching | ||
} | ||
|
||
func filterByName(serviceAccounts []*api.ClusterIAMServiceAccount, name string) []*api.ClusterIAMServiceAccount { | ||
var serviceAccountsMatching []*api.ClusterIAMServiceAccount | ||
for _, sa := range serviceAccounts { | ||
if sa.Name == name { | ||
serviceAccountsMatching = append(serviceAccountsMatching, sa) | ||
} | ||
} | ||
return serviceAccountsMatching | ||
} |
Oops, something went wrong.