PageRenderTime 142ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/src/github.com/docker/distribution/registry/api/v2/descriptors.go

https://gitlab.com/liwh/docker
Go | 1505 lines | 1375 code | 61 blank | 69 comment | 1 complexity | 69a26925a32ad4a5364dda1d898539c8 MD5 | raw file
  1. package v2
  2. import (
  3. "net/http"
  4. "regexp"
  5. "github.com/docker/distribution/digest"
  6. "github.com/docker/distribution/reference"
  7. "github.com/docker/distribution/registry/api/errcode"
  8. )
  9. var (
  10. nameParameterDescriptor = ParameterDescriptor{
  11. Name: "name",
  12. Type: "string",
  13. Format: reference.NameRegexp.String(),
  14. Required: true,
  15. Description: `Name of the target repository.`,
  16. }
  17. referenceParameterDescriptor = ParameterDescriptor{
  18. Name: "reference",
  19. Type: "string",
  20. Format: reference.TagRegexp.String(),
  21. Required: true,
  22. Description: `Tag or digest of the target manifest.`,
  23. }
  24. uuidParameterDescriptor = ParameterDescriptor{
  25. Name: "uuid",
  26. Type: "opaque",
  27. Required: true,
  28. Description: "A uuid identifying the upload. This field can accept characters that match `[a-zA-Z0-9-_.=]+`.",
  29. }
  30. digestPathParameter = ParameterDescriptor{
  31. Name: "digest",
  32. Type: "path",
  33. Required: true,
  34. Format: digest.DigestRegexp.String(),
  35. Description: `Digest of desired blob.`,
  36. }
  37. hostHeader = ParameterDescriptor{
  38. Name: "Host",
  39. Type: "string",
  40. Description: "Standard HTTP Host Header. Should be set to the registry host.",
  41. Format: "<registry host>",
  42. Examples: []string{"registry-1.docker.io"},
  43. }
  44. authHeader = ParameterDescriptor{
  45. Name: "Authorization",
  46. Type: "string",
  47. Description: "An RFC7235 compliant authorization header.",
  48. Format: "<scheme> <token>",
  49. Examples: []string{"Bearer dGhpcyBpcyBhIGZha2UgYmVhcmVyIHRva2VuIQ=="},
  50. }
  51. authChallengeHeader = ParameterDescriptor{
  52. Name: "WWW-Authenticate",
  53. Type: "string",
  54. Description: "An RFC7235 compliant authentication challenge header.",
  55. Format: `<scheme> realm="<realm>", ..."`,
  56. Examples: []string{
  57. `Bearer realm="https://auth.docker.com/", service="registry.docker.com", scopes="repository:library/ubuntu:pull"`,
  58. },
  59. }
  60. contentLengthZeroHeader = ParameterDescriptor{
  61. Name: "Content-Length",
  62. Description: "The `Content-Length` header must be zero and the body must be empty.",
  63. Type: "integer",
  64. Format: "0",
  65. }
  66. dockerUploadUUIDHeader = ParameterDescriptor{
  67. Name: "Docker-Upload-UUID",
  68. Description: "Identifies the docker upload uuid for the current request.",
  69. Type: "uuid",
  70. Format: "<uuid>",
  71. }
  72. digestHeader = ParameterDescriptor{
  73. Name: "Docker-Content-Digest",
  74. Description: "Digest of the targeted content for the request.",
  75. Type: "digest",
  76. Format: "<digest>",
  77. }
  78. linkHeader = ParameterDescriptor{
  79. Name: "Link",
  80. Type: "link",
  81. Description: "RFC5988 compliant rel='next' with URL to next result set, if available",
  82. Format: `<<url>?n=<last n value>&last=<last entry from response>>; rel="next"`,
  83. }
  84. paginationParameters = []ParameterDescriptor{
  85. {
  86. Name: "n",
  87. Type: "integer",
  88. Description: "Limit the number of entries in each response. It not present, all entries will be returned.",
  89. Format: "<integer>",
  90. Required: false,
  91. },
  92. {
  93. Name: "last",
  94. Type: "string",
  95. Description: "Result set will include values lexically after last.",
  96. Format: "<integer>",
  97. Required: false,
  98. },
  99. }
  100. unauthorizedResponseDescriptor = ResponseDescriptor{
  101. Name: "Authentication Required",
  102. StatusCode: http.StatusUnauthorized,
  103. Description: "The client is not authenticated.",
  104. Headers: []ParameterDescriptor{
  105. authChallengeHeader,
  106. {
  107. Name: "Content-Length",
  108. Type: "integer",
  109. Description: "Length of the JSON response body.",
  110. Format: "<length>",
  111. },
  112. },
  113. Body: BodyDescriptor{
  114. ContentType: "application/json; charset=utf-8",
  115. Format: errorsBody,
  116. },
  117. ErrorCodes: []errcode.ErrorCode{
  118. errcode.ErrorCodeUnauthorized,
  119. },
  120. }
  121. repositoryNotFoundResponseDescriptor = ResponseDescriptor{
  122. Name: "No Such Repository Error",
  123. StatusCode: http.StatusNotFound,
  124. Description: "The repository is not known to the registry.",
  125. Headers: []ParameterDescriptor{
  126. {
  127. Name: "Content-Length",
  128. Type: "integer",
  129. Description: "Length of the JSON response body.",
  130. Format: "<length>",
  131. },
  132. },
  133. Body: BodyDescriptor{
  134. ContentType: "application/json; charset=utf-8",
  135. Format: errorsBody,
  136. },
  137. ErrorCodes: []errcode.ErrorCode{
  138. ErrorCodeNameUnknown,
  139. },
  140. }
  141. deniedResponseDescriptor = ResponseDescriptor{
  142. Name: "Access Denied",
  143. StatusCode: http.StatusForbidden,
  144. Description: "The client does not have required access to the repository.",
  145. Headers: []ParameterDescriptor{
  146. {
  147. Name: "Content-Length",
  148. Type: "integer",
  149. Description: "Length of the JSON response body.",
  150. Format: "<length>",
  151. },
  152. },
  153. Body: BodyDescriptor{
  154. ContentType: "application/json; charset=utf-8",
  155. Format: errorsBody,
  156. },
  157. ErrorCodes: []errcode.ErrorCode{
  158. errcode.ErrorCodeDenied,
  159. },
  160. }
  161. )
  162. const (
  163. manifestBody = `{
  164. "name": <name>,
  165. "tag": <tag>,
  166. "fsLayers": [
  167. {
  168. "blobSum": "<digest>"
  169. },
  170. ...
  171. ]
  172. ],
  173. "history": <v1 images>,
  174. "signature": <JWS>
  175. }`
  176. errorsBody = `{
  177. "errors:" [
  178. {
  179. "code": <error code>,
  180. "message": "<error message>",
  181. "detail": ...
  182. },
  183. ...
  184. ]
  185. }`
  186. unauthorizedErrorsBody = `{
  187. "errors:" [
  188. {
  189. "code": "UNAUTHORIZED",
  190. "message": "access to the requested resource is not authorized",
  191. "detail": ...
  192. },
  193. ...
  194. ]
  195. }`
  196. )
  197. // APIDescriptor exports descriptions of the layout of the v2 registry API.
  198. var APIDescriptor = struct {
  199. // RouteDescriptors provides a list of the routes available in the API.
  200. RouteDescriptors []RouteDescriptor
  201. }{
  202. RouteDescriptors: routeDescriptors,
  203. }
  204. // RouteDescriptor describes a route specified by name.
  205. type RouteDescriptor struct {
  206. // Name is the name of the route, as specified in RouteNameXXX exports.
  207. // These names a should be considered a unique reference for a route. If
  208. // the route is registered with gorilla, this is the name that will be
  209. // used.
  210. Name string
  211. // Path is a gorilla/mux-compatible regexp that can be used to match the
  212. // route. For any incoming method and path, only one route descriptor
  213. // should match.
  214. Path string
  215. // Entity should be a short, human-readalbe description of the object
  216. // targeted by the endpoint.
  217. Entity string
  218. // Description should provide an accurate overview of the functionality
  219. // provided by the route.
  220. Description string
  221. // Methods should describe the various HTTP methods that may be used on
  222. // this route, including request and response formats.
  223. Methods []MethodDescriptor
  224. }
  225. // MethodDescriptor provides a description of the requests that may be
  226. // conducted with the target method.
  227. type MethodDescriptor struct {
  228. // Method is an HTTP method, such as GET, PUT or POST.
  229. Method string
  230. // Description should provide an overview of the functionality provided by
  231. // the covered method, suitable for use in documentation. Use of markdown
  232. // here is encouraged.
  233. Description string
  234. // Requests is a slice of request descriptors enumerating how this
  235. // endpoint may be used.
  236. Requests []RequestDescriptor
  237. }
  238. // RequestDescriptor covers a particular set of headers and parameters that
  239. // can be carried out with the parent method. Its most helpful to have one
  240. // RequestDescriptor per API use case.
  241. type RequestDescriptor struct {
  242. // Name provides a short identifier for the request, usable as a title or
  243. // to provide quick context for the particalar request.
  244. Name string
  245. // Description should cover the requests purpose, covering any details for
  246. // this particular use case.
  247. Description string
  248. // Headers describes headers that must be used with the HTTP request.
  249. Headers []ParameterDescriptor
  250. // PathParameters enumerate the parameterized path components for the
  251. // given request, as defined in the route's regular expression.
  252. PathParameters []ParameterDescriptor
  253. // QueryParameters provides a list of query parameters for the given
  254. // request.
  255. QueryParameters []ParameterDescriptor
  256. // Body describes the format of the request body.
  257. Body BodyDescriptor
  258. // Successes enumerates the possible responses that are considered to be
  259. // the result of a successful request.
  260. Successes []ResponseDescriptor
  261. // Failures covers the possible failures from this particular request.
  262. Failures []ResponseDescriptor
  263. }
  264. // ResponseDescriptor describes the components of an API response.
  265. type ResponseDescriptor struct {
  266. // Name provides a short identifier for the response, usable as a title or
  267. // to provide quick context for the particalar response.
  268. Name string
  269. // Description should provide a brief overview of the role of the
  270. // response.
  271. Description string
  272. // StatusCode specifies the status recieved by this particular response.
  273. StatusCode int
  274. // Headers covers any headers that may be returned from the response.
  275. Headers []ParameterDescriptor
  276. // Fields describes any fields that may be present in the response.
  277. Fields []ParameterDescriptor
  278. // ErrorCodes enumerates the error codes that may be returned along with
  279. // the response.
  280. ErrorCodes []errcode.ErrorCode
  281. // Body describes the body of the response, if any.
  282. Body BodyDescriptor
  283. }
  284. // BodyDescriptor describes a request body and its expected content type. For
  285. // the most part, it should be example json or some placeholder for body
  286. // data in documentation.
  287. type BodyDescriptor struct {
  288. ContentType string
  289. Format string
  290. }
  291. // ParameterDescriptor describes the format of a request parameter, which may
  292. // be a header, path parameter or query parameter.
  293. type ParameterDescriptor struct {
  294. // Name is the name of the parameter, either of the path component or
  295. // query parameter.
  296. Name string
  297. // Type specifies the type of the parameter, such as string, integer, etc.
  298. Type string
  299. // Description provides a human-readable description of the parameter.
  300. Description string
  301. // Required means the field is required when set.
  302. Required bool
  303. // Format is a specifying the string format accepted by this parameter.
  304. Format string
  305. // Regexp is a compiled regular expression that can be used to validate
  306. // the contents of the parameter.
  307. Regexp *regexp.Regexp
  308. // Examples provides multiple examples for the values that might be valid
  309. // for this parameter.
  310. Examples []string
  311. }
  312. var routeDescriptors = []RouteDescriptor{
  313. {
  314. Name: RouteNameBase,
  315. Path: "/v2/",
  316. Entity: "Base",
  317. Description: `Base V2 API route. Typically, this can be used for lightweight version checks and to validate registry authentication.`,
  318. Methods: []MethodDescriptor{
  319. {
  320. Method: "GET",
  321. Description: "Check that the endpoint implements Docker Registry API V2.",
  322. Requests: []RequestDescriptor{
  323. {
  324. Headers: []ParameterDescriptor{
  325. hostHeader,
  326. authHeader,
  327. },
  328. Successes: []ResponseDescriptor{
  329. {
  330. Description: "The API implements V2 protocol and is accessible.",
  331. StatusCode: http.StatusOK,
  332. },
  333. },
  334. Failures: []ResponseDescriptor{
  335. {
  336. Description: "The registry does not implement the V2 API.",
  337. StatusCode: http.StatusNotFound,
  338. },
  339. unauthorizedResponseDescriptor,
  340. },
  341. },
  342. },
  343. },
  344. },
  345. },
  346. {
  347. Name: RouteNameTags,
  348. Path: "/v2/{name:" + reference.NameRegexp.String() + "}/tags/list",
  349. Entity: "Tags",
  350. Description: "Retrieve information about tags.",
  351. Methods: []MethodDescriptor{
  352. {
  353. Method: "GET",
  354. Description: "Fetch the tags under the repository identified by `name`.",
  355. Requests: []RequestDescriptor{
  356. {
  357. Name: "Tags",
  358. Description: "Return all tags for the repository",
  359. Headers: []ParameterDescriptor{
  360. hostHeader,
  361. authHeader,
  362. },
  363. PathParameters: []ParameterDescriptor{
  364. nameParameterDescriptor,
  365. },
  366. Successes: []ResponseDescriptor{
  367. {
  368. StatusCode: http.StatusOK,
  369. Description: "A list of tags for the named repository.",
  370. Headers: []ParameterDescriptor{
  371. {
  372. Name: "Content-Length",
  373. Type: "integer",
  374. Description: "Length of the JSON response body.",
  375. Format: "<length>",
  376. },
  377. },
  378. Body: BodyDescriptor{
  379. ContentType: "application/json; charset=utf-8",
  380. Format: `{
  381. "name": <name>,
  382. "tags": [
  383. <tag>,
  384. ...
  385. ]
  386. }`,
  387. },
  388. },
  389. },
  390. Failures: []ResponseDescriptor{
  391. unauthorizedResponseDescriptor,
  392. repositoryNotFoundResponseDescriptor,
  393. deniedResponseDescriptor,
  394. },
  395. },
  396. {
  397. Name: "Tags Paginated",
  398. Description: "Return a portion of the tags for the specified repository.",
  399. PathParameters: []ParameterDescriptor{nameParameterDescriptor},
  400. QueryParameters: paginationParameters,
  401. Successes: []ResponseDescriptor{
  402. {
  403. StatusCode: http.StatusOK,
  404. Description: "A list of tags for the named repository.",
  405. Headers: []ParameterDescriptor{
  406. {
  407. Name: "Content-Length",
  408. Type: "integer",
  409. Description: "Length of the JSON response body.",
  410. Format: "<length>",
  411. },
  412. linkHeader,
  413. },
  414. Body: BodyDescriptor{
  415. ContentType: "application/json; charset=utf-8",
  416. Format: `{
  417. "name": <name>,
  418. "tags": [
  419. <tag>,
  420. ...
  421. ],
  422. }`,
  423. },
  424. },
  425. },
  426. Failures: []ResponseDescriptor{
  427. unauthorizedResponseDescriptor,
  428. repositoryNotFoundResponseDescriptor,
  429. deniedResponseDescriptor,
  430. },
  431. },
  432. },
  433. },
  434. },
  435. },
  436. {
  437. Name: RouteNameManifest,
  438. Path: "/v2/{name:" + reference.NameRegexp.String() + "}/manifests/{reference:" + reference.TagRegexp.String() + "|" + digest.DigestRegexp.String() + "}",
  439. Entity: "Manifest",
  440. Description: "Create, update, delete and retrieve manifests.",
  441. Methods: []MethodDescriptor{
  442. {
  443. Method: "GET",
  444. Description: "Fetch the manifest identified by `name` and `reference` where `reference` can be a tag or digest.",
  445. Requests: []RequestDescriptor{
  446. {
  447. Headers: []ParameterDescriptor{
  448. hostHeader,
  449. authHeader,
  450. },
  451. PathParameters: []ParameterDescriptor{
  452. nameParameterDescriptor,
  453. referenceParameterDescriptor,
  454. },
  455. Successes: []ResponseDescriptor{
  456. {
  457. Description: "The manifest identified by `name` and `reference`. The contents can be used to identify and resolve resources required to run the specified image.",
  458. StatusCode: http.StatusOK,
  459. Headers: []ParameterDescriptor{
  460. digestHeader,
  461. },
  462. Body: BodyDescriptor{
  463. ContentType: "application/json; charset=utf-8",
  464. Format: manifestBody,
  465. },
  466. },
  467. },
  468. Failures: []ResponseDescriptor{
  469. {
  470. Description: "The name or reference was invalid.",
  471. StatusCode: http.StatusBadRequest,
  472. ErrorCodes: []errcode.ErrorCode{
  473. ErrorCodeNameInvalid,
  474. ErrorCodeTagInvalid,
  475. },
  476. Body: BodyDescriptor{
  477. ContentType: "application/json; charset=utf-8",
  478. Format: errorsBody,
  479. },
  480. },
  481. unauthorizedResponseDescriptor,
  482. repositoryNotFoundResponseDescriptor,
  483. deniedResponseDescriptor,
  484. },
  485. },
  486. },
  487. },
  488. {
  489. Method: "PUT",
  490. Description: "Put the manifest identified by `name` and `reference` where `reference` can be a tag or digest.",
  491. Requests: []RequestDescriptor{
  492. {
  493. Headers: []ParameterDescriptor{
  494. hostHeader,
  495. authHeader,
  496. },
  497. PathParameters: []ParameterDescriptor{
  498. nameParameterDescriptor,
  499. referenceParameterDescriptor,
  500. },
  501. Body: BodyDescriptor{
  502. ContentType: "application/json; charset=utf-8",
  503. Format: manifestBody,
  504. },
  505. Successes: []ResponseDescriptor{
  506. {
  507. Description: "The manifest has been accepted by the registry and is stored under the specified `name` and `tag`.",
  508. StatusCode: http.StatusCreated,
  509. Headers: []ParameterDescriptor{
  510. {
  511. Name: "Location",
  512. Type: "url",
  513. Description: "The canonical location url of the uploaded manifest.",
  514. Format: "<url>",
  515. },
  516. contentLengthZeroHeader,
  517. digestHeader,
  518. },
  519. },
  520. },
  521. Failures: []ResponseDescriptor{
  522. {
  523. Name: "Invalid Manifest",
  524. Description: "The received manifest was invalid in some way, as described by the error codes. The client should resolve the issue and retry the request.",
  525. StatusCode: http.StatusBadRequest,
  526. Body: BodyDescriptor{
  527. ContentType: "application/json; charset=utf-8",
  528. Format: errorsBody,
  529. },
  530. ErrorCodes: []errcode.ErrorCode{
  531. ErrorCodeNameInvalid,
  532. ErrorCodeTagInvalid,
  533. ErrorCodeManifestInvalid,
  534. ErrorCodeManifestUnverified,
  535. ErrorCodeBlobUnknown,
  536. },
  537. },
  538. unauthorizedResponseDescriptor,
  539. repositoryNotFoundResponseDescriptor,
  540. deniedResponseDescriptor,
  541. {
  542. Name: "Missing Layer(s)",
  543. Description: "One or more layers may be missing during a manifest upload. If so, the missing layers will be enumerated in the error response.",
  544. StatusCode: http.StatusBadRequest,
  545. ErrorCodes: []errcode.ErrorCode{
  546. ErrorCodeBlobUnknown,
  547. },
  548. Body: BodyDescriptor{
  549. ContentType: "application/json; charset=utf-8",
  550. Format: `{
  551. "errors:" [{
  552. "code": "BLOB_UNKNOWN",
  553. "message": "blob unknown to registry",
  554. "detail": {
  555. "digest": "<digest>"
  556. }
  557. },
  558. ...
  559. ]
  560. }`,
  561. },
  562. },
  563. {
  564. Name: "Not allowed",
  565. Description: "Manifest put is not allowed because the registry is configured as a pull-through cache or for some other reason",
  566. StatusCode: http.StatusMethodNotAllowed,
  567. ErrorCodes: []errcode.ErrorCode{
  568. errcode.ErrorCodeUnsupported,
  569. },
  570. },
  571. },
  572. },
  573. },
  574. },
  575. {
  576. Method: "DELETE",
  577. Description: "Delete the manifest identified by `name` and `reference`. Note that a manifest can _only_ be deleted by `digest`.",
  578. Requests: []RequestDescriptor{
  579. {
  580. Headers: []ParameterDescriptor{
  581. hostHeader,
  582. authHeader,
  583. },
  584. PathParameters: []ParameterDescriptor{
  585. nameParameterDescriptor,
  586. referenceParameterDescriptor,
  587. },
  588. Successes: []ResponseDescriptor{
  589. {
  590. StatusCode: http.StatusAccepted,
  591. },
  592. },
  593. Failures: []ResponseDescriptor{
  594. {
  595. Name: "Invalid Name or Reference",
  596. Description: "The specified `name` or `reference` were invalid and the delete was unable to proceed.",
  597. StatusCode: http.StatusBadRequest,
  598. ErrorCodes: []errcode.ErrorCode{
  599. ErrorCodeNameInvalid,
  600. ErrorCodeTagInvalid,
  601. },
  602. Body: BodyDescriptor{
  603. ContentType: "application/json; charset=utf-8",
  604. Format: errorsBody,
  605. },
  606. },
  607. unauthorizedResponseDescriptor,
  608. repositoryNotFoundResponseDescriptor,
  609. deniedResponseDescriptor,
  610. {
  611. Name: "Unknown Manifest",
  612. Description: "The specified `name` or `reference` are unknown to the registry and the delete was unable to proceed. Clients can assume the manifest was already deleted if this response is returned.",
  613. StatusCode: http.StatusNotFound,
  614. ErrorCodes: []errcode.ErrorCode{
  615. ErrorCodeNameUnknown,
  616. ErrorCodeManifestUnknown,
  617. },
  618. Body: BodyDescriptor{
  619. ContentType: "application/json; charset=utf-8",
  620. Format: errorsBody,
  621. },
  622. },
  623. {
  624. Name: "Not allowed",
  625. Description: "Manifest delete is not allowed because the registry is configured as a pull-through cache or `delete` has been disabled.",
  626. StatusCode: http.StatusMethodNotAllowed,
  627. ErrorCodes: []errcode.ErrorCode{
  628. errcode.ErrorCodeUnsupported,
  629. },
  630. },
  631. },
  632. },
  633. },
  634. },
  635. },
  636. },
  637. {
  638. Name: RouteNameBlob,
  639. Path: "/v2/{name:" + reference.NameRegexp.String() + "}/blobs/{digest:" + digest.DigestRegexp.String() + "}",
  640. Entity: "Blob",
  641. Description: "Operations on blobs identified by `name` and `digest`. Used to fetch or delete layers by digest.",
  642. Methods: []MethodDescriptor{
  643. {
  644. Method: "GET",
  645. Description: "Retrieve the blob from the registry identified by `digest`. A `HEAD` request can also be issued to this endpoint to obtain resource information without receiving all data.",
  646. Requests: []RequestDescriptor{
  647. {
  648. Name: "Fetch Blob",
  649. Headers: []ParameterDescriptor{
  650. hostHeader,
  651. authHeader,
  652. },
  653. PathParameters: []ParameterDescriptor{
  654. nameParameterDescriptor,
  655. digestPathParameter,
  656. },
  657. Successes: []ResponseDescriptor{
  658. {
  659. Description: "The blob identified by `digest` is available. The blob content will be present in the body of the request.",
  660. StatusCode: http.StatusOK,
  661. Headers: []ParameterDescriptor{
  662. {
  663. Name: "Content-Length",
  664. Type: "integer",
  665. Description: "The length of the requested blob content.",
  666. Format: "<length>",
  667. },
  668. digestHeader,
  669. },
  670. Body: BodyDescriptor{
  671. ContentType: "application/octet-stream",
  672. Format: "<blob binary data>",
  673. },
  674. },
  675. {
  676. Description: "The blob identified by `digest` is available at the provided location.",
  677. StatusCode: http.StatusTemporaryRedirect,
  678. Headers: []ParameterDescriptor{
  679. {
  680. Name: "Location",
  681. Type: "url",
  682. Description: "The location where the layer should be accessible.",
  683. Format: "<blob location>",
  684. },
  685. digestHeader,
  686. },
  687. },
  688. },
  689. Failures: []ResponseDescriptor{
  690. {
  691. Description: "There was a problem with the request that needs to be addressed by the client, such as an invalid `name` or `tag`.",
  692. StatusCode: http.StatusBadRequest,
  693. ErrorCodes: []errcode.ErrorCode{
  694. ErrorCodeNameInvalid,
  695. ErrorCodeDigestInvalid,
  696. },
  697. Body: BodyDescriptor{
  698. ContentType: "application/json; charset=utf-8",
  699. Format: errorsBody,
  700. },
  701. },
  702. {
  703. Description: "The blob, identified by `name` and `digest`, is unknown to the registry.",
  704. StatusCode: http.StatusNotFound,
  705. Body: BodyDescriptor{
  706. ContentType: "application/json; charset=utf-8",
  707. Format: errorsBody,
  708. },
  709. ErrorCodes: []errcode.ErrorCode{
  710. ErrorCodeNameUnknown,
  711. ErrorCodeBlobUnknown,
  712. },
  713. },
  714. unauthorizedResponseDescriptor,
  715. repositoryNotFoundResponseDescriptor,
  716. deniedResponseDescriptor,
  717. },
  718. },
  719. {
  720. Name: "Fetch Blob Part",
  721. Description: "This endpoint may also support RFC7233 compliant range requests. Support can be detected by issuing a HEAD request. If the header `Accept-Range: bytes` is returned, range requests can be used to fetch partial content.",
  722. Headers: []ParameterDescriptor{
  723. hostHeader,
  724. authHeader,
  725. {
  726. Name: "Range",
  727. Type: "string",
  728. Description: "HTTP Range header specifying blob chunk.",
  729. Format: "bytes=<start>-<end>",
  730. },
  731. },
  732. PathParameters: []ParameterDescriptor{
  733. nameParameterDescriptor,
  734. digestPathParameter,
  735. },
  736. Successes: []ResponseDescriptor{
  737. {
  738. Description: "The blob identified by `digest` is available. The specified chunk of blob content will be present in the body of the request.",
  739. StatusCode: http.StatusPartialContent,
  740. Headers: []ParameterDescriptor{
  741. {
  742. Name: "Content-Length",
  743. Type: "integer",
  744. Description: "The length of the requested blob chunk.",
  745. Format: "<length>",
  746. },
  747. {
  748. Name: "Content-Range",
  749. Type: "byte range",
  750. Description: "Content range of blob chunk.",
  751. Format: "bytes <start>-<end>/<size>",
  752. },
  753. },
  754. Body: BodyDescriptor{
  755. ContentType: "application/octet-stream",
  756. Format: "<blob binary data>",
  757. },
  758. },
  759. },
  760. Failures: []ResponseDescriptor{
  761. {
  762. Description: "There was a problem with the request that needs to be addressed by the client, such as an invalid `name` or `tag`.",
  763. StatusCode: http.StatusBadRequest,
  764. ErrorCodes: []errcode.ErrorCode{
  765. ErrorCodeNameInvalid,
  766. ErrorCodeDigestInvalid,
  767. },
  768. Body: BodyDescriptor{
  769. ContentType: "application/json; charset=utf-8",
  770. Format: errorsBody,
  771. },
  772. },
  773. {
  774. StatusCode: http.StatusNotFound,
  775. ErrorCodes: []errcode.ErrorCode{
  776. ErrorCodeNameUnknown,
  777. ErrorCodeBlobUnknown,
  778. },
  779. Body: BodyDescriptor{
  780. ContentType: "application/json; charset=utf-8",
  781. Format: errorsBody,
  782. },
  783. },
  784. {
  785. Description: "The range specification cannot be satisfied for the requested content. This can happen when the range is not formatted correctly or if the range is outside of the valid size of the content.",
  786. StatusCode: http.StatusRequestedRangeNotSatisfiable,
  787. },
  788. unauthorizedResponseDescriptor,
  789. repositoryNotFoundResponseDescriptor,
  790. deniedResponseDescriptor,
  791. },
  792. },
  793. },
  794. },
  795. {
  796. Method: "DELETE",
  797. Description: "Delete the blob identified by `name` and `digest`",
  798. Requests: []RequestDescriptor{
  799. {
  800. Headers: []ParameterDescriptor{
  801. hostHeader,
  802. authHeader,
  803. },
  804. PathParameters: []ParameterDescriptor{
  805. nameParameterDescriptor,
  806. digestPathParameter,
  807. },
  808. Successes: []ResponseDescriptor{
  809. {
  810. StatusCode: http.StatusAccepted,
  811. Headers: []ParameterDescriptor{
  812. {
  813. Name: "Content-Length",
  814. Type: "integer",
  815. Description: "0",
  816. Format: "0",
  817. },
  818. digestHeader,
  819. },
  820. },
  821. },
  822. Failures: []ResponseDescriptor{
  823. {
  824. Name: "Invalid Name or Digest",
  825. StatusCode: http.StatusBadRequest,
  826. ErrorCodes: []errcode.ErrorCode{
  827. ErrorCodeDigestInvalid,
  828. ErrorCodeNameInvalid,
  829. },
  830. },
  831. {
  832. Description: "The blob, identified by `name` and `digest`, is unknown to the registry.",
  833. StatusCode: http.StatusNotFound,
  834. Body: BodyDescriptor{
  835. ContentType: "application/json; charset=utf-8",
  836. Format: errorsBody,
  837. },
  838. ErrorCodes: []errcode.ErrorCode{
  839. ErrorCodeNameUnknown,
  840. ErrorCodeBlobUnknown,
  841. },
  842. },
  843. {
  844. Description: "Blob delete is not allowed because the registry is configured as a pull-through cache or `delete` has been disabled",
  845. StatusCode: http.StatusMethodNotAllowed,
  846. Body: BodyDescriptor{
  847. ContentType: "application/json; charset=utf-8",
  848. Format: errorsBody,
  849. },
  850. ErrorCodes: []errcode.ErrorCode{
  851. errcode.ErrorCodeUnsupported,
  852. },
  853. },
  854. unauthorizedResponseDescriptor,
  855. repositoryNotFoundResponseDescriptor,
  856. deniedResponseDescriptor,
  857. },
  858. },
  859. },
  860. },
  861. // TODO(stevvooe): We may want to add a PUT request here to
  862. // kickoff an upload of a blob, integrated with the blob upload
  863. // API.
  864. },
  865. },
  866. {
  867. Name: RouteNameBlobUpload,
  868. Path: "/v2/{name:" + reference.NameRegexp.String() + "}/blobs/uploads/",
  869. Entity: "Initiate Blob Upload",
  870. Description: "Initiate a blob upload. This endpoint can be used to create resumable uploads or monolithic uploads.",
  871. Methods: []MethodDescriptor{
  872. {
  873. Method: "POST",
  874. Description: "Initiate a resumable blob upload. If successful, an upload location will be provided to complete the upload. Optionally, if the `digest` parameter is present, the request body will be used to complete the upload in a single request.",
  875. Requests: []RequestDescriptor{
  876. {
  877. Name: "Initiate Monolithic Blob Upload",
  878. Description: "Upload a blob identified by the `digest` parameter in single request. This upload will not be resumable unless a recoverable error is returned.",
  879. Headers: []ParameterDescriptor{
  880. hostHeader,
  881. authHeader,
  882. {
  883. Name: "Content-Length",
  884. Type: "integer",
  885. Format: "<length of blob>",
  886. },
  887. },
  888. PathParameters: []ParameterDescriptor{
  889. nameParameterDescriptor,
  890. },
  891. QueryParameters: []ParameterDescriptor{
  892. {
  893. Name: "digest",
  894. Type: "query",
  895. Format: "<digest>",
  896. Regexp: digest.DigestRegexp,
  897. Description: `Digest of uploaded blob. If present, the upload will be completed, in a single request, with contents of the request body as the resulting blob.`,
  898. },
  899. },
  900. Body: BodyDescriptor{
  901. ContentType: "application/octect-stream",
  902. Format: "<binary data>",
  903. },
  904. Successes: []ResponseDescriptor{
  905. {
  906. Description: "The blob has been created in the registry and is available at the provided location.",
  907. StatusCode: http.StatusCreated,
  908. Headers: []ParameterDescriptor{
  909. {
  910. Name: "Location",
  911. Type: "url",
  912. Format: "<blob location>",
  913. },
  914. contentLengthZeroHeader,
  915. dockerUploadUUIDHeader,
  916. },
  917. },
  918. },
  919. Failures: []ResponseDescriptor{
  920. {
  921. Name: "Invalid Name or Digest",
  922. StatusCode: http.StatusBadRequest,
  923. ErrorCodes: []errcode.ErrorCode{
  924. ErrorCodeDigestInvalid,
  925. ErrorCodeNameInvalid,
  926. },
  927. },
  928. {
  929. Name: "Not allowed",
  930. Description: "Blob upload is not allowed because the registry is configured as a pull-through cache or for some other reason",
  931. StatusCode: http.StatusMethodNotAllowed,
  932. ErrorCodes: []errcode.ErrorCode{
  933. errcode.ErrorCodeUnsupported,
  934. },
  935. },
  936. unauthorizedResponseDescriptor,
  937. repositoryNotFoundResponseDescriptor,
  938. deniedResponseDescriptor,
  939. },
  940. },
  941. {
  942. Name: "Initiate Resumable Blob Upload",
  943. Description: "Initiate a resumable blob upload with an empty request body.",
  944. Headers: []ParameterDescriptor{
  945. hostHeader,
  946. authHeader,
  947. contentLengthZeroHeader,
  948. },
  949. PathParameters: []ParameterDescriptor{
  950. nameParameterDescriptor,
  951. },
  952. Successes: []ResponseDescriptor{
  953. {
  954. Description: "The upload has been created. The `Location` header must be used to complete the upload. The response should be identical to a `GET` request on the contents of the returned `Location` header.",
  955. StatusCode: http.StatusAccepted,
  956. Headers: []ParameterDescriptor{
  957. contentLengthZeroHeader,
  958. {
  959. Name: "Location",
  960. Type: "url",
  961. Format: "/v2/<name>/blobs/uploads/<uuid>",
  962. Description: "The location of the created upload. Clients should use the contents verbatim to complete the upload, adding parameters where required.",
  963. },
  964. {
  965. Name: "Range",
  966. Format: "0-0",
  967. Description: "Range header indicating the progress of the upload. When starting an upload, it will return an empty range, since no content has been received.",
  968. },
  969. dockerUploadUUIDHeader,
  970. },
  971. },
  972. },
  973. Failures: []ResponseDescriptor{
  974. {
  975. Name: "Invalid Name or Digest",
  976. StatusCode: http.StatusBadRequest,
  977. ErrorCodes: []errcode.ErrorCode{
  978. ErrorCodeDigestInvalid,
  979. ErrorCodeNameInvalid,
  980. },
  981. },
  982. unauthorizedResponseDescriptor,
  983. repositoryNotFoundResponseDescriptor,
  984. deniedResponseDescriptor,
  985. },
  986. },
  987. },
  988. },
  989. },
  990. },
  991. {
  992. Name: RouteNameBlobUploadChunk,
  993. Path: "/v2/{name:" + reference.NameRegexp.String() + "}/blobs/uploads/{uuid:[a-zA-Z0-9-_.=]+}",
  994. Entity: "Blob Upload",
  995. Description: "Interact with blob uploads. Clients should never assemble URLs for this endpoint and should only take it through the `Location` header on related API requests. The `Location` header and its parameters should be preserved by clients, using the latest value returned via upload related API calls.",
  996. Methods: []MethodDescriptor{
  997. {
  998. Method: "GET",
  999. Description: "Retrieve status of upload identified by `uuid`. The primary purpose of this endpoint is to resolve the current status of a resumable upload.",
  1000. Requests: []RequestDescriptor{
  1001. {
  1002. Description: "Retrieve the progress of the current upload, as reported by the `Range` header.",
  1003. Headers: []ParameterDescriptor{
  1004. hostHeader,
  1005. authHeader,
  1006. },
  1007. PathParameters: []ParameterDescriptor{
  1008. nameParameterDescriptor,
  1009. uuidParameterDescriptor,
  1010. },
  1011. Successes: []ResponseDescriptor{
  1012. {
  1013. Name: "Upload Progress",
  1014. Description: "The upload is known and in progress. The last received offset is available in the `Range` header.",
  1015. StatusCode: http.StatusNoContent,
  1016. Headers: []ParameterDescriptor{
  1017. {
  1018. Name: "Range",
  1019. Type: "header",
  1020. Format: "0-<offset>",
  1021. Description: "Range indicating the current progress of the upload.",
  1022. },
  1023. contentLengthZeroHeader,
  1024. dockerUploadUUIDHeader,
  1025. },
  1026. },
  1027. },
  1028. Failures: []ResponseDescriptor{
  1029. {
  1030. Description: "There was an error processing the upload and it must be restarted.",
  1031. StatusCode: http.StatusBadRequest,
  1032. ErrorCodes: []errcode.ErrorCode{
  1033. ErrorCodeDigestInvalid,
  1034. ErrorCodeNameInvalid,
  1035. ErrorCodeBlobUploadInvalid,
  1036. },
  1037. Body: BodyDescriptor{
  1038. ContentType: "application/json; charset=utf-8",
  1039. Format: errorsBody,
  1040. },
  1041. },
  1042. {
  1043. Description: "The upload is unknown to the registry. The upload must be restarted.",
  1044. StatusCode: http.StatusNotFound,
  1045. ErrorCodes: []errcode.ErrorCode{
  1046. ErrorCodeBlobUploadUnknown,
  1047. },
  1048. Body: BodyDescriptor{
  1049. ContentType: "application/json; charset=utf-8",
  1050. Format: errorsBody,
  1051. },
  1052. },
  1053. unauthorizedResponseDescriptor,
  1054. repositoryNotFoundResponseDescriptor,
  1055. deniedResponseDescriptor,
  1056. },
  1057. },
  1058. },
  1059. },
  1060. {
  1061. Method: "PATCH",
  1062. Description: "Upload a chunk of data for the specified upload.",
  1063. Requests: []RequestDescriptor{
  1064. {
  1065. Name: "Stream upload",
  1066. Description: "Upload a stream of data to upload without completing the upload.",
  1067. PathParameters: []ParameterDescriptor{
  1068. nameParameterDescriptor,
  1069. uuidParameterDescriptor,
  1070. },
  1071. Headers: []ParameterDescriptor{
  1072. hostHeader,
  1073. authHeader,
  1074. },
  1075. Body: BodyDescriptor{
  1076. ContentType: "application/octet-stream",
  1077. Format: "<binary data>",
  1078. },
  1079. Successes: []ResponseDescriptor{
  1080. {
  1081. Name: "Data Accepted",
  1082. Description: "The stream of data has been accepted and the current progress is available in the range header. The updated upload location is available in the `Location` header.",
  1083. StatusCode: http.StatusNoContent,
  1084. Headers: []ParameterDescriptor{
  1085. {
  1086. Name: "Location",
  1087. Type: "url",
  1088. Format: "/v2/<name>/blobs/uploads/<uuid>",
  1089. Description: "The location of the upload. Clients should assume this changes after each request. Clients should use the contents verbatim to complete the upload, adding parameters where required.",
  1090. },
  1091. {
  1092. Name: "Range",
  1093. Type: "header",
  1094. Format: "0-<offset>",
  1095. Description: "Range indicating the current progress of the upload.",
  1096. },
  1097. contentLengthZeroHeader,
  1098. dockerUploadUUIDHeader,
  1099. },
  1100. },
  1101. },
  1102. Failures: []ResponseDescriptor{
  1103. {
  1104. Description: "There was an error processing the upload and it must be restarted.",
  1105. StatusCode: http.StatusBadRequest,
  1106. ErrorCodes: []errcode.ErrorCode{
  1107. ErrorCodeDigestInvalid,
  1108. ErrorCodeNameInvalid,
  1109. ErrorCodeBlobUploadInvalid,
  1110. },
  1111. Body: BodyDescriptor{
  1112. ContentType: "application/json; charset=utf-8",
  1113. Format: errorsBody,
  1114. },
  1115. },
  1116. {
  1117. Description: "The upload is unknown to the registry. The upload must be restarted.",
  1118. StatusCode: http.StatusNotFound,
  1119. ErrorCodes: []errcode.ErrorCode{
  1120. ErrorCodeBlobUploadUnknown,
  1121. },
  1122. Body: BodyDescriptor{
  1123. ContentType: "application/json; charset=utf-8",
  1124. Format: errorsBody,
  1125. },
  1126. },
  1127. unauthorizedResponseDescriptor,
  1128. repositoryNotFoundResponseDescriptor,
  1129. deniedResponseDescriptor,
  1130. },
  1131. },
  1132. {
  1133. Name: "Chunked upload",
  1134. Description: "Upload a chunk of data to specified upload without completing the upload. The data will be uploaded to the specified Content Range.",
  1135. PathParameters: []ParameterDescriptor{
  1136. nameParameterDescriptor,
  1137. uuidParameterDescriptor,
  1138. },
  1139. Headers: []ParameterDescriptor{
  1140. hostHeader,
  1141. authHeader,
  1142. {
  1143. Name: "Content-Range",
  1144. Type: "header",
  1145. Format: "<start of range>-<end of range, inclusive>",
  1146. Required: true,
  1147. Description: "Range of bytes identifying the desired block of content represented by the body. Start must the end offset retrieved via status check plus one. Note that this is a non-standard use of the `Content-Range` header.",
  1148. },
  1149. {
  1150. Name: "Content-Length",
  1151. Type: "integer",
  1152. Format: "<length of chunk>",
  1153. Description: "Length of the chunk being uploaded, corresponding the length of the request body.",
  1154. },
  1155. },
  1156. Body: BodyDescriptor{
  1157. ContentType: "application/octet-stream",
  1158. Format: "<binary chunk>",
  1159. },
  1160. Successes: []ResponseDescriptor{
  1161. {
  1162. Name: "Chunk Accepted",
  1163. Description: "The chunk of data has been accepted and the current progress is available in the range header. The updated upload location is available in the `Location` header.",
  1164. StatusCode: http.StatusNoContent,
  1165. Headers: []ParameterDescriptor{
  1166. {
  1167. Name: "Location",
  1168. Type: "url",
  1169. Format: "/v2/<name>/blobs/uploads/<uuid>",
  1170. Description: "The location of the upload. Clients should assume this changes after each request. Clients should use the contents verbatim to complete the upload, adding parameters where required.",
  1171. },
  1172. {
  1173. Name: "Range",
  1174. Type: "header",
  1175. Format: "0-<offset>",
  1176. Description: "Range indicating the current progress of the upload.",
  1177. },
  1178. contentLengthZeroHeader,
  1179. dockerUploadUUIDHeader,
  1180. },
  1181. },
  1182. },
  1183. Failures: []ResponseDescriptor{
  1184. {
  1185. Description: "There was an error processing the upload and it must be restarted.",
  1186. StatusCode: http.StatusBadRequest,
  1187. ErrorCodes: []errcode.ErrorCode{
  1188. ErrorCodeDigestInvalid,
  1189. ErrorCodeNameInvalid,
  1190. ErrorCodeBlobUploadInvalid,
  1191. },
  1192. Body: BodyDescriptor{
  1193. ContentType: "application/json; charset=utf-8",
  1194. Format: errorsBody,
  1195. },
  1196. },
  1197. {
  1198. Description: "The upload is unknown to the registry. The upload must be restarted.",
  1199. StatusCode: http.StatusNotFound,
  1200. ErrorCodes: []errcode.ErrorCode{
  1201. ErrorCodeBlobUploadUnknown,
  1202. },
  1203. Body: BodyDescriptor{
  1204. ContentType: "application/json; charset=utf-8",
  1205. Format: errorsBody,
  1206. },
  1207. },
  1208. {
  1209. Description: "The `Content-Range` specification cannot be accepted, either because it does not overlap with the current progress or it is invalid.",
  1210. StatusCode: http.StatusRequestedRangeNotSatisfiable,
  1211. },
  1212. unauthorizedResponseDescriptor,
  1213. repositoryNotFoundResponseDescriptor,
  1214. deniedResponseDescriptor,
  1215. },
  1216. },
  1217. },
  1218. },
  1219. {
  1220. Method: "PUT",
  1221. Description: "Complete the upload specified by `uuid`, optionally appending the body as the final chunk.",
  1222. Requests: []RequestDescriptor{
  1223. {
  1224. Description: "Complete the upload, providing all the data in the body, if necessary. A request without a body will just complete the upload with previously uploaded content.",
  1225. Headers: []ParameterDescriptor{
  1226. hostHeader,
  1227. authHeader,
  1228. {
  1229. Name: "Content-Length",
  1230. Type: "integer",
  1231. Format: "<length of data>",
  1232. Description: "Length of the data being uploaded, corresponding to the length of the request body. May be zero if no data is provided.",
  1233. },
  1234. },
  1235. PathParameters: []ParameterDescriptor{
  1236. nameParameterDescriptor,
  1237. uuidParameterDescriptor,
  1238. },
  1239. QueryParameters: []ParameterDescriptor{
  1240. {
  1241. Name: "digest",
  1242. Type: "string",
  1243. Format: "<digest>",
  1244. Regexp: digest.DigestRegexp,
  1245. Required: true,
  1246. Description: `Digest of uploaded blob.`,
  1247. },
  1248. },
  1249. Body: BodyDescriptor{
  1250. ContentType: "application/octet-stream",
  1251. Format: "<binary data>",
  1252. },
  1253. Successes: []ResponseDescriptor{
  1254. {
  1255. Name: "Upload Complete",
  1256. Description: "The upload has been completed and accepted by the registry. The canonical location will be available in the `Location` header.",
  1257. StatusCode: http.StatusNoContent,
  1258. Headers: []ParameterDescriptor{
  1259. {
  1260. Name: "Location",
  1261. Type: "url",
  1262. Format: "<blob location>",
  1263. Description: "The canonical location of the blob for retrieval",
  1264. },
  1265. {
  1266. Name: "Content-Range",
  1267. Type: "header",
  1268. Format: "<start of range>-<end of range, inclusive>",
  1269. Description: "Range of bytes identifying the desired block of content represented by the body. Start must match the end of offset retrieved via status check. Note that this is a non-standard use of the `Content-Range` header.",
  1270. },
  1271. contentLengthZeroHeader,
  1272. digestHeader,
  1273. },
  1274. },
  1275. },
  1276. Failures: []ResponseDescriptor{
  1277. {
  1278. Description: "There was an error processing the upload and it must be restarted.",
  1279. StatusCode: http.StatusBadRequest,
  1280. ErrorCodes: []errcode.ErrorCode{
  1281. ErrorCodeDigestInvalid,
  1282. ErrorCodeNameInvalid,
  1283. ErrorCodeBlobUploadInvalid,
  1284. errcode.ErrorCodeUnsupported,
  1285. },
  1286. Body: BodyDescriptor{
  1287. ContentType: "application/json; charset=utf-8",
  1288. Format: errorsBody,
  1289. },
  1290. },
  1291. {
  1292. Description: "The upload is unknown to the registry. The upload must be restarted.",
  1293. StatusCode: http.StatusNotFound,
  1294. ErrorCodes: []errcode.ErrorCode{
  1295. ErrorCodeBlobUploadUnknown,
  1296. },
  1297. Body: BodyDescriptor{
  1298. ContentType: "application/json; charset=utf-8",
  1299. Format: errorsBody,
  1300. },
  1301. },
  1302. unauthorizedResponseDescriptor,
  1303. repositoryNotFoundResponseDescriptor,
  1304. deniedResponseDescriptor,
  1305. },
  1306. },
  1307. },
  1308. },
  1309. {
  1310. Method: "DELETE",
  1311. Description: "Cancel outstanding upload processes, releasing associated resources. If this is not called, the unfinished uploads will eventually timeout.",
  1312. Requests: []RequestDescriptor{
  1313. {
  1314. Description: "Cancel the upload specified by `uuid`.",
  1315. PathParameters: []ParameterDescriptor{
  1316. nameParameterDescriptor,
  1317. uuidParameterDescriptor,
  1318. },
  1319. Headers: []ParameterDescriptor{
  1320. hostHeader,
  1321. authHeader,
  1322. contentLengthZeroHeader,
  1323. },
  1324. Successes: []ResponseDescriptor{
  1325. {
  1326. Name: "Upload Deleted",
  1327. Description: "The upload has been successfully deleted.",
  1328. StatusCode: http.StatusNoContent,
  1329. Headers: []ParameterDescriptor{
  1330. contentLengthZeroHeader,
  1331. },
  1332. },
  1333. },
  1334. Failures: []ResponseDescriptor{
  1335. {
  1336. Description: "An error was encountered processing the delete. The client may ignore this error.",
  1337. StatusCode: http.StatusBadRequest,
  1338. ErrorCodes: []errcode.ErrorCode{
  1339. ErrorCodeNameInvalid,
  1340. ErrorCodeBlobUploadInvalid,
  1341. },
  1342. Body: BodyDescriptor{
  1343. ContentType: "application/json; charset=utf-8",
  1344. Format: errorsBody,
  1345. },
  1346. },
  1347. {
  1348. Description: "The upload is unknown to the registry. The client may ignore this error and assume the upload has been deleted.",
  1349. StatusCode: http.StatusNotFound,
  1350. ErrorCodes: []errcode.ErrorCode{
  1351. ErrorCodeBlobUploadUnknown,
  1352. },
  1353. Body: BodyDescriptor{
  1354. ContentType: "application/json; charset=utf-8",
  1355. Format: errorsBody,
  1356. },
  1357. },
  1358. unauthorizedResponseDescriptor,
  1359. repositoryNotFoundResponseDescriptor,
  1360. deniedResponseDescriptor,
  1361. },
  1362. },
  1363. },
  1364. },
  1365. },
  1366. },
  1367. {
  1368. Name: RouteNameCatalog,
  1369. Path: "/v2/_catalog",
  1370. Entity: "Catalog",
  1371. Description: "List a set of available repositories in the local registry cluster. Does not provide any indication of what may be available upstream. Applications can only determine if a repository is available but not if it is not available.",
  1372. Methods: []MethodDescriptor{
  1373. {
  1374. Method: "GET",
  1375. Description: "Retrieve a sorted, json list of repositories available in the registry.",
  1376. Requests: []RequestDescriptor{
  1377. {
  1378. Name: "Catalog Fetch Complete",
  1379. Description: "Request an unabridged list of repositories available.",
  1380. Successes: []ResponseDescriptor{
  1381. {
  1382. Description: "Returns the unabridged list of repositories as a json response.",
  1383. StatusCode: http.StatusOK,
  1384. Headers: []ParameterDescriptor{
  1385. {
  1386. Name: "Content-Length",
  1387. Type: "integer",
  1388. Description: "Length of the JSON response body.",
  1389. Format: "<length>",
  1390. },
  1391. },
  1392. Body: BodyDescriptor{
  1393. ContentType: "application/json; charset=utf-8",
  1394. Format: `{
  1395. "repositories": [
  1396. <name>,
  1397. ...
  1398. ]
  1399. }`,
  1400. },
  1401. },
  1402. },
  1403. },
  1404. {
  1405. Name: "Catalog Fetch Paginated",
  1406. Description: "Return the specified portion of repositories.",
  1407. QueryParameters: paginationParameters,
  1408. Successes: []ResponseDescriptor{
  1409. {
  1410. StatusCode: http.StatusOK,
  1411. Body: BodyDescriptor{
  1412. ContentType: "application/json; charset=utf-8",
  1413. Format: `{
  1414. "repositories": [
  1415. <name>,
  1416. ...
  1417. ]
  1418. "next": "<url>?last=<name>&n=<last value of n>"
  1419. }`,
  1420. },
  1421. Headers: []ParameterDescriptor{
  1422. {
  1423. Name: "Content-Length",
  1424. Type: "integer",
  1425. Description: "Length of the JSON response body.",
  1426. Format: "<length>",
  1427. },
  1428. linkHeader,
  1429. },
  1430. },
  1431. },
  1432. },
  1433. },
  1434. },
  1435. },
  1436. },
  1437. }
  1438. var routeDescriptorsMap map[string]RouteDescriptor
  1439. func init() {
  1440. routeDescriptorsMap = make(map[string]RouteDescriptor, len(routeDescriptors))
  1441. for _, descriptor := range routeDescriptors {
  1442. routeDescriptorsMap[descriptor.Name] = descriptor
  1443. }
  1444. }