Update docs and code to use application/x-tar in the build API

At the "Build image from Dockerfile" section in the API docs
the Content-Type header is missing.
In addition, some parts in the code are still setting the
Content-Type header to application/tar while it was changed
to application/x-tar since 16th September 2015.

Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>
Upstream-commit: b1996728aaeaa147c2045c8be79373d59ce7117a
Component: engine
This commit is contained in:
Boaz Shuster
2017-01-10 06:40:06 +02:00
parent 1f4bebfb09
commit 8f27f74ad0
12 changed files with 21 additions and 15 deletions
+2 -2
View File
@@ -4399,8 +4399,8 @@ paths:
in: "header"
type: "string"
enum:
- "application/tar"
default: "application/tar"
- "application/x-tar"
default: "application/x-tar"
- name: "X-Registry-Config"
in: "header"
description: |
+1 -1
View File
@@ -29,7 +29,7 @@ func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, optio
return types.ImageBuildResponse{}, err
}
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)
if err != nil {
+2 -2
View File
@@ -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)
}
contentType := r.Header.Get("Content-Type")
if contentType != "application/tar" {
return nil, fmt.Errorf("Content-type header not properly set in the request. Expected 'application/tar', got %s", contentType)
if contentType != "application/x-tar" {
return nil, fmt.Errorf("Content-type header not properly set in the request. Expected 'application/x-tar', got %s", contentType)
}
// Check query parameters
+1 -1
View File
@@ -12,7 +12,7 @@ import (
// PluginCreate creates a plugin
func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error {
headers := http.Header(make(map[string][]string))
headers.Set("Content-Type", "application/tar")
headers.Set("Content-Type", "application/x-tar")
query := url.Values{}
query.Set("name", createOptions.RepoName)
+2 -1
View File
@@ -1192,6 +1192,7 @@ Build an image from a Dockerfile
**Example request**:
POST /v1.18/build HTTP/1.1
Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }}
@@ -1246,7 +1247,7 @@ or being killed.
**Request Headers**:
- **Content-type** Set to `"application/tar"`.
- **Content-type** Set to `"application/x-tar"`.
- **X-Registry-Config** base64-encoded ConfigFile object
**Status codes**:
+2 -1
View File
@@ -1236,6 +1236,7 @@ Build an image from a Dockerfile
**Example request**:
POST /v1.19/build HTTP/1.1
Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }}
@@ -1292,7 +1293,7 @@ or being killed.
**Request Headers**:
- **Content-type** Set to `"application/tar"`.
- **Content-type** Set to `"application/x-tar"`.
- **X-Registry-Config** base64-encoded ConfigFile object
**Status codes**:
+2 -1
View File
@@ -1365,6 +1365,7 @@ Build an image from a Dockerfile
**Example request**:
POST /v1.20/build HTTP/1.1
Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }}
@@ -1425,7 +1426,7 @@ or being killed.
**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
object with the following structure:
+2 -1
View File
@@ -1448,6 +1448,7 @@ Build an image from a Dockerfile
**Example request**:
POST /v1.21/build HTTP/1.1
Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }}
@@ -1514,7 +1515,7 @@ or being killed.
**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
object with the following structure:
+2 -1
View File
@@ -1627,6 +1627,7 @@ Build an image from a Dockerfile
**Example request**:
POST /v1.22/build HTTP/1.1
Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }}
@@ -1694,7 +1695,7 @@ or being killed.
**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
object with the following structure:
+2 -1
View File
@@ -1662,6 +1662,7 @@ Build an image from a Dockerfile
**Example request**:
POST /v1.23/build HTTP/1.1
Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }}
@@ -1730,7 +1731,7 @@ or being killed.
**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
object with the following structure:
+2 -1
View File
@@ -1659,6 +1659,7 @@ Build an image from a Dockerfile
**Example request**:
POST /v1.24/build HTTP/1.1
Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }}
@@ -1727,7 +1728,7 @@ or being killed.
**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
object with the following structure:
+1 -2
View File
@@ -8,9 +8,8 @@ import (
// MimeTypes stores the MIME content type.
var MimeTypes = struct {
TextPlain string
Tar string
OctetStream string
}{"text/plain", "application/tar", "application/octet-stream"}
}{"text/plain", "application/octet-stream"}
// DetectContentType returns a best guess representation of the MIME
// content type for the bytes at c. The value detected by