Skip to content

Commit ff0cb85

Browse files
committed
Add Options and bump content type to conform the new volume api.
Signed-off-by: David Calavera <david.calavera@gmail.com>
1 parent 30be3a9 commit ff0cb85

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

api.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const (
1414
// DefaultDockerRootDirectory is the default directory where volumes will be created.
1515
DefaultDockerRootDirectory = "/var/lib/docker/volumes"
1616

17-
defaultContentTypeV1 = "application/vnd.docker.plugins.v1+json"
17+
defaultContentTypeV1_1 = "application/vnd.docker.plugins.v1.1+json"
1818
defaultImplementationManifest = `{"Implements": ["VolumeDriver"]}`
1919
pluginSpecDir = "/etc/docker/plugins"
2020
pluginSockDir = "/run/docker/plugins"
@@ -29,7 +29,8 @@ const (
2929

3030
// Request is the structure that docker's requests are deserialized to.
3131
type Request struct {
32-
Name string
32+
Name string
33+
Options map[string]string `json:"Opts,omitempty"`
3334
}
3435

3536
// Response is the strucutre that the plugin's responses are serialized to.
@@ -64,7 +65,7 @@ func NewHandler(driver Driver) *Handler {
6465

6566
func (h *Handler) initMux() {
6667
h.mux.HandleFunc(activatePath, func(w http.ResponseWriter, r *http.Request) {
67-
w.Header().Set("Content-Type", defaultContentTypeV1)
68+
w.Header().Set("Content-Type", defaultContentTypeV1_1)
6869
fmt.Fprintln(w, defaultImplementationManifest)
6970
})
7071

@@ -153,7 +154,7 @@ func decodeRequest(w http.ResponseWriter, r *http.Request) (req Request, err err
153154
}
154155

155156
func encodeResponse(w http.ResponseWriter, res Response) {
156-
w.Header().Set("Content-Type", defaultContentTypeV1)
157+
w.Header().Set("Content-Type", defaultContentTypeV1_1)
157158
if res.Err != "" {
158159
w.WriteHeader(http.StatusInternalServerError)
159160
}

0 commit comments

Comments
 (0)