MCPcopy
hub / github.com/containerd/containerd / processEnvironment

Function processEnvironment

integration/failpoint/cmd/runc-fp/delayexec.go:96–131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

94}
95
96func processEnvironment() (map[string]string, error) {
97 idx := 2
98 for ; idx < len(os.Args); idx++ {
99 if os.Args[idx] == "--process" {
100 break
101 }
102 }
103
104 if idx >= len(os.Args)-1 || os.Args[idx] != "--process" {
105 return nil, errors.New("env: option --process required")
106 }
107
108 specFile := os.Args[idx+1]
109 f, err := os.OpenFile(specFile, os.O_RDONLY, 0o644)
110 if err != nil {
111 return nil, fmt.Errorf("env: failed to open %s: %w", specFile, err)
112 }
113
114 b, err := io.ReadAll(f)
115 if err != nil {
116 return nil, fmt.Errorf("env: failed to read spec from %q", specFile)
117 }
118 var spec specs.Process
119 if err := json.Unmarshal(b, &spec); err != nil {
120 return nil, fmt.Errorf("env: failed to unmarshal spec from %q: %w", specFile, err)
121 }
122
123 // XXX: env vars can be specified multiple times, but we only keep one
124 env := make(map[string]string)
125 for _, e := range spec.Env {
126 k, v, _ := strings.Cut(e, "=")
127 env[k] = v
128 }
129
130 return env, nil
131}

Callers 1

fifoFromProcessEnvFunction · 0.85

Calls 1

UnmarshalMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…