dealTask "block" argument is not defined in block.
(ctx context.Context, hosts []string, when []string, block kkprojectv1.Block)
| 164 | |
| 165 | // dealTask "block" argument is not defined in block. |
| 166 | func (e blockExecutor) dealTask(ctx context.Context, hosts []string, when []string, block kkprojectv1.Block) error { |
| 167 | task := converter.MarshalBlock(hosts, when, block) |
| 168 | // complete module by unknown field |
| 169 | for n, a := range block.UnknownField { |
| 170 | data, err := json.Marshal(a) |
| 171 | if err != nil { |
| 172 | return errors.Wrapf(err, "failed to marshal block %q unknown filed %q in playbook", block.Name, n, ctrlclient.ObjectKeyFromObject(e.playbook)) |
| 173 | } |
| 174 | if m := modules.FindModule(n); m != nil { |
| 175 | task.Spec.Module.Name = n |
| 176 | task.Spec.Module.Args = runtime.RawExtension{Raw: data} |
| 177 | |
| 178 | break |
| 179 | } |
| 180 | } |
| 181 | if task.Spec.Module.Name == "" { // action is necessary for a task |
| 182 | return errors.Errorf("no module/action detected in task: [%s]%s", task.Annotations[kkcorev1alpha1.TaskAnnotationRelativePath], task.Spec.Name) |
| 183 | } |
| 184 | // complete by playbook |
| 185 | task.GenerateName = e.playbook.Name + "-" |
| 186 | task.Namespace = e.playbook.Namespace |
| 187 | if err := ctrl.SetControllerReference(e.playbook, task, e.client.Scheme()); err != nil { |
| 188 | return errors.Wrapf(err, "failed to set playbook %q ownerReferences to %q", ctrlclient.ObjectKeyFromObject(e.playbook), block.Name) |
| 189 | } |
| 190 | |
| 191 | return (&taskExecutor{option: e.option, task: task}).Exec(ctx) |
| 192 | } |
no test coverage detected