| 352 | } |
| 353 | |
| 354 | func (c *devConfig) validate() error { |
| 355 | if c.agpl && c.useProxy { |
| 356 | return xerrors.New("cannot use both --agpl and --use-proxy") |
| 357 | } |
| 358 | if c.agpl && c.multiOrg { |
| 359 | return xerrors.New("cannot use both --agpl and --multi-organization") |
| 360 | } |
| 361 | if c.dbRollback && c.dbReset { |
| 362 | return xerrors.New("cannot use both --db-rollback and --db-reset") |
| 363 | } |
| 364 | if c.dbContinue && c.dbReset { |
| 365 | return xerrors.New("cannot use both --db-continue and --db-reset") |
| 366 | } |
| 367 | for _, p := range []struct { |
| 368 | name string |
| 369 | val int64 |
| 370 | }{ |
| 371 | {"--port", c.apiPort}, |
| 372 | {"--web-port", c.webPort}, |
| 373 | {"--proxy-port", c.proxyPort}, |
| 374 | } { |
| 375 | if p.val < 1 || p.val > 65535 { |
| 376 | return xerrors.Errorf("%s must be between 1 and 65535", p.name) |
| 377 | } |
| 378 | } |
| 379 | if c.coderMetricsPort < 0 || c.coderMetricsPort > 65535 { |
| 380 | return xerrors.Errorf("--prometheus-port must be 0 (disabled) or between 1 and 65535") |
| 381 | } |
| 382 | if c.apiPort == c.webPort { |
| 383 | return xerrors.Errorf("--port %d conflicts with frontend dev server", c.webPort) |
| 384 | } |
| 385 | if c.useProxy && c.apiPort == c.proxyPort { |
| 386 | return xerrors.Errorf("--port %d conflicts with workspace proxy", c.proxyPort) |
| 387 | } |
| 388 | if c.useProxy && c.webPort == c.proxyPort { |
| 389 | return xerrors.Errorf("--web-port %d conflicts with --proxy-port", c.webPort) |
| 390 | } |
| 391 | if c.coderMetricsPort != 0 { |
| 392 | if c.coderMetricsPort == c.apiPort { |
| 393 | return xerrors.Errorf("--prometheus-port %d conflicts with API server", c.coderMetricsPort) |
| 394 | } |
| 395 | if c.coderMetricsPort == c.webPort { |
| 396 | return xerrors.Errorf("--prometheus-port %d conflicts with frontend dev server", c.coderMetricsPort) |
| 397 | } |
| 398 | if c.useProxy && c.coderMetricsPort == c.proxyPort { |
| 399 | return xerrors.Errorf("--prometheus-port %d conflicts with workspace proxy", c.coderMetricsPort) |
| 400 | } |
| 401 | } |
| 402 | if c.prometheusServer && c.coderMetricsPort == 0 { |
| 403 | return xerrors.New("--prometheus-server requires prometheus to be enabled (--prometheus-port != 0)") |
| 404 | } |
| 405 | if c.prometheusServer { |
| 406 | conflicts := []struct { |
| 407 | flag string |
| 408 | val int64 |
| 409 | }{ |
| 410 | {"--port", c.apiPort}, |
| 411 | {"--web-port", c.webPort}, |