MCPcopy
hub / github.com/containerd/containerd / Validate

Function Validate

pkg/labels/validate.go:33–42  ·  view source on GitHub ↗

Validate a label's key and value are under 4096 bytes

(k, v string)

Source from the content-addressed store, hash-verified

31
32// Validate a label's key and value are under 4096 bytes
33func Validate(k, v string) error {
34 total := len(k) + len(v)
35 if total > maxSize {
36 if len(k) > keyMaxLen {
37 k = k[:keyMaxLen]
38 }
39 return fmt.Errorf("label key and value length (%d bytes) greater than maximum size (%d bytes), key: %s: %w", total, maxSize, k, errdefs.ErrInvalidArgument)
40 }
41 return nil
42}
43
44// IsReserved returns true if the label key is in a namespace reserved for
45// containerd (ReservedPrefix) or its CRI plugin (CRIContainerdPrefix).

Callers 8

validateInfoFunction · 0.92
validateSnapshotFunction · 0.92
validateContainerFunction · 0.92
validateImageFunction · 0.92
TestValidLabelsFunction · 0.70
TestInvalidLabelsFunction · 0.70
TestLongKeyFunction · 0.70

Calls

no outgoing calls

Tested by 3

TestValidLabelsFunction · 0.56
TestInvalidLabelsFunction · 0.56
TestLongKeyFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…