|
@@ -4,10 +4,11 @@ import (
|
|
|
"fmt"
|
|
|
"net"
|
|
|
|
|
|
+ "github.com/docker/docker/pkg/plugingetter"
|
|
|
+ "github.com/docker/libnetwork/driverapi"
|
|
|
"github.com/docker/libnetwork/ipamapi"
|
|
|
"github.com/docker/swarmkit/api"
|
|
|
"github.com/docker/swarmkit/identity"
|
|
|
- "github.com/docker/swarmkit/manager/allocator/networkallocator"
|
|
|
"github.com/docker/swarmkit/manager/state/store"
|
|
|
"golang.org/x/net/context"
|
|
|
"google.golang.org/grpc"
|
|
@@ -49,14 +50,14 @@ func validateIPAMConfiguration(ipamConf *api.IPAMConfig) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func validateIPAM(ipam *api.IPAMOptions) error {
|
|
|
+func validateIPAM(ipam *api.IPAMOptions, pg plugingetter.PluginGetter) error {
|
|
|
if ipam == nil {
|
|
|
// It is ok to not specify any IPAM configurations. We
|
|
|
// will choose good defaults.
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
- if err := validateDriver(ipam.Driver, ipamapi.DefaultIPAM); err != nil {
|
|
|
+ if err := validateDriver(ipam.Driver, pg, ipamapi.PluginEndpointType); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
@@ -69,7 +70,7 @@ func validateIPAM(ipam *api.IPAMOptions) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func validateNetworkSpec(spec *api.NetworkSpec) error {
|
|
|
+func validateNetworkSpec(spec *api.NetworkSpec, pg plugingetter.PluginGetter) error {
|
|
|
if spec == nil {
|
|
|
return grpc.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
|
|
|
}
|
|
@@ -78,11 +79,11 @@ func validateNetworkSpec(spec *api.NetworkSpec) error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- if err := validateDriver(spec.DriverConfig, networkallocator.DefaultDriver); err != nil {
|
|
|
+ if err := validateDriver(spec.DriverConfig, pg, driverapi.NetworkPluginEndpointType); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- if err := validateIPAM(spec.IPAM); err != nil {
|
|
|
+ if err := validateIPAM(spec.IPAM, pg); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
@@ -95,7 +96,7 @@ func validateNetworkSpec(spec *api.NetworkSpec) error {
|
|
|
func (s *Server) CreateNetwork(ctx context.Context, request *api.CreateNetworkRequest) (*api.CreateNetworkResponse, error) {
|
|
|
// if you change this function, you have to change createInternalNetwork in
|
|
|
// the tests to match it (except the part where we check the label).
|
|
|
- if err := validateNetworkSpec(request.Spec); err != nil {
|
|
|
+ if err := validateNetworkSpec(request.Spec, s.pg); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|