mirror of
https://github.com/moby/moby.git
synced 2025-07-29 07:21:35 +03:00
integration-cli: use plugin Content-Type headers v1.2
The MediaType was changed twice in; -b3b7eb2723
("application/vnd.docker.plugins.v1+json" -> "application/vnd.docker.plugins.v1.1+json") -54587d861d
("application/vnd.docker.plugins.v1.1+json" -> "application/vnd.docker.plugins.v1.2+json") But the (integration) tests were still using the old version, so let's use the VersionMimeType const that's defined, and use the updated version. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -16,6 +16,7 @@ import (
|
|||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
volumetypes "github.com/docker/docker/api/types/volume"
|
volumetypes "github.com/docker/docker/api/types/volume"
|
||||||
"github.com/docker/docker/integration-cli/daemon"
|
"github.com/docker/docker/integration-cli/daemon"
|
||||||
|
"github.com/docker/docker/pkg/plugins"
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
testdaemon "github.com/docker/docker/testutil/daemon"
|
testdaemon "github.com/docker/docker/testutil/daemon"
|
||||||
"github.com/docker/docker/volume"
|
"github.com/docker/docker/volume"
|
||||||
@ -104,10 +105,10 @@ func newVolumePlugin(c *testing.T, name string) *volumePlugin {
|
|||||||
case error:
|
case error:
|
||||||
http.Error(w, t.Error(), 500)
|
http.Error(w, t.Error(), 500)
|
||||||
case string:
|
case string:
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintln(w, t)
|
fmt.Fprintln(w, t)
|
||||||
default:
|
default:
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
json.NewEncoder(w).Encode(&data)
|
json.NewEncoder(w).Encode(&data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/docker/docker/libnetwork/ipamapi"
|
"github.com/docker/docker/libnetwork/ipamapi"
|
||||||
remoteipam "github.com/docker/docker/libnetwork/ipams/remote/api"
|
remoteipam "github.com/docker/docker/libnetwork/ipams/remote/api"
|
||||||
"github.com/docker/docker/libnetwork/netlabel"
|
"github.com/docker/docker/libnetwork/netlabel"
|
||||||
|
"github.com/docker/docker/pkg/plugins"
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
"github.com/docker/docker/runconfig"
|
"github.com/docker/docker/runconfig"
|
||||||
testdaemon "github.com/docker/docker/testutil/daemon"
|
testdaemon "github.com/docker/docker/testutil/daemon"
|
||||||
@ -58,13 +59,13 @@ func (s *DockerNetworkSuite) SetUpSuite(c *testing.T) {
|
|||||||
|
|
||||||
func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ipamDrv string) {
|
func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ipamDrv string) {
|
||||||
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, `{"Implements": ["%s", "%s"]}`, driverapi.NetworkPluginEndpointType, ipamapi.PluginEndpointType)
|
fmt.Fprintf(w, `{"Implements": ["%s", "%s"]}`, driverapi.NetworkPluginEndpointType, ipamapi.PluginEndpointType)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Network driver implementation
|
// Network driver implementation
|
||||||
mux.HandleFunc(fmt.Sprintf("/%s.GetCapabilities", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc(fmt.Sprintf("/%s.GetCapabilities", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, `{"Scope":"local"}`)
|
fmt.Fprintf(w, `{"Scope":"local"}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -74,22 +75,22 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip
|
|||||||
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, "null")
|
fmt.Fprintf(w, "null")
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc(fmt.Sprintf("/%s.DeleteNetwork", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc(fmt.Sprintf("/%s.DeleteNetwork", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, "null")
|
fmt.Fprintf(w, "null")
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc(fmt.Sprintf("/%s.CreateEndpoint", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc(fmt.Sprintf("/%s.CreateEndpoint", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, `{"Interface":{"MacAddress":"a0:b1:c2:d3:e4:f5"}}`)
|
fmt.Fprintf(w, `{"Interface":{"MacAddress":"a0:b1:c2:d3:e4:f5"}}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc(fmt.Sprintf("/%s.Join", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc(fmt.Sprintf("/%s.Join", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
|
|
||||||
veth := &netlink.Veth{
|
veth := &netlink.Veth{
|
||||||
LinkAttrs: netlink.LinkAttrs{Name: "randomIfName", TxQLen: 0}, PeerName: "cnt0",
|
LinkAttrs: netlink.LinkAttrs{Name: "randomIfName", TxQLen: 0}, PeerName: "cnt0",
|
||||||
@ -102,12 +103,12 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip
|
|||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc(fmt.Sprintf("/%s.Leave", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc(fmt.Sprintf("/%s.Leave", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, "null")
|
fmt.Fprintf(w, "null")
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc(fmt.Sprintf("/%s.DeleteEndpoint", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc(fmt.Sprintf("/%s.DeleteEndpoint", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
if link, err := netlink.LinkByName("cnt0"); err == nil {
|
if link, err := netlink.LinkByName("cnt0"); err == nil {
|
||||||
netlink.LinkDel(link)
|
netlink.LinkDel(link)
|
||||||
}
|
}
|
||||||
@ -128,7 +129,7 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip
|
|||||||
)
|
)
|
||||||
|
|
||||||
mux.HandleFunc(fmt.Sprintf("/%s.GetDefaultAddressSpaces", ipamapi.PluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc(fmt.Sprintf("/%s.GetDefaultAddressSpaces", ipamapi.PluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, `{"LocalDefaultAddressSpace":"`+lAS+`", "GlobalDefaultAddressSpace": "`+gAS+`"}`)
|
fmt.Fprintf(w, `{"LocalDefaultAddressSpace":"`+lAS+`", "GlobalDefaultAddressSpace": "`+gAS+`"}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -138,7 +139,7 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip
|
|||||||
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
if poolRequest.AddressSpace != lAS && poolRequest.AddressSpace != gAS {
|
if poolRequest.AddressSpace != lAS && poolRequest.AddressSpace != gAS {
|
||||||
fmt.Fprintf(w, `{"Error":"Unknown address space in pool request: `+poolRequest.AddressSpace+`"}`)
|
fmt.Fprintf(w, `{"Error":"Unknown address space in pool request: `+poolRequest.AddressSpace+`"}`)
|
||||||
} else if poolRequest.Pool != "" && poolRequest.Pool != pool {
|
} else if poolRequest.Pool != "" && poolRequest.Pool != pool {
|
||||||
@ -154,7 +155,7 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip
|
|||||||
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
// make sure libnetwork is now querying on the expected pool id
|
// make sure libnetwork is now querying on the expected pool id
|
||||||
if addressRequest.PoolID != poolID {
|
if addressRequest.PoolID != poolID {
|
||||||
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
||||||
@ -171,7 +172,7 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip
|
|||||||
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
// make sure libnetwork is now asking to release the expected address from the expected poolid
|
// make sure libnetwork is now asking to release the expected address from the expected poolid
|
||||||
if addressRequest.PoolID != poolID {
|
if addressRequest.PoolID != poolID {
|
||||||
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
||||||
@ -188,7 +189,7 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip
|
|||||||
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
// make sure libnetwork is now asking to release the expected poolid
|
// make sure libnetwork is now asking to release the expected poolid
|
||||||
if addressRequest.PoolID != poolID {
|
if addressRequest.PoolID != poolID {
|
||||||
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/docker/libnetwork/ipamapi"
|
"github.com/docker/docker/libnetwork/ipamapi"
|
||||||
remoteipam "github.com/docker/docker/libnetwork/ipams/remote/api"
|
remoteipam "github.com/docker/docker/libnetwork/ipams/remote/api"
|
||||||
|
"github.com/docker/docker/pkg/plugins"
|
||||||
"github.com/moby/swarmkit/v2/ca/keyutils"
|
"github.com/moby/swarmkit/v2/ca/keyutils"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
@ -617,13 +618,13 @@ const (
|
|||||||
|
|
||||||
func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDrv, ipamDrv string) {
|
func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDrv, ipamDrv string) {
|
||||||
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, `{"Implements": ["%s", "%s"]}`, driverapi.NetworkPluginEndpointType, ipamapi.PluginEndpointType)
|
fmt.Fprintf(w, `{"Implements": ["%s", "%s"]}`, driverapi.NetworkPluginEndpointType, ipamapi.PluginEndpointType)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Network driver implementation
|
// Network driver implementation
|
||||||
mux.HandleFunc(fmt.Sprintf("/%s.GetCapabilities", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc(fmt.Sprintf("/%s.GetCapabilities", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, `{"Scope":"global"}`)
|
fmt.Fprintf(w, `{"Scope":"global"}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -633,12 +634,12 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr
|
|||||||
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, "null")
|
fmt.Fprintf(w, "null")
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc(fmt.Sprintf("/%s.FreeNetwork", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc(fmt.Sprintf("/%s.FreeNetwork", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, "null")
|
fmt.Fprintf(w, "null")
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -648,22 +649,22 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr
|
|||||||
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, "null")
|
fmt.Fprintf(w, "null")
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc(fmt.Sprintf("/%s.DeleteNetwork", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc(fmt.Sprintf("/%s.DeleteNetwork", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, "null")
|
fmt.Fprintf(w, "null")
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc(fmt.Sprintf("/%s.CreateEndpoint", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc(fmt.Sprintf("/%s.CreateEndpoint", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, `{"Interface":{"MacAddress":"a0:b1:c2:d3:e4:f5"}}`)
|
fmt.Fprintf(w, `{"Interface":{"MacAddress":"a0:b1:c2:d3:e4:f5"}}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc(fmt.Sprintf("/%s.Join", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc(fmt.Sprintf("/%s.Join", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
|
|
||||||
veth := &netlink.Veth{
|
veth := &netlink.Veth{
|
||||||
LinkAttrs: netlink.LinkAttrs{Name: "randomIfName", TxQLen: 0}, PeerName: "cnt0",
|
LinkAttrs: netlink.LinkAttrs{Name: "randomIfName", TxQLen: 0}, PeerName: "cnt0",
|
||||||
@ -676,12 +677,12 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr
|
|||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc(fmt.Sprintf("/%s.Leave", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc(fmt.Sprintf("/%s.Leave", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, "null")
|
fmt.Fprintf(w, "null")
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc(fmt.Sprintf("/%s.DeleteEndpoint", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc(fmt.Sprintf("/%s.DeleteEndpoint", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
if link, err := netlink.LinkByName("cnt0"); err == nil {
|
if link, err := netlink.LinkByName("cnt0"); err == nil {
|
||||||
netlink.LinkDel(link)
|
netlink.LinkDel(link)
|
||||||
}
|
}
|
||||||
@ -702,7 +703,7 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr
|
|||||||
)
|
)
|
||||||
|
|
||||||
mux.HandleFunc(fmt.Sprintf("/%s.GetDefaultAddressSpaces", ipamapi.PluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc(fmt.Sprintf("/%s.GetDefaultAddressSpaces", ipamapi.PluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
fmt.Fprintf(w, `{"LocalDefaultAddressSpace":"`+lAS+`", "GlobalDefaultAddressSpace": "`+gAS+`"}`)
|
fmt.Fprintf(w, `{"LocalDefaultAddressSpace":"`+lAS+`", "GlobalDefaultAddressSpace": "`+gAS+`"}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -712,7 +713,7 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr
|
|||||||
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
if poolRequest.AddressSpace != lAS && poolRequest.AddressSpace != gAS {
|
if poolRequest.AddressSpace != lAS && poolRequest.AddressSpace != gAS {
|
||||||
fmt.Fprintf(w, `{"Error":"Unknown address space in pool request: `+poolRequest.AddressSpace+`"}`)
|
fmt.Fprintf(w, `{"Error":"Unknown address space in pool request: `+poolRequest.AddressSpace+`"}`)
|
||||||
} else if poolRequest.Pool != "" && poolRequest.Pool != pool {
|
} else if poolRequest.Pool != "" && poolRequest.Pool != pool {
|
||||||
@ -728,7 +729,7 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr
|
|||||||
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
// make sure libnetwork is now querying on the expected pool id
|
// make sure libnetwork is now querying on the expected pool id
|
||||||
if addressRequest.PoolID != poolID {
|
if addressRequest.PoolID != poolID {
|
||||||
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
||||||
@ -745,7 +746,7 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr
|
|||||||
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
// make sure libnetwork is now asking to release the expected address from the expected poolid
|
// make sure libnetwork is now asking to release the expected address from the expected poolid
|
||||||
if addressRequest.PoolID != poolID {
|
if addressRequest.PoolID != poolID {
|
||||||
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
||||||
@ -762,7 +763,7 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr
|
|||||||
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", plugins.VersionMimetype)
|
||||||
// make sure libnetwork is now asking to release the expected poolid
|
// make sure libnetwork is now asking to release the expected poolid
|
||||||
if addressRequest.PoolID != poolID {
|
if addressRequest.PoolID != poolID {
|
||||||
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
||||||
|
Reference in New Issue
Block a user