(cliContext *cli.Context, config *srvconfig.Config)
| 281 | } |
| 282 | |
| 283 | func 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 { |
no test coverage detected
searching dependent graphs…