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

Function applyFlags

cmd/containerd/command/main.go:283–350  ·  view source on GitHub ↗
(cliContext *cli.Context, config *srvconfig.Config)

Source from the content-addressed store, hash-verified

281}
282
283func applyFlags(cliContext *cli.Context, config *srvconfig.Config) error {
284 // the order for config vs flag values is that flags will always override
285 // the config values if they are set
286 if err := setLogLevel(cliContext, config); err != nil {
287 return err
288 }
289 if err := setLogFormat(config); err != nil {
290 return err
291 }
292
293 for _, v := range []struct {
294 name string
295 d *string
296 }{
297 {
298 name: "root",
299 d: &config.Root,
300 },
301 {
302 name: "state",
303 d: &config.State,
304 },
305 } {
306 if s := cliContext.String(v.name); s != "" {
307 *v.d = s
308 if v.name == "root" || v.name == "state" {
309 absPath, err := filepath.Abs(s)
310 if err != nil {
311 return err
312 }
313 *v.d = absPath
314 }
315 }
316 }
317
318 if s := cliContext.String("address"); s != "" {
319 var (
320 grpcConfig map[string]any
321 ttrpcConfig map[string]any
322 )
323 v, ok := config.Plugins["io.containerd.server.v1.grpc"]
324 if !ok {
325 grpcConfig = make(map[string]any)
326 } else if grpcConfig, ok = v.(map[string]any); !ok {
327 return fmt.Errorf("grpc plugin has invalid configuration: %w", errdefs.ErrInvalidArgument)
328 }
329 grpcConfig["address"] = s
330 config.Plugins["io.containerd.server.v1.grpc"] = grpcConfig
331
332 _, ok = config.Plugins["io.containerd.server.v1.ttrpc"]
333 if !ok {
334 ttrpcConfig = map[string]any{
335 "address": s + ".ttrpc",
336 }
337 if uid, ok := grpcConfig["uid"]; ok {
338 ttrpcConfig["uid"] = uid
339 }
340 if gid, ok := grpcConfig["gid"]; ok {

Callers 1

AppFunction · 0.85

Calls 4

setLogLevelFunction · 0.85
setLogFormatFunction · 0.85
applyPlatformFlagsFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…