Create creates a TaskTree for creating nodegroups.
(ctx context.Context, options CreateNodeGroupOptions)
| 82 | |
| 83 | // Create creates a TaskTree for creating nodegroups. |
| 84 | func (t *UnmanagedNodeGroupTask) Create(ctx context.Context, options CreateNodeGroupOptions) *tasks.TaskTree { |
| 85 | taskTree := &tasks.TaskTree{Parallel: true, Limit: options.Parallelism} |
| 86 | |
| 87 | for _, ng := range t.NodeGroups { |
| 88 | ng := ng |
| 89 | createAccessEntryInStack := ng.IAM.InstanceRoleARN == "" |
| 90 | createNodeGroupTask := &tasks.GenericTask{ |
| 91 | Description: fmt.Sprintf("create nodegroup %q", ng.NameString()), |
| 92 | Doer: func() error { |
| 93 | return t.createNodeGroup(ctx, ng, options, createAccessEntryInStack) |
| 94 | }, |
| 95 | } |
| 96 | |
| 97 | if options.DisableAccessEntryCreation || createAccessEntryInStack { |
| 98 | taskTree.Append(createNodeGroupTask) |
| 99 | } else { |
| 100 | var ngTask tasks.TaskTree |
| 101 | ngTask.Append(createNodeGroupTask) |
| 102 | ngTask.Append(&tasks.GenericTask{ |
| 103 | Description: fmt.Sprintf("create access entry for nodegroup %q", ng.NameString()), |
| 104 | Doer: func() error { |
| 105 | return t.maybeCreateAccessEntry(ctx, ng) |
| 106 | }, |
| 107 | }) |
| 108 | taskTree.Append(&ngTask) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | return taskTree |
| 113 | } |
| 114 | |
| 115 | func (t *UnmanagedNodeGroupTask) createNodeGroup(ctx context.Context, ng *api.NodeGroup, options CreateNodeGroupOptions, createAccessEntryInStack bool) error { |
| 116 | name := makeNodeGroupStackName(t.ClusterConfig.Metadata.Name, ng.Name) |
no test coverage detected