MCPcopy
hub / github.com/containerd/containerd / SetLabels

Method SetLabels

client/container.go:147–169  ·  view source on GitHub ↗
(ctx context.Context, labels map[string]string)

Source from the content-addressed store, hash-verified

145}
146
147func (c *container) SetLabels(ctx context.Context, labels map[string]string) (map[string]string, error) {
148 ctx, span := tracing.StartSpan(ctx, "container.SetLabels",
149 tracing.WithAttribute("container.id", c.id),
150 )
151 defer span.End()
152 container := containers.Container{
153 ID: c.id,
154 Labels: labels,
155 }
156
157 var paths []string
158 // mask off paths so we only muck with the labels encountered in labels.
159 // Labels not in the passed in argument will be left alone.
160 for k := range labels {
161 paths = append(paths, strings.Join([]string{"labels", k}, "."))
162 }
163
164 r, err := c.client.ContainerService().Update(ctx, container, paths...)
165 if err != nil {
166 return nil, err
167 }
168 return r.Labels, nil
169}
170
171// Spec returns the current OCI specification for the container
172func (c *container) Spec(ctx context.Context) (*oci.Spec, error) {

Callers

nothing calls this directly

Calls 5

StartSpanFunction · 0.92
WithAttributeFunction · 0.92
EndMethod · 0.80
ContainerServiceMethod · 0.80
UpdateMethod · 0.65

Tested by

no test coverage detected