Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions pkg/hns/endpoint_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
package hns

import (
"github.com/Microsoft/hcsshim"
"github.com/containernetworking/cni/pkg/types/current"
"fmt"
"log"
"net"
"strings"

"github.com/Microsoft/hcsshim"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you run gofmt?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rakelkar

I changed these codes in the vscode editor. It looks like that my editor auto run the gofmt command for me.
should I manually make it recover as before?

"github.com/containernetworking/cni/pkg/types/current"
)

// ConstructEndpointName constructs enpointId which is used to identify an endpoint from HNS
Expand Down Expand Up @@ -123,7 +125,17 @@ func ConstructResult(hnsNetwork *hcsshim.HNSNetwork, hnsEndpoint *hcsshim.HNSEnd
return nil, err
}

var ipVersion string
if ipv4 := hnsEndpoint.IPAddress.To4(); ipv4 != nil {
ipVersion = "4"
} else if ipv6 := hnsEndpoint.IPAddress.To16(); ipv6 != nil {
ipVersion = "6"
} else {
return nil, fmt.Errorf("[win-cni] The IPAddress of hnsEndpoint isn't a valid ipv4 or ipv6 Address.")
}

resultIPConfig := &current.IPConfig{
Version: ipVersion,
Address: net.IPNet{
IP: hnsEndpoint.IPAddress,
Mask: ipSubnet.Mask},
Expand Down