Skip to content

Commit 93a9069

Browse files
committed
devices: add connectedToControl field on device resource
Updates tailscale/corp#31905 Signed-off-by: mcoulombe <[email protected]>
1 parent 04111c4 commit 93a9069

File tree

3 files changed

+68
-12
lines changed

3 files changed

+68
-12
lines changed

devices.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ type Device struct {
8383
Hostname string `json:"hostname"`
8484
IsEphemeral bool `json:"isEphemeral"`
8585
IsExternal bool `json:"isExternal"`
86+
ConnectedToControl bool `json:"connectedToControl"`
8687
LastSeen Time `json:"lastSeen"`
8788
MachineKey string `json:"machineKey"`
8889
NodeKey string `json:"nodeKey"`

devices_test.go

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func TestClient_Devices_Get(t *testing.T) {
5757
Expires: Time{time.Date(2022, 8, 9, 11, 50, 23, 0, time.UTC)},
5858
Hostname: "test",
5959
IsExternal: false,
60+
ConnectedToControl: false,
6061
LastSeen: Time{time.Date(2022, 3, 9, 20, 3, 42, 0, time.UTC)},
6162
MachineKey: "mkey:test",
6263
NodeKey: "nodekey:test",
@@ -165,6 +166,7 @@ func TestClient_Devices_List(t *testing.T) {
165166
Hostname: "test",
166167
IsEphemeral: false,
167168
IsExternal: false,
169+
ConnectedToControl: false,
168170
LastSeen: Time{time.Date(2022, 3, 9, 20, 3, 42, 0, time.UTC)},
169171
MachineKey: "mkey:test",
170172
NodeKey: "nodekey:test",
@@ -233,12 +235,13 @@ func TestDevices_Unmarshal(t *testing.T) {
233235
Expires: Time{
234236
time.Date(1, 1, 1, 00, 00, 00, 0, time.UTC),
235237
},
236-
Hostname: "hello",
237-
ID: "50052",
238-
NodeID: "nTESTJ30",
239-
IsEphemeral: false,
240-
IsExternal: true,
241-
KeyExpiryDisabled: true,
238+
Hostname: "hello",
239+
ID: "50052",
240+
NodeID: "nTESTJ30",
241+
IsEphemeral: false,
242+
IsExternal: true,
243+
KeyExpiryDisabled: true,
244+
ConnectedToControl: false,
242245
LastSeen: Time{
243246
time.Date(2022, 4, 15, 13, 24, 40, 0, time.UTC),
244247
},
@@ -260,12 +263,13 @@ func TestDevices_Unmarshal(t *testing.T) {
260263
Expires: Time{
261264
time.Date(2022, 9, 1, 17, 10, 27, 0, time.UTC),
262265
},
263-
Hostname: "foo",
264-
ID: "50053",
265-
NodeID: "nTESTJ31",
266-
IsEphemeral: true,
267-
IsExternal: false,
268-
KeyExpiryDisabled: true,
266+
Hostname: "foo",
267+
ID: "50053",
268+
NodeID: "nTESTJ31",
269+
IsEphemeral: true,
270+
IsExternal: false,
271+
KeyExpiryDisabled: true,
272+
ConnectedToControl: false,
269273
LastSeen: Time{
270274
time.Date(2022, 4, 15, 13, 25, 21, 0, time.UTC),
271275
},
@@ -276,6 +280,31 @@ func TestDevices_Unmarshal(t *testing.T) {
276280
UpdateAvailable: false,
277281
278282
},
283+
{
284+
Addresses: []string{"100.69.123.1", "fd7a:115c:a1e0:ab12:4843:cd96:6265:e618"},
285+
Authorized: true,
286+
BlocksIncomingConnections: false,
287+
ClientVersion: "1.22.2-t60b671955-gecc5d9846",
288+
Created: Time{
289+
time.Date(2022, 3, 5, 17, 10, 27, 0, time.UTC),
290+
},
291+
Expires: Time{
292+
time.Date(2022, 9, 1, 17, 10, 27, 0, time.UTC),
293+
},
294+
Hostname: "foo",
295+
ID: "50053",
296+
NodeID: "nTESTJ31",
297+
IsEphemeral: true,
298+
IsExternal: false,
299+
KeyExpiryDisabled: true,
300+
ConnectedToControl: true,
301+
MachineKey: "mkey:30dc3c061ac8b33fdc6d88a4a67b053b01b56930d78cae0cf7a164411d424c0d",
302+
Name: "foo.example.com",
303+
NodeKey: "nodekey:30dc3c061ac8b33fdc6d88a4a67b053b01b56930d78cae0cf7a164411d424c0d",
304+
OS: "linux",
305+
UpdateAvailable: false,
306+
307+
},
279308
},
280309
},
281310
}

testdata/devices.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"isEphemeral": false,
1717
"isExternal": true,
1818
"keyExpiryDisabled": true,
19+
"connectedToControl": false,
1920
"lastSeen": "2022-04-15T13:24:40Z",
2021
"machineKey": "",
2122
"name": "hello.example.com",
@@ -40,13 +41,38 @@
4041
"isEphemeral": true,
4142
"isExternal": false,
4243
"keyExpiryDisabled": true,
44+
"connectedToControl": false,
4345
"lastSeen": "2022-04-15T13:25:21Z",
4446
"machineKey": "mkey:30dc3c061ac8b33fdc6d88a4a67b053b01b56930d78cae0cf7a164411d424c0d",
4547
"name": "foo.example.com",
4648
"nodeKey": "nodekey:30dc3c061ac8b33fdc6d88a4a67b053b01b56930d78cae0cf7a164411d424c0d",
4749
"os": "linux",
4850
"updateAvailable": false,
4951
52+
},
53+
{
54+
"addresses": [
55+
"100.69.123.1",
56+
"fd7a:115c:a1e0:ab12:4843:cd96:6265:e618"
57+
],
58+
"authorized": true,
59+
"blocksIncomingConnections": false,
60+
"clientVersion": "1.22.2-t60b671955-gecc5d9846",
61+
"created": "2022-03-05T17:10:27Z",
62+
"expires": "2022-09-01T17:10:27Z",
63+
"hostname": "foo",
64+
"id": "50053",
65+
"nodeId": "nTESTJ31",
66+
"isEphemeral": true,
67+
"isExternal": false,
68+
"keyExpiryDisabled": true,
69+
"connectedToControl": true,
70+
"machineKey": "mkey:30dc3c061ac8b33fdc6d88a4a67b053b01b56930d78cae0cf7a164411d424c0d",
71+
"name": "foo.example.com",
72+
"nodeKey": "nodekey:30dc3c061ac8b33fdc6d88a4a67b053b01b56930d78cae0cf7a164411d424c0d",
73+
"os": "linux",
74+
"updateAvailable": false,
75+
5076
}
5177
]
5278
}

0 commit comments

Comments
 (0)