// Init is part of the workflow.Factory interface. func (f *WorkflowFactory) Init(w *workflowpb.Workflow, args []string) error { // No parameters to parse. if len(args) > 0 { return fmt.Errorf("topovalidator doesn't take any parameter") } w.Name = "Topology Validator" return nil }
// Init is part of the workflow.Factory interface. func (f *SleepWorkflowFactory) Init(w *workflowpb.Workflow, args []string) error { // Parse the flags. subFlags := flag.NewFlagSet(sleepFactoryName, flag.ContinueOnError) duration := subFlags.Int("duration", 30, "How long to sleep") if err := subFlags.Parse(args); err != nil { return err } if *duration <= 0 { return fmt.Errorf("duration cannot be a negative number") } // Build the Workflow object. w.Name = fmt.Sprintf("Sleep(%v seconds)", *duration) data := &SleepWorkflowData{ Duration: *duration, } var err error w.Data, err = json.Marshal(data) if err != nil { return err } return nil }