MCPcopy
hub / github.com/containerd/containerd / BinaryHandler

Function BinaryHandler

core/diff/stream.go:175–189  ·  view source on GitHub ↗

BinaryHandler creates a new stream processor handler which calls out to the given binary. The id is used to identify the stream processor and allows the caller to send payloads specific for that stream processor (i.e. decryption keys for decrypt stream processor). The binary will be called for the p

(id, returnsMediaType string, mediaTypes []string, path string, args, env []string)

Source from the content-addressed store, hash-verified

173// payloads specific for that stream processor (i.e. decryption keys for decrypt stream processor).
174// The binary will be called for the provided mediaTypes and return the given media type.
175func BinaryHandler(id, returnsMediaType string, mediaTypes []string, path string, args, env []string) Handler {
176 set := make(map[string]struct{}, len(mediaTypes))
177 for _, m := range mediaTypes {
178 set[m] = struct{}{}
179 }
180 return func(_ context.Context, mediaType string) (StreamProcessorInit, bool) {
181 if _, ok := set[mediaType]; ok {
182 return func(ctx context.Context, stream StreamProcessor, payloads map[string]typeurl.Any) (StreamProcessor, error) {
183 payload := payloads[id]
184 return NewBinaryProcessor(ctx, mediaType, returnsMediaType, stream, path, args, env, payload)
185 }, true
186 }
187 return nil, false
188 }
189}
190
191const mediaTypeEnvVar = "STREAM_PROCESSOR_MEDIATYPE"

Callers 1

NewFunction · 0.92

Calls 1

NewBinaryProcessorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…