MCPcopy
hub / github.com/rancher/local-path-provisioner / loadHelperPodFile

Function loadHelperPodFile

util.go:28–45  ·  view source on GitHub ↗
(helperPodYaml string, allowUnsafe bool)

Source from the content-addressed store, hash-verified

26}
27
28func 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
47func validateHelperPodTemplate(p *v1.Pod, allowUnsafe bool) error {
48 if allowUnsafe {

Callers 3

TestLoadHelperPodFileFunction · 0.85
NewProvisionerFunction · 0.85
refreshHelperPodMethod · 0.85

Calls 1

Tested by 1

TestLoadHelperPodFileFunction · 0.68