Skip to content

Commit 9222cc9

Browse files
feat: add locks field to various resources (#942)
1 parent f77d904 commit 9222cc9

13 files changed

Lines changed: 27 additions & 2 deletions

instances.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ type Instance struct {
7575
InterfaceGeneration InterfaceGeneration `json:"interface_generation"`
7676
MaintenancePolicy string `json:"maintenance_policy"`
7777

78-
// NOTE: Locks can only be used with v4beta.
78+
// NOTE: Both cannot_delete and cannot_delete_with_subresources apply to Instances and can only be used with v4beta.
7979
Locks []LockType `json:"locks"`
8080
}
8181

lke_clusters.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ type LKECluster struct {
4747
SubnetID int `json:"subnet_id"`
4848
VpcID int `json:"vpc_id"`
4949
StackType LKEClusterStackType `json:"stack_type"`
50+
51+
// NOTE: Locks can only be used with v4beta.
52+
Locks []LockType `json:"locks"`
5053
}
5154

5255
// LKEClusterCreateOptions fields are those accepted by CreateLKECluster

lke_node_pools.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ type LKENodePool struct {
8383
// It may not currently be available to all users and is under v4beta.
8484
K8sVersion *string `json:"k8s_version,omitzero"`
8585
UpdateStrategy *LKENodePoolUpdateStrategy `json:"update_strategy,omitzero"`
86+
87+
// NOTE: Only cannot_delete applies to LKE node pools and can only be used with v4beta.
88+
Locks []LockType `json:"locks"`
8689
}
8790

8891
// LKENodePoolCreateOptions fields are those accepted by CreateLKENodePool

test/unit/fixtures/lke_cluster_get.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"label": "test-cluster",
44
"region": "us-east",
55
"status": "ready",
6+
"locks": ["cannot_delete"],
67
"subnet_id": 123,
78
"vpc_id": 456,
89
"stack_type": "ipv4",

test/unit/fixtures/lke_cluster_list.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"label": "test-cluster",
66
"region": "us-east",
77
"status": "ready",
8+
"locks": ["cannot_delete"],
89
"subnet_id": 123,
910
"vpc_id": 456,
1011
"stack_type": "ipv4",
@@ -16,7 +17,8 @@
1617
"id": 124,
1718
"label": "second-cluster",
1819
"region": "us-west",
19-
"status": "not_ready"
20+
"status": "not_ready",
21+
"locks": []
2022
}
2123
],
2224
"pages": 1,

test/unit/fixtures/lke_node_pool_get.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"id": 456,
33
"count": 3,
44
"type": "g6-standard-2",
5+
"locks": ["cannot_delete"],
56
"tags": ["tag1", "tag2"],
67
"labels": {"env": "staging"},
78
"autoscaler": {

test/unit/fixtures/lke_node_pool_list.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"id": 456,
55
"count": 3,
66
"type": "g6-standard-2",
7+
"locks": ["cannot_delete"],
78
"tags": ["tag1"],
89
"labels": {"env": "staging"},
910
"autoscaler": {"enabled": true, "min": 1, "max": 5}
@@ -12,6 +13,7 @@
1213
"id": 789,
1314
"count": 2,
1415
"type": "g6-standard-4",
16+
"locks": [],
1517
"tags": ["tag2"],
1618
"labels": {"env": "prod"},
1719
"autoscaler": {"enabled": false, "min": 0, "max": 0}

test/unit/fixtures/volume_get.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"linode_id": null,
88
"filesystem_path": "",
99
"tags": ["test"],
10+
"locks": ["cannot_delete_with_subresources"],
1011
"hardware_type": "",
1112
"linode_label": "",
1213
"encryption": "",

test/unit/fixtures/volumes_list.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"linode_id": null,
1010
"filesystem_path": "",
1111
"tags": ["test"],
12+
"locks": ["cannot_delete"],
1213
"hardware_type": "",
1314
"linode_label": "",
1415
"encryption": "",

test/unit/lke_clusters_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ func TestLKECluster_List(t *testing.T) {
6565
assert.Equal(t, 123, clusters[0].SubnetID)
6666
assert.Equal(t, 456, clusters[0].VpcID)
6767
assert.Equal(t, linodego.LKEClusterStackIPv4, clusters[0].StackType)
68+
assert.Equal(t, []linodego.LockType{linodego.LockTypeCannotDelete}, clusters[0].Locks)
6869
assert.Equal(t, false, clusters[0].ControlPlane.AuditLogsEnabled)
70+
assert.Empty(t, clusters[1].Locks)
6971
}
7072

7173
func TestLKECluster_Get(t *testing.T) {
@@ -85,6 +87,7 @@ func TestLKECluster_Get(t *testing.T) {
8587
assert.Equal(t, 123, cluster.SubnetID)
8688
assert.Equal(t, 456, cluster.VpcID)
8789
assert.Equal(t, linodego.LKEClusterStackIPv4, cluster.StackType)
90+
assert.Equal(t, []linodego.LockType{linodego.LockTypeCannotDelete}, cluster.Locks)
8891
assert.Equal(t, false, cluster.ControlPlane.AuditLogsEnabled)
8992
}
9093

0 commit comments

Comments
 (0)