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

Method Create

plugins/services/namespaces/local.go:123–153  ·  view source on GitHub ↗
(ctx context.Context, req *api.CreateNamespaceRequest, _ ...grpc.CallOption)

Source from the content-addressed store, hash-verified

121}
122
123func (l *local) Create(ctx context.Context, req *api.CreateNamespaceRequest, _ ...grpc.CallOption) (*api.CreateNamespaceResponse, error) {
124 var resp api.CreateNamespaceResponse
125
126 if err := l.withStoreUpdate(ctx, func(ctx context.Context, store namespaces.Store) error {
127 if err := store.Create(ctx, req.Namespace.Name, req.Namespace.Labels); err != nil {
128 return errgrpc.ToGRPC(err)
129 }
130
131 for k, v := range req.Namespace.Labels {
132 if err := store.SetLabel(ctx, req.Namespace.Name, k, v); err != nil {
133 return err
134 }
135 }
136
137 resp.Namespace = req.Namespace
138 return nil
139 }); err != nil {
140 return &resp, err
141 }
142
143 ctx = namespaces.WithNamespace(ctx, req.Namespace.Name)
144 if err := l.publisher.Publish(ctx, "/namespaces/create", &eventstypes.NamespaceCreate{
145 Name: req.Namespace.Name,
146 Labels: req.Namespace.Labels,
147 }); err != nil {
148 return &resp, err
149 }
150
151 return &resp, nil
152
153}
154
155func (l *local) Update(ctx context.Context, req *api.UpdateNamespaceRequest, _ ...grpc.CallOption) (*api.UpdateNamespaceResponse, error) {
156 var resp api.UpdateNamespaceResponse

Callers

nothing calls this directly

Calls 5

withStoreUpdateMethod · 0.95
WithNamespaceFunction · 0.92
CreateMethod · 0.65
SetLabelMethod · 0.65
PublishMethod · 0.65

Tested by

no test coverage detected