diff --git a/pkg/coordinator/scheduler/options.go b/pkg/coordinator/scheduler/options.go index 4acdf74..fdf4e95 100644 --- a/pkg/coordinator/scheduler/options.go +++ b/pkg/coordinator/scheduler/options.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/ethpandaops/assertoor/pkg/coordinator/helper" - "github.com/ethpandaops/assertoor/pkg/coordinator/human-duration" "github.com/ethpandaops/assertoor/pkg/coordinator/types" "gopkg.in/yaml.v3" ) @@ -18,37 +17,18 @@ func (ts *TaskScheduler) ParseTaskOptions(rawtask *helper.RawMessage) (*types.Ta return options, nil } -type TaskOptsSettings struct { - // The title of the task - this is used to describe the task to the user. - Title string `yaml:"title" json:"title"` - // The configuration settings to consume from runtime variables. - ConfigVars map[string]string `yaml:"configVars" json:"configVars"` - // Timeout defines the max time waiting for the condition to be met. - Timeout human.Duration `yaml:"timeout" json:"timeout"` -} - -func (ts *TaskScheduler) NewTaskOptions(task *types.TaskDescriptor, config interface{}, settings *TaskOptsSettings) (*types.TaskOptions, error) { - options := &types.TaskOptions{ - Name: task.Name, +func GetRawConfig(config interface{}) *helper.RawMessage { + configYaml, err := yaml.Marshal(config) + if err != nil { + return nil } - if settings != nil { - options.Title = settings.Title - options.ConfigVars = settings.ConfigVars - options.Timeout = settings.Timeout - } + configRaw := helper.RawMessage{} - if config != nil { - configYaml, err := yaml.Marshal(config) - if err != nil { - return nil, fmt.Errorf("error serializing task config: %w", err) - } - - err = yaml.Unmarshal(configYaml, options.Config) - if err != nil { - return nil, fmt.Errorf("error parsing task config: %w", err) - } + err = yaml.Unmarshal(configYaml, &configRaw) + if err != nil { + return nil } - return options, nil + return &configRaw } diff --git a/pkg/coordinator/scheduler/services.go b/pkg/coordinator/scheduler/services.go new file mode 100644 index 0000000..b9b83cd --- /dev/null +++ b/pkg/coordinator/scheduler/services.go @@ -0,0 +1,34 @@ +package scheduler + +import ( + "github.com/ethpandaops/assertoor/pkg/coordinator/clients" + "github.com/ethpandaops/assertoor/pkg/coordinator/names" + "github.com/ethpandaops/assertoor/pkg/coordinator/types" + "github.com/ethpandaops/assertoor/pkg/coordinator/wallet" +) + +type servicesProvider struct { + clientPool *clients.ClientPool + walletManager *wallet.Manager + validatorNames *names.ValidatorNames +} + +func NewServicesProvider(clientPool *clients.ClientPool, walletManager *wallet.Manager, validatorNames *names.ValidatorNames) types.TaskServices { + return &servicesProvider{ + clientPool: clientPool, + walletManager: walletManager, + validatorNames: validatorNames, + } +} + +func (p *servicesProvider) ClientPool() *clients.ClientPool { + return p.clientPool +} + +func (p *servicesProvider) WalletManager() *wallet.Manager { + return p.walletManager +} + +func (p *servicesProvider) ValidatorNames() *names.ValidatorNames { + return p.validatorNames +}