builder.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package errors
  2. // This file contains all of the errors that can be generated from the
  3. // docker/builder component.
  4. import (
  5. "net/http"
  6. "github.com/docker/distribution/registry/api/errcode"
  7. )
  8. var (
  9. // ErrorCodeAtLeastOneArg is generated when the parser comes across a
  10. // Dockerfile command that doesn't have any args.
  11. ErrorCodeAtLeastOneArg = errcode.Register(errGroup, errcode.ErrorDescriptor{
  12. Value: "ATLEASTONEARG",
  13. Message: "%s requires at least one argument",
  14. Description: "The specified command requires at least one argument",
  15. HTTPStatusCode: http.StatusInternalServerError,
  16. })
  17. // ErrorCodeExactlyOneArg is generated when the parser comes across a
  18. // Dockerfile command that requires exactly one arg but got less/more.
  19. ErrorCodeExactlyOneArg = errcode.Register(errGroup, errcode.ErrorDescriptor{
  20. Value: "EXACTLYONEARG",
  21. Message: "%s requires exactly one argument",
  22. Description: "The specified command requires exactly one argument",
  23. HTTPStatusCode: http.StatusInternalServerError,
  24. })
  25. // ErrorCodeAtLeastTwoArgs is generated when the parser comes across a
  26. // Dockerfile command that requires at least two args but got less.
  27. ErrorCodeAtLeastTwoArgs = errcode.Register(errGroup, errcode.ErrorDescriptor{
  28. Value: "ATLEASTTWOARGS",
  29. Message: "%s requires at least two arguments",
  30. Description: "The specified command requires at least two arguments",
  31. HTTPStatusCode: http.StatusInternalServerError,
  32. })
  33. // ErrorCodeTooManyArgs is generated when the parser comes across a
  34. // Dockerfile command that has more args than it should
  35. ErrorCodeTooManyArgs = errcode.Register(errGroup, errcode.ErrorDescriptor{
  36. Value: "TOOMANYARGS",
  37. Message: "Bad input to %s, too many args",
  38. Description: "The specified command was passed too many arguments",
  39. HTTPStatusCode: http.StatusInternalServerError,
  40. })
  41. // ErrorCodeChainOnBuild is generated when the parser comes across a
  42. // Dockerfile command that is trying to chain ONBUILD commands.
  43. ErrorCodeChainOnBuild = errcode.Register(errGroup, errcode.ErrorDescriptor{
  44. Value: "CHAINONBUILD",
  45. Message: "Chaining ONBUILD via `ONBUILD ONBUILD` isn't allowed",
  46. Description: "ONBUILD Dockerfile commands aren't allow on ONBUILD commands",
  47. HTTPStatusCode: http.StatusInternalServerError,
  48. })
  49. // ErrorCodeBadOnBuildCmd is generated when the parser comes across a
  50. // an ONBUILD Dockerfile command with an invalid trigger/command.
  51. ErrorCodeBadOnBuildCmd = errcode.Register(errGroup, errcode.ErrorDescriptor{
  52. Value: "BADONBUILDCMD",
  53. Message: "%s isn't allowed as an ONBUILD trigger",
  54. Description: "The specified ONBUILD command isn't allowed",
  55. HTTPStatusCode: http.StatusInternalServerError,
  56. })
  57. // ErrorCodeMissingFrom is generated when the Dockerfile is missing
  58. // a FROM command.
  59. ErrorCodeMissingFrom = errcode.Register(errGroup, errcode.ErrorDescriptor{
  60. Value: "MISSINGFROM",
  61. Message: "Please provide a source image with `from` prior to run",
  62. Description: "The Dockerfile is missing a FROM command",
  63. HTTPStatusCode: http.StatusInternalServerError,
  64. })
  65. // ErrorCodeNotOnWindows is generated when the specified Dockerfile
  66. // command is not supported on Windows.
  67. ErrorCodeNotOnWindows = errcode.Register(errGroup, errcode.ErrorDescriptor{
  68. Value: "NOTONWINDOWS",
  69. Message: "%s is not supported on Windows",
  70. Description: "The specified Dockerfile command is not supported on Windows",
  71. HTTPStatusCode: http.StatusInternalServerError,
  72. })
  73. // ErrorCodeVolumeEmpty is generated when the specified Volume string
  74. // is empty.
  75. ErrorCodeVolumeEmpty = errcode.Register(errGroup, errcode.ErrorDescriptor{
  76. Value: "VOLUMEEMPTY",
  77. Message: "Volume specified can not be an empty string",
  78. Description: "The specified volume can not be an empty string",
  79. HTTPStatusCode: http.StatusInternalServerError,
  80. })
  81. )