The MediaType was changed twice in;
- b3b7eb2723461b1eb4be692f4bced0ae8ea9cb58 ("application/vnd.docker.plugins.v1+json" -> "application/vnd.docker.plugins.v1.1+json")
- 54587d861d6664d6d32bc62a46c0c7ea0c7853e6 ("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>
| ... | ... |
@@ -16,6 +16,7 @@ import ( |
| 16 | 16 |
"github.com/docker/docker/api/types" |
| 17 | 17 |
volumetypes "github.com/docker/docker/api/types/volume" |
| 18 | 18 |
"github.com/docker/docker/integration-cli/daemon" |
| 19 |
+ "github.com/docker/docker/pkg/plugins" |
|
| 19 | 20 |
"github.com/docker/docker/pkg/stringid" |
| 20 | 21 |
testdaemon "github.com/docker/docker/testutil/daemon" |
| 21 | 22 |
"github.com/docker/docker/volume" |
| ... | ... |
@@ -104,10 +105,10 @@ func newVolumePlugin(c *testing.T, name string) *volumePlugin {
|
| 104 | 104 |
case error: |
| 105 | 105 |
http.Error(w, t.Error(), 500) |
| 106 | 106 |
case string: |
| 107 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 107 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 108 | 108 |
fmt.Fprintln(w, t) |
| 109 | 109 |
default: |
| 110 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 110 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 111 | 111 |
json.NewEncoder(w).Encode(&data) |
| 112 | 112 |
} |
| 113 | 113 |
} |
| ... | ... |
@@ -22,6 +22,7 @@ import ( |
| 22 | 22 |
"github.com/docker/docker/libnetwork/ipamapi" |
| 23 | 23 |
remoteipam "github.com/docker/docker/libnetwork/ipams/remote/api" |
| 24 | 24 |
"github.com/docker/docker/libnetwork/netlabel" |
| 25 |
+ "github.com/docker/docker/pkg/plugins" |
|
| 25 | 26 |
"github.com/docker/docker/pkg/stringid" |
| 26 | 27 |
"github.com/docker/docker/runconfig" |
| 27 | 28 |
testdaemon "github.com/docker/docker/testutil/daemon" |
| ... | ... |
@@ -58,13 +59,13 @@ func (s *DockerNetworkSuite) SetUpSuite(c *testing.T) {
|
| 58 | 58 |
|
| 59 | 59 |
func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ipamDrv string) {
|
| 60 | 60 |
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
| 61 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 61 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 62 | 62 |
fmt.Fprintf(w, `{"Implements": ["%s", "%s"]}`, driverapi.NetworkPluginEndpointType, ipamapi.PluginEndpointType)
|
| 63 | 63 |
}) |
| 64 | 64 |
|
| 65 | 65 |
// Network driver implementation |
| 66 | 66 |
mux.HandleFunc(fmt.Sprintf("/%s.GetCapabilities", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
| 67 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 67 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 68 | 68 |
fmt.Fprintf(w, `{"Scope":"local"}`)
|
| 69 | 69 |
}) |
| 70 | 70 |
|
| ... | ... |
@@ -74,22 +75,22 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip |
| 74 | 74 |
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest) |
| 75 | 75 |
return |
| 76 | 76 |
} |
| 77 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 77 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 78 | 78 |
fmt.Fprintf(w, "null") |
| 79 | 79 |
}) |
| 80 | 80 |
|
| 81 | 81 |
mux.HandleFunc(fmt.Sprintf("/%s.DeleteNetwork", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
| 82 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 82 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 83 | 83 |
fmt.Fprintf(w, "null") |
| 84 | 84 |
}) |
| 85 | 85 |
|
| 86 | 86 |
mux.HandleFunc(fmt.Sprintf("/%s.CreateEndpoint", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
| 87 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 87 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 88 | 88 |
fmt.Fprintf(w, `{"Interface":{"MacAddress":"a0:b1:c2:d3:e4:f5"}}`)
|
| 89 | 89 |
}) |
| 90 | 90 |
|
| 91 | 91 |
mux.HandleFunc(fmt.Sprintf("/%s.Join", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
| 92 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 92 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 93 | 93 |
|
| 94 | 94 |
veth := &netlink.Veth{
|
| 95 | 95 |
LinkAttrs: netlink.LinkAttrs{Name: "randomIfName", TxQLen: 0}, PeerName: "cnt0",
|
| ... | ... |
@@ -102,12 +103,12 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip |
| 102 | 102 |
}) |
| 103 | 103 |
|
| 104 | 104 |
mux.HandleFunc(fmt.Sprintf("/%s.Leave", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
| 105 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 105 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 106 | 106 |
fmt.Fprintf(w, "null") |
| 107 | 107 |
}) |
| 108 | 108 |
|
| 109 | 109 |
mux.HandleFunc(fmt.Sprintf("/%s.DeleteEndpoint", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
| 110 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 110 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 111 | 111 |
if link, err := netlink.LinkByName("cnt0"); err == nil {
|
| 112 | 112 |
netlink.LinkDel(link) |
| 113 | 113 |
} |
| ... | ... |
@@ -128,7 +129,7 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip |
| 128 | 128 |
) |
| 129 | 129 |
|
| 130 | 130 |
mux.HandleFunc(fmt.Sprintf("/%s.GetDefaultAddressSpaces", ipamapi.PluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
| 131 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 131 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 132 | 132 |
fmt.Fprintf(w, `{"LocalDefaultAddressSpace":"`+lAS+`", "GlobalDefaultAddressSpace": "`+gAS+`"}`)
|
| 133 | 133 |
}) |
| 134 | 134 |
|
| ... | ... |
@@ -138,7 +139,7 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip |
| 138 | 138 |
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest) |
| 139 | 139 |
return |
| 140 | 140 |
} |
| 141 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 141 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 142 | 142 |
if poolRequest.AddressSpace != lAS && poolRequest.AddressSpace != gAS {
|
| 143 | 143 |
fmt.Fprintf(w, `{"Error":"Unknown address space in pool request: `+poolRequest.AddressSpace+`"}`)
|
| 144 | 144 |
} else if poolRequest.Pool != "" && poolRequest.Pool != pool {
|
| ... | ... |
@@ -154,7 +155,7 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip |
| 154 | 154 |
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest) |
| 155 | 155 |
return |
| 156 | 156 |
} |
| 157 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 157 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 158 | 158 |
// make sure libnetwork is now querying on the expected pool id |
| 159 | 159 |
if addressRequest.PoolID != poolID {
|
| 160 | 160 |
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
| ... | ... |
@@ -171,7 +172,7 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip |
| 171 | 171 |
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest) |
| 172 | 172 |
return |
| 173 | 173 |
} |
| 174 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 174 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 175 | 175 |
// make sure libnetwork is now asking to release the expected address from the expected poolid |
| 176 | 176 |
if addressRequest.PoolID != poolID {
|
| 177 | 177 |
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
| ... | ... |
@@ -188,7 +189,7 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip |
| 188 | 188 |
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest) |
| 189 | 189 |
return |
| 190 | 190 |
} |
| 191 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 191 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 192 | 192 |
// make sure libnetwork is now asking to release the expected poolid |
| 193 | 193 |
if addressRequest.PoolID != poolID {
|
| 194 | 194 |
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
| ... | ... |
@@ -26,6 +26,7 @@ import ( |
| 26 | 26 |
"github.com/docker/docker/libnetwork/driverapi" |
| 27 | 27 |
"github.com/docker/docker/libnetwork/ipamapi" |
| 28 | 28 |
remoteipam "github.com/docker/docker/libnetwork/ipams/remote/api" |
| 29 |
+ "github.com/docker/docker/pkg/plugins" |
|
| 29 | 30 |
"github.com/moby/swarmkit/v2/ca/keyutils" |
| 30 | 31 |
"github.com/vishvananda/netlink" |
| 31 | 32 |
"gotest.tools/v3/assert" |
| ... | ... |
@@ -617,13 +618,13 @@ const ( |
| 617 | 617 |
|
| 618 | 618 |
func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDrv, ipamDrv string) {
|
| 619 | 619 |
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
| 620 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 620 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 621 | 621 |
fmt.Fprintf(w, `{"Implements": ["%s", "%s"]}`, driverapi.NetworkPluginEndpointType, ipamapi.PluginEndpointType)
|
| 622 | 622 |
}) |
| 623 | 623 |
|
| 624 | 624 |
// Network driver implementation |
| 625 | 625 |
mux.HandleFunc(fmt.Sprintf("/%s.GetCapabilities", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
| 626 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 626 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 627 | 627 |
fmt.Fprintf(w, `{"Scope":"global"}`)
|
| 628 | 628 |
}) |
| 629 | 629 |
|
| ... | ... |
@@ -633,12 +634,12 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr |
| 633 | 633 |
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest) |
| 634 | 634 |
return |
| 635 | 635 |
} |
| 636 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 636 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 637 | 637 |
fmt.Fprintf(w, "null") |
| 638 | 638 |
}) |
| 639 | 639 |
|
| 640 | 640 |
mux.HandleFunc(fmt.Sprintf("/%s.FreeNetwork", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
| 641 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 641 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 642 | 642 |
fmt.Fprintf(w, "null") |
| 643 | 643 |
}) |
| 644 | 644 |
|
| ... | ... |
@@ -648,22 +649,22 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr |
| 648 | 648 |
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest) |
| 649 | 649 |
return |
| 650 | 650 |
} |
| 651 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 651 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 652 | 652 |
fmt.Fprintf(w, "null") |
| 653 | 653 |
}) |
| 654 | 654 |
|
| 655 | 655 |
mux.HandleFunc(fmt.Sprintf("/%s.DeleteNetwork", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
| 656 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 656 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 657 | 657 |
fmt.Fprintf(w, "null") |
| 658 | 658 |
}) |
| 659 | 659 |
|
| 660 | 660 |
mux.HandleFunc(fmt.Sprintf("/%s.CreateEndpoint", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
| 661 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 661 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 662 | 662 |
fmt.Fprintf(w, `{"Interface":{"MacAddress":"a0:b1:c2:d3:e4:f5"}}`)
|
| 663 | 663 |
}) |
| 664 | 664 |
|
| 665 | 665 |
mux.HandleFunc(fmt.Sprintf("/%s.Join", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
| 666 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 666 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 667 | 667 |
|
| 668 | 668 |
veth := &netlink.Veth{
|
| 669 | 669 |
LinkAttrs: netlink.LinkAttrs{Name: "randomIfName", TxQLen: 0}, PeerName: "cnt0",
|
| ... | ... |
@@ -676,12 +677,12 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr |
| 676 | 676 |
}) |
| 677 | 677 |
|
| 678 | 678 |
mux.HandleFunc(fmt.Sprintf("/%s.Leave", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
| 679 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 679 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 680 | 680 |
fmt.Fprintf(w, "null") |
| 681 | 681 |
}) |
| 682 | 682 |
|
| 683 | 683 |
mux.HandleFunc(fmt.Sprintf("/%s.DeleteEndpoint", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
| 684 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 684 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 685 | 685 |
if link, err := netlink.LinkByName("cnt0"); err == nil {
|
| 686 | 686 |
netlink.LinkDel(link) |
| 687 | 687 |
} |
| ... | ... |
@@ -702,7 +703,7 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr |
| 702 | 702 |
) |
| 703 | 703 |
|
| 704 | 704 |
mux.HandleFunc(fmt.Sprintf("/%s.GetDefaultAddressSpaces", ipamapi.PluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
|
| 705 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 705 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 706 | 706 |
fmt.Fprintf(w, `{"LocalDefaultAddressSpace":"`+lAS+`", "GlobalDefaultAddressSpace": "`+gAS+`"}`)
|
| 707 | 707 |
}) |
| 708 | 708 |
|
| ... | ... |
@@ -712,7 +713,7 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr |
| 712 | 712 |
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest) |
| 713 | 713 |
return |
| 714 | 714 |
} |
| 715 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 715 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 716 | 716 |
if poolRequest.AddressSpace != lAS && poolRequest.AddressSpace != gAS {
|
| 717 | 717 |
fmt.Fprintf(w, `{"Error":"Unknown address space in pool request: `+poolRequest.AddressSpace+`"}`)
|
| 718 | 718 |
} else if poolRequest.Pool != "" && poolRequest.Pool != pool {
|
| ... | ... |
@@ -728,7 +729,7 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr |
| 728 | 728 |
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest) |
| 729 | 729 |
return |
| 730 | 730 |
} |
| 731 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 731 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 732 | 732 |
// make sure libnetwork is now querying on the expected pool id |
| 733 | 733 |
if addressRequest.PoolID != poolID {
|
| 734 | 734 |
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
| ... | ... |
@@ -745,7 +746,7 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr |
| 745 | 745 |
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest) |
| 746 | 746 |
return |
| 747 | 747 |
} |
| 748 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 748 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 749 | 749 |
// make sure libnetwork is now asking to release the expected address from the expected poolid |
| 750 | 750 |
if addressRequest.PoolID != poolID {
|
| 751 | 751 |
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|
| ... | ... |
@@ -762,7 +763,7 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr |
| 762 | 762 |
http.Error(w, "Unable to decode JSON payload: "+err.Error(), http.StatusBadRequest) |
| 763 | 763 |
return |
| 764 | 764 |
} |
| 765 |
- w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
|
| 765 |
+ w.Header().Set("Content-Type", plugins.VersionMimetype)
|
|
| 766 | 766 |
// make sure libnetwork is now asking to release the expected poolid |
| 767 | 767 |
if addressRequest.PoolID != poolID {
|
| 768 | 768 |
fmt.Fprintf(w, `{"Error":"unknown pool id"}`)
|