MCPcopy Index your code
hub / github.com/containerd/containerd / putObject

Function putObject

plugins/snapshots/devmapper/metadata.go:340–357  ·  view source on GitHub ↗
(bucket *bolt.Bucket, key string, obj any, overwrite bool)

Source from the content-addressed store, hash-verified

338}
339
340func putObject(bucket *bolt.Bucket, key string, obj any, overwrite bool) error {
341 keyBytes := []byte(key)
342
343 if !overwrite && bucket.Get(keyBytes) != nil {
344 return fmt.Errorf("object with key %q already exists", key)
345 }
346
347 data, err := json.Marshal(obj)
348 if err != nil {
349 return fmt.Errorf("failed to marshal object with key %q: %w", key, err)
350 }
351
352 if err := bucket.Put(keyBytes, data); err != nil {
353 return fmt.Errorf("failed to insert object with key %q: %w", key, err)
354 }
355
356 return nil
357}
358
359func getObject(bucket *bolt.Bucket, key string, obj any) error {
360 data := bucket.Get([]byte(key))

Callers 3

AddDeviceMethod · 0.85
MarkFaultyMethod · 0.85
UpdateDeviceMethod · 0.85

Calls 3

PutMethod · 0.80
GetMethod · 0.65
MarshalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…