Browse Source

Replace use of deprecated functions

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 4 years ago
parent
commit
bf28003c99

+ 3 - 3
libnetwork/drivers/windows/overlay/ov_endpoint_windows.go

@@ -7,7 +7,7 @@ import (
 	"sync"
 
 	"github.com/Microsoft/hcsshim"
-	"github.com/docker/docker/pkg/system"
+	"github.com/Microsoft/hcsshim/osversion"
 	"github.com/docker/libnetwork/driverapi"
 	"github.com/docker/libnetwork/drivers/windows"
 	"github.com/docker/libnetwork/netlabel"
@@ -34,7 +34,7 @@ var (
 	//Server 2016 (RS1) does not support concurrent add/delete of endpoints.  Therefore, we need
 	//to use this mutex and serialize the add/delete of endpoints on RS1.
 	endpointMu   sync.Mutex
-	windowsBuild = system.GetOSVersion().Build
+	windowsBuild = osversion.Build()
 )
 
 func validateID(nid, eid string) error {
@@ -155,7 +155,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
 
 	hnsEndpoint.Policies = append(hnsEndpoint.Policies, paPolicy)
 
-	if system.GetOSVersion().Build > 16236 {
+	if osversion.Build() > 16236 {
 		natPolicy, err := json.Marshal(hcsshim.PaPolicy{
 			Type: "OutBoundNAT",
 		})

+ 2 - 2
libnetwork/drivers/windows/windows.go

@@ -20,7 +20,7 @@ import (
 	"sync"
 
 	"github.com/Microsoft/hcsshim"
-	"github.com/docker/docker/pkg/system"
+	"github.com/Microsoft/hcsshim/osversion"
 	"github.com/docker/libnetwork/datastore"
 	"github.com/docker/libnetwork/discoverapi"
 	"github.com/docker/libnetwork/driverapi"
@@ -217,7 +217,7 @@ func (d *driver) parseNetworkOptions(id string, genericOptions map[string]string
 			}
 			config.VSID = uint(vsid)
 		case EnableOutboundNat:
-			if system.GetOSVersion().Build <= 16236 {
+			if osversion.Build() <= 16236 {
 				return nil, fmt.Errorf("Invalid network option. OutboundNat is not supported on this OS version")
 			}
 			b, err := strconv.ParseBool(value)

+ 1 - 1
libnetwork/firewall_test.go

@@ -2,13 +2,13 @@ package libnetwork
 
 import (
 	"fmt"
-	"gotest.tools/assert"
 	"strings"
 	"testing"
 
 	"github.com/docker/libnetwork/iptables"
 	"github.com/docker/libnetwork/netlabel"
 	"github.com/docker/libnetwork/options"
+	"gotest.tools/assert"
 )
 
 const (

+ 3 - 3
libnetwork/service_windows.go

@@ -4,7 +4,7 @@ import (
 	"net"
 
 	"github.com/Microsoft/hcsshim"
-	"github.com/docker/docker/pkg/system"
+	"github.com/Microsoft/hcsshim/osversion"
 	"github.com/sirupsen/logrus"
 )
 
@@ -27,7 +27,7 @@ func (n *network) addLBBackend(ip net.IP, lb *loadBalancer) {
 	vip := lb.vip
 	ingressPorts := lb.service.ingressPorts
 
-	if system.GetOSVersion().Build > 16236 {
+	if osversion.Build() > 16236 {
 		lb.Lock()
 		defer lb.Unlock()
 		//find the load balancer IP for the network.
@@ -128,7 +128,7 @@ func (n *network) rmLBBackend(ip net.IP, lb *loadBalancer, rmService bool, fullR
 		return
 	}
 
-	if system.GetOSVersion().Build > 16236 {
+	if osversion.Build() > 16236 {
 		if numEnabledBackends(lb) > 0 {
 			//Reprogram HNS (actually VFP) with the existing backends.
 			n.addLBBackend(ip, lb)