(path string, devContainer *latest.DevContainer, devPod *latest.DevPod, nameRequired bool)
| 403 | } |
| 404 | |
| 405 | func validateDevContainer(path string, devContainer *latest.DevContainer, devPod *latest.DevPod, nameRequired bool) error { |
| 406 | if nameRequired && devContainer.Container == "" { |
| 407 | return errors.Errorf("%s.container is required", path) |
| 408 | } |
| 409 | |
| 410 | if !ValidContainerArch(devContainer.Arch) { |
| 411 | return errors.Errorf("%s.arch is not valid '%s'", path, devContainer.Arch) |
| 412 | } |
| 413 | |
| 414 | // check if there are values from devContainers that are overwriting values from devPod |
| 415 | err := validatePodContainerDuplicates(path, devContainer, devPod) |
| 416 | if err != nil { |
| 417 | return err |
| 418 | } |
| 419 | |
| 420 | for index, sync := range devContainer.Sync { |
| 421 | // Validate initial sync strategy |
| 422 | if !ValidInitialSyncStrategy(sync.InitialSync) { |
| 423 | return errors.Errorf("%s.sync[%d].initialSync is not valid '%s'", path, index, sync.InitialSync) |
| 424 | } |
| 425 | if sync.OnUpload != nil { |
| 426 | for j, e := range sync.OnUpload.Exec { |
| 427 | if e.Command == "" { |
| 428 | return errors.Errorf("%s.sync[%d].exec[%d].command is required", path, index, j) |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | for j, p := range sync.ExcludePaths { |
| 433 | if p == "" { |
| 434 | return errors.Errorf("%s.sync[%d].excludePaths[%d] is empty. This can happen if you use !path without quotes like this: '!path'", path, index, j) |
| 435 | } |
| 436 | } |
| 437 | for j, p := range sync.UploadExcludePaths { |
| 438 | if p == "" { |
| 439 | return errors.Errorf("%s.sync[%d].uploadExcludePaths[%d] is empty. This can happen if you use !path without quotes like this: '!path'", path, index, j) |
| 440 | } |
| 441 | } |
| 442 | for j, p := range sync.DownloadExcludePaths { |
| 443 | if p == "" { |
| 444 | return errors.Errorf("%s.sync[%d].downloadExcludePaths[%d] is empty. This can happen if you use !path without quotes like this: '!path'", path, index, j) |
| 445 | } |
| 446 | } |
| 447 | } |
| 448 | for index, port := range devContainer.ReversePorts { |
| 449 | if port.Port == "" { |
| 450 | return errors.Errorf("%s.reversePorts[%d].port is required", path, index) |
| 451 | } |
| 452 | } |
| 453 | for j, p := range devContainer.PersistPaths { |
| 454 | if p.Path == "" { |
| 455 | return errors.Errorf("%s.persistPaths[%d].path is required", path, j) |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | return nil |
| 460 | } |
| 461 | |
| 462 | func validatePodContainerDuplicates(path string, devContainer *latest.DevContainer, devPod *latest.DevPod) error { |
no test coverage detected