forked from AliyunContainerService/terway
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpod.go
48 lines (39 loc) · 749 Bytes
/
pod.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package node
import (
"net/netip"
networkv1beta1 "github.com/AliyunContainerService/terway/pkg/apis/network.alibabacloud.com/v1beta1"
)
type PodRequest struct {
// requirements
PodUID string
RequireIPv4 bool
RequireIPv6 bool
RequireERDMA bool
// status
IPv4 string
IPv6 string
// ref for eni & ip
ipv4Ref, ipv6Ref *EniIP
}
type EniIP struct {
NetworkInterface *networkv1beta1.NetworkInterface
IP *networkv1beta1.IP
}
func podIPs(ips []string) (string, string, error) {
var ipv4, ipv6 string
for _, v := range ips {
if v == "" {
continue
}
addr, err := netip.ParseAddr(v)
if err != nil {
return "", "", err
}
if addr.Is4() {
ipv4 = v
} else {
ipv6 = v
}
}
return ipv4, ipv6, nil
}