mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-31 08:22:50 +00:00
33 lines
632 B
Go
33 lines
632 B
Go
package modules
|
|
|
|
import (
|
|
"github.com/kubesphere/kubekey/pkg/core/connector"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type BaseTaskModule struct {
|
|
BaseModule
|
|
Tasks []*Task
|
|
}
|
|
|
|
func (b *BaseTaskModule) Init() {
|
|
if b.Name == "" {
|
|
b.Name = DefaultTaskModuleName
|
|
}
|
|
}
|
|
|
|
func (b *BaseTaskModule) Is() string {
|
|
return TaskModuleType
|
|
}
|
|
|
|
func (b *BaseTaskModule) Run() error {
|
|
for i := range b.Tasks {
|
|
task := b.Tasks[i]
|
|
task.Init(b.Name, b.Runtime.(connector.Runtime), b.ModuleCache, b.PipelineCache)
|
|
if res := task.Execute(); res.IsFailed() {
|
|
return errors.Wrapf(res.CombineErr(), "Module[%s] exec failed", b.Name)
|
|
}
|
|
}
|
|
return nil
|
|
}
|