mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #29206 from ripcurld0/doc_api_update
Specify content type in the build request
This commit is contained in:
commit
24e9ac1575
12 changed files with 21 additions and 15 deletions
|
@ -4399,8 +4399,8 @@ paths:
|
||||||
in: "header"
|
in: "header"
|
||||||
type: "string"
|
type: "string"
|
||||||
enum:
|
enum:
|
||||||
- "application/tar"
|
- "application/x-tar"
|
||||||
default: "application/tar"
|
default: "application/x-tar"
|
||||||
- name: "X-Registry-Config"
|
- name: "X-Registry-Config"
|
||||||
in: "header"
|
in: "header"
|
||||||
description: |
|
description: |
|
||||||
|
|
|
@ -29,7 +29,7 @@ func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, optio
|
||||||
return types.ImageBuildResponse{}, err
|
return types.ImageBuildResponse{}, err
|
||||||
}
|
}
|
||||||
headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf))
|
headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf))
|
||||||
headers.Set("Content-Type", "application/tar")
|
headers.Set("Content-Type", "application/x-tar")
|
||||||
|
|
||||||
serverResp, err := cli.postRaw(ctx, "/build", query, buildContext, headers)
|
serverResp, err := cli.postRaw(ctx, "/build", query, buildContext, headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -170,8 +170,8 @@ func TestImageBuild(t *testing.T) {
|
||||||
return nil, fmt.Errorf("X-Registry-Config header not properly set in the request. Expected '%s', got %s", buildCase.expectedRegistryConfig, registryConfig)
|
return nil, fmt.Errorf("X-Registry-Config header not properly set in the request. Expected '%s', got %s", buildCase.expectedRegistryConfig, registryConfig)
|
||||||
}
|
}
|
||||||
contentType := r.Header.Get("Content-Type")
|
contentType := r.Header.Get("Content-Type")
|
||||||
if contentType != "application/tar" {
|
if contentType != "application/x-tar" {
|
||||||
return nil, fmt.Errorf("Content-type header not properly set in the request. Expected 'application/tar', got %s", contentType)
|
return nil, fmt.Errorf("Content-type header not properly set in the request. Expected 'application/x-tar', got %s", contentType)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check query parameters
|
// Check query parameters
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
// PluginCreate creates a plugin
|
// PluginCreate creates a plugin
|
||||||
func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error {
|
func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error {
|
||||||
headers := http.Header(make(map[string][]string))
|
headers := http.Header(make(map[string][]string))
|
||||||
headers.Set("Content-Type", "application/tar")
|
headers.Set("Content-Type", "application/x-tar")
|
||||||
|
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
query.Set("name", createOptions.RepoName)
|
query.Set("name", createOptions.RepoName)
|
||||||
|
|
|
@ -1192,6 +1192,7 @@ Build an image from a Dockerfile
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
POST /v1.18/build HTTP/1.1
|
POST /v1.18/build HTTP/1.1
|
||||||
|
Content-Type: application/x-tar
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{{ TAR STREAM }}
|
{{ TAR STREAM }}
|
||||||
|
@ -1246,7 +1247,7 @@ or being killed.
|
||||||
|
|
||||||
**Request Headers**:
|
**Request Headers**:
|
||||||
|
|
||||||
- **Content-type** – Set to `"application/tar"`.
|
- **Content-type** – Set to `"application/x-tar"`.
|
||||||
- **X-Registry-Config** – base64-encoded ConfigFile object
|
- **X-Registry-Config** – base64-encoded ConfigFile object
|
||||||
|
|
||||||
**Status codes**:
|
**Status codes**:
|
||||||
|
|
|
@ -1236,6 +1236,7 @@ Build an image from a Dockerfile
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
POST /v1.19/build HTTP/1.1
|
POST /v1.19/build HTTP/1.1
|
||||||
|
Content-Type: application/x-tar
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{{ TAR STREAM }}
|
{{ TAR STREAM }}
|
||||||
|
@ -1292,7 +1293,7 @@ or being killed.
|
||||||
|
|
||||||
**Request Headers**:
|
**Request Headers**:
|
||||||
|
|
||||||
- **Content-type** – Set to `"application/tar"`.
|
- **Content-type** – Set to `"application/x-tar"`.
|
||||||
- **X-Registry-Config** – base64-encoded ConfigFile object
|
- **X-Registry-Config** – base64-encoded ConfigFile object
|
||||||
|
|
||||||
**Status codes**:
|
**Status codes**:
|
||||||
|
|
|
@ -1365,6 +1365,7 @@ Build an image from a Dockerfile
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
POST /v1.20/build HTTP/1.1
|
POST /v1.20/build HTTP/1.1
|
||||||
|
Content-Type: application/x-tar
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{{ TAR STREAM }}
|
{{ TAR STREAM }}
|
||||||
|
@ -1425,7 +1426,7 @@ or being killed.
|
||||||
|
|
||||||
**Request Headers**:
|
**Request Headers**:
|
||||||
|
|
||||||
- **Content-type** – Set to `"application/tar"`.
|
- **Content-type** – Set to `"application/x-tar"`.
|
||||||
- **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON
|
- **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON
|
||||||
object with the following structure:
|
object with the following structure:
|
||||||
|
|
||||||
|
|
|
@ -1448,6 +1448,7 @@ Build an image from a Dockerfile
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
POST /v1.21/build HTTP/1.1
|
POST /v1.21/build HTTP/1.1
|
||||||
|
Content-Type: application/x-tar
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{{ TAR STREAM }}
|
{{ TAR STREAM }}
|
||||||
|
@ -1514,7 +1515,7 @@ or being killed.
|
||||||
|
|
||||||
**Request Headers**:
|
**Request Headers**:
|
||||||
|
|
||||||
- **Content-type** – Set to `"application/tar"`.
|
- **Content-type** – Set to `"application/x-tar"`.
|
||||||
- **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON
|
- **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON
|
||||||
object with the following structure:
|
object with the following structure:
|
||||||
|
|
||||||
|
|
|
@ -1627,6 +1627,7 @@ Build an image from a Dockerfile
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
POST /v1.22/build HTTP/1.1
|
POST /v1.22/build HTTP/1.1
|
||||||
|
Content-Type: application/x-tar
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{{ TAR STREAM }}
|
{{ TAR STREAM }}
|
||||||
|
@ -1694,7 +1695,7 @@ or being killed.
|
||||||
|
|
||||||
**Request Headers**:
|
**Request Headers**:
|
||||||
|
|
||||||
- **Content-type** – Set to `"application/tar"`.
|
- **Content-type** – Set to `"application/x-tar"`.
|
||||||
- **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON
|
- **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON
|
||||||
object with the following structure:
|
object with the following structure:
|
||||||
|
|
||||||
|
|
|
@ -1662,6 +1662,7 @@ Build an image from a Dockerfile
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
POST /v1.23/build HTTP/1.1
|
POST /v1.23/build HTTP/1.1
|
||||||
|
Content-Type: application/x-tar
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{{ TAR STREAM }}
|
{{ TAR STREAM }}
|
||||||
|
@ -1730,7 +1731,7 @@ or being killed.
|
||||||
|
|
||||||
**Request Headers**:
|
**Request Headers**:
|
||||||
|
|
||||||
- **Content-type** – Set to `"application/tar"`.
|
- **Content-type** – Set to `"application/x-tar"`.
|
||||||
- **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON
|
- **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON
|
||||||
object with the following structure:
|
object with the following structure:
|
||||||
|
|
||||||
|
|
|
@ -1659,6 +1659,7 @@ Build an image from a Dockerfile
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
POST /v1.24/build HTTP/1.1
|
POST /v1.24/build HTTP/1.1
|
||||||
|
Content-Type: application/x-tar
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{{ TAR STREAM }}
|
{{ TAR STREAM }}
|
||||||
|
@ -1727,7 +1728,7 @@ or being killed.
|
||||||
|
|
||||||
**Request Headers**:
|
**Request Headers**:
|
||||||
|
|
||||||
- **Content-type** – Set to `"application/tar"`.
|
- **Content-type** – Set to `"application/x-tar"`.
|
||||||
- **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON
|
- **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON
|
||||||
object with the following structure:
|
object with the following structure:
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,8 @@ import (
|
||||||
// MimeTypes stores the MIME content type.
|
// MimeTypes stores the MIME content type.
|
||||||
var MimeTypes = struct {
|
var MimeTypes = struct {
|
||||||
TextPlain string
|
TextPlain string
|
||||||
Tar string
|
|
||||||
OctetStream string
|
OctetStream string
|
||||||
}{"text/plain", "application/tar", "application/octet-stream"}
|
}{"text/plain", "application/octet-stream"}
|
||||||
|
|
||||||
// DetectContentType returns a best guess representation of the MIME
|
// DetectContentType returns a best guess representation of the MIME
|
||||||
// content type for the bytes at c. The value detected by
|
// content type for the bytes at c. The value detected by
|
||||||
|
|
Loading…
Reference in a new issue