@@ -23,16 +23,19 @@ import (
23
23
24
24
types100 "github.com/containernetworking/cni/pkg/types/100"
25
25
"gotest.tools/v3/assert"
26
+
27
+ "github.com/containerd/nerdctl/v2/pkg/netutil"
26
28
)
27
29
28
30
func TestCreateLine (t * testing.T ) {
29
31
type testCase struct {
30
- thatIP string
31
- thatNetwork string
32
- thatHostname string // nerdctl run --hostname
33
- thatName string // nerdctl run --name
34
- myNetwork string
35
- expected string
32
+ thatIP string
33
+ thatNetwork string
34
+ thatHostname string // nerdctl run --hostname
35
+ thatDomainname string // nerdctl run --domainname
36
+ thatName string // nerdctl run --name
37
+ myNetwork string
38
+ expected string
36
39
}
37
40
testCases := []testCase {
38
41
{
@@ -52,7 +55,7 @@ func TestCreateLine(t *testing.T) {
52
55
},
53
56
{
54
57
thatIP : "10.4.2.4" ,
55
- thatNetwork : "bridge" ,
58
+ thatNetwork : netutil . DefaultNetworkName ,
56
59
thatHostname : "bar" ,
57
60
myNetwork : "n1" ,
58
61
expected : "" ,
@@ -61,7 +64,7 @@ func TestCreateLine(t *testing.T) {
61
64
thatIP : "10.4.2.5" ,
62
65
thatNetwork : "n1" ,
63
66
thatName : "foo" ,
64
- myNetwork : "bridge" ,
67
+ myNetwork : netutil . DefaultNetworkName ,
65
68
expected : "" ,
66
69
},
67
70
{
@@ -71,6 +74,46 @@ func TestCreateLine(t *testing.T) {
71
74
myNetwork : "n2" ,
72
75
expected : "" ,
73
76
},
77
+ {
78
+ thatIP : "10.4.2.3" ,
79
+ thatNetwork : "n1" ,
80
+ thatHostname : "bar.example.com" , // using a fqdn as hostname
81
+ myNetwork : "n1" ,
82
+ expected : "bar.example.com bar.example.com.n1" ,
83
+ },
84
+ {
85
+ thatIP : "10.4.2.7" ,
86
+ thatNetwork : "n1" ,
87
+ thatHostname : "bar" , // unqualified hostname with separate domain name
88
+ thatName : "foo" ,
89
+ thatDomainname : "example.com" ,
90
+ myNetwork : "n1" ,
91
+ expected : "bar.example.com bar bar.n1 foo foo.n1" ,
92
+ },
93
+ {
94
+ thatIP : "10.4.2.8" ,
95
+ thatNetwork : "n1" ,
96
+ thatHostname : "bar" ,
97
+ thatDomainname : "example.com" ,
98
+ myNetwork : "n1" ,
99
+ expected : "bar.example.com bar bar.n1" ,
100
+ },
101
+ {
102
+ thatIP : "10.4.2.9" ,
103
+ thatNetwork : netutil .DefaultNetworkName ,
104
+ thatHostname : "bar" ,
105
+ thatDomainname : "example.com" ,
106
+ myNetwork : netutil .DefaultNetworkName ,
107
+ expected : "bar.example.com bar" ,
108
+ },
109
+ {
110
+ thatIP : "10.4.2.9" ,
111
+ thatNetwork : netutil .DefaultNetworkName ,
112
+ thatHostname : "bar.example.com" ,
113
+ thatDomainname : "example.com" ,
114
+ myNetwork : netutil .DefaultNetworkName ,
115
+ expected : "bar.example.com.example.com bar.example.com" ,
116
+ },
74
117
}
75
118
for _ , tc := range testCases {
76
119
thatMeta := & Meta {
@@ -89,8 +132,9 @@ func TestCreateLine(t *testing.T) {
89
132
},
90
133
},
91
134
},
92
- Hostname : tc .thatHostname ,
93
- Name : tc .thatName ,
135
+ Hostname : tc .thatHostname ,
136
+ Domainname : tc .thatDomainname ,
137
+ Name : tc .thatName ,
94
138
}
95
139
96
140
myNetworks := map [string ]struct {}{
0 commit comments