| 26 | } |
| 27 | |
| 28 | func loadHelperPodFile(helperPodYaml string, allowUnsafe bool) (*v1.Pod, error) { |
| 29 | helperPodJSON, err := yaml.YAMLToJSON([]byte(helperPodYaml)) |
| 30 | if err != nil { |
| 31 | return nil, fmt.Errorf("invalid YAMLToJSON the helper pod with helperPodYaml: %v", helperPodYaml) |
| 32 | } |
| 33 | p := v1.Pod{} |
| 34 | err = json.Unmarshal(helperPodJSON, &p) |
| 35 | if err != nil { |
| 36 | return nil, fmt.Errorf("invalid unmarshal the helper pod with helperPodJson: %v", string(helperPodJSON)) |
| 37 | } |
| 38 | if len(p.Spec.Containers) == 0 { |
| 39 | return nil, fmt.Errorf("helper pod template does not specify any container") |
| 40 | } |
| 41 | if err := validateHelperPodTemplate(&p, allowUnsafe); err != nil { |
| 42 | return nil, err |
| 43 | } |
| 44 | return &p, nil |
| 45 | } |
| 46 | |
| 47 | func validateHelperPodTemplate(p *v1.Pod, allowUnsafe bool) error { |
| 48 | if allowUnsafe { |