Skip to content

Commit

Permalink
refactor(win-bridge): netconf
Browse files Browse the repository at this point in the history
- support v2 api
- unify v1 and v2 api

BREAKING CHANGE:
- remove `HcnPolicyArgs` field
- merge `HcnPolicyArgs` into `Policies` field

Signed-off-by: thxcode <[email protected]>
  • Loading branch information
thxCode committed Apr 19, 2021
1 parent 1927832 commit 222fe58
Show file tree
Hide file tree
Showing 8 changed files with 695 additions and 192 deletions.
13 changes: 4 additions & 9 deletions pkg/hns/endpoint_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func GenerateHnsEndpoint(epInfo *EndpointInfo, n *NetConf) (*hcsshim.HNSEndpoint
}

if n.LoopbackDSR {
n.ApplyLoopbackDSR(&epInfo.IpAddress)
n.ApplyLoopbackDSRPolicy(&epInfo.IpAddress)
}
hnsEndpoint = &hcsshim.HNSEndpoint{
Name: epInfo.EndpointName,
Expand All @@ -104,7 +104,7 @@ func GenerateHnsEndpoint(epInfo *EndpointInfo, n *NetConf) (*hcsshim.HNSEndpoint
DNSSuffix: strings.Join(epInfo.DNS.Search, ","),
GatewayAddress: GetIpString(&epInfo.Gateway),
IPAddress: epInfo.IpAddress,
Policies: n.MarshalPolicies(),
Policies: n.GetHNSEndpointPolicies(),
}
return hnsEndpoint, nil
}
Expand Down Expand Up @@ -240,7 +240,7 @@ func GenerateHcnEndpoint(epInfo *EndpointInfo, n *NetConf) (*hcn.HostComputeEndp
}

if n.LoopbackDSR {
n.ApplyLoopbackDSR(&epInfo.IpAddress)
n.ApplyLoopbackDSRPolicy(&epInfo.IpAddress)
}
hcnEndpoint = &hcn.HostComputeEndpoint{
SchemaVersion: hcn.SchemaVersion{
Expand All @@ -266,12 +266,7 @@ func GenerateHcnEndpoint(epInfo *EndpointInfo, n *NetConf) (*hcn.HostComputeEndp
IpAddress: GetIpString(&epInfo.IpAddress),
},
},
Policies: func() []hcn.EndpointPolicy {
if n.HcnPolicyArgs == nil {
n.HcnPolicyArgs = []hcn.EndpointPolicy{}
}
return n.HcnPolicyArgs
}(),
Policies: n.GetHostComputeEndpointPolicies(),
}
return hcnEndpoint, nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/hns/netconf_suite_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"testing"
)

func TestHns(t *testing.T) {
func TestNetConf(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "HNS NetConf Suite")
RunSpecs(t, "NetConf Suite")
}
Loading

0 comments on commit 222fe58

Please sign in to comment.