Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1129 from weaveworks/append-cluster-config-tasks
Refactor how additional cluster config tasks are handled
- Loading branch information
Showing
3 changed files
with
47 additions
and
39 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
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,44 @@ | ||
package eks | ||
|
||
import ( | ||
"github.com/kris-nova/logger" | ||
|
||
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5" | ||
"github.com/weaveworks/eksctl/pkg/cfn/manager" | ||
) | ||
|
||
type clusterConfigTask struct { | ||
info string | ||
spec *api.ClusterConfig | ||
call func(*api.ClusterConfig) error | ||
} | ||
|
||
func (t *clusterConfigTask) Describe() string { return t.info } | ||
|
||
func (t *clusterConfigTask) Do(errs chan error) error { | ||
err := t.call(t.spec) | ||
close(errs) | ||
return err | ||
} | ||
|
||
// AppendExtraClusterConfigTasks returns all tasks for updating cluster configuration or nil if there are no tasks | ||
func (c *ClusterProvider) AppendExtraClusterConfigTasks(cfg *api.ClusterConfig, tasks *manager.TaskTree) { | ||
newTasks := &manager.TaskTree{ | ||
Parallel: false, | ||
IsSubTask: true, | ||
} | ||
if !cfg.HasClusterCloudWatchLogging() { | ||
logger.Info("CloudWatch logging will not be enabled for cluster %q in %q", cfg.Metadata.Name, cfg.Metadata.Region) | ||
logger.Info("you can enable it with 'eksctl utils update-cluster-logging --region=%s --name=%s'", cfg.Metadata.Region, cfg.Metadata.Name) | ||
|
||
} else { | ||
newTasks.Append(&clusterConfigTask{ | ||
info: "update CloudWatch logging configuration", | ||
spec: cfg, | ||
call: c.UpdateClusterConfigForLogging, | ||
}) | ||
} | ||
if newTasks.Len() > 0 { | ||
tasks.Append(newTasks) | ||
} | ||
} |
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