Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type Instance struct {
InterfaceGeneration InterfaceGeneration `json:"interface_generation"`
MaintenancePolicy string `json:"maintenance_policy"`

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

Expand Down
3 changes: 3 additions & 0 deletions lke_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ type LKECluster struct {
SubnetID int `json:"subnet_id"`
VpcID int `json:"vpc_id"`
StackType LKEClusterStackType `json:"stack_type"`

// NOTE: Locks can only be used with v4beta.
Locks []LockType `json:"locks"`
}

// LKEClusterCreateOptions fields are those accepted by CreateLKECluster
Expand Down
3 changes: 3 additions & 0 deletions lke_node_pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ type LKENodePool struct {
// It may not currently be available to all users and is under v4beta.
K8sVersion *string `json:"k8s_version,omitempty"`
UpdateStrategy *LKENodePoolUpdateStrategy `json:"update_strategy,omitempty"`

// NOTE: Only cannot_delete applies to LKE node pools and can only be used with v4beta.
Locks []LockType `json:"locks"`
}

// LKENodePoolCreateOptions fields are those accepted by CreateLKENodePool
Expand Down
1 change: 1 addition & 0 deletions test/unit/fixtures/lke_cluster_get.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"label": "test-cluster",
"region": "us-east",
"status": "ready",
"locks": ["cannot_delete"],
"subnet_id": 123,
"vpc_id": 456,
"stack_type": "ipv4",
Expand Down
4 changes: 3 additions & 1 deletion test/unit/fixtures/lke_cluster_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"label": "test-cluster",
"region": "us-east",
"status": "ready",
"locks": ["cannot_delete"],
"subnet_id": 123,
"vpc_id": 456,
"stack_type": "ipv4",
Expand All @@ -16,7 +17,8 @@
"id": 124,
"label": "second-cluster",
"region": "us-west",
"status": "not_ready"
"status": "not_ready",
"locks": []
}
],
"pages": 1,
Expand Down
1 change: 1 addition & 0 deletions test/unit/fixtures/lke_node_pool_get.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"id": 456,
"count": 3,
"type": "g6-standard-2",
"locks": ["cannot_delete"],
"tags": ["tag1", "tag2"],
"labels": {"env": "staging"},
"autoscaler": {
Expand Down
2 changes: 2 additions & 0 deletions test/unit/fixtures/lke_node_pool_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"id": 456,
"count": 3,
"type": "g6-standard-2",
"locks": ["cannot_delete"],
"tags": ["tag1"],
"labels": {"env": "staging"},
"autoscaler": {"enabled": true, "min": 1, "max": 5}
Expand All @@ -12,6 +13,7 @@
"id": 789,
"count": 2,
"type": "g6-standard-4",
"locks": [],
"tags": ["tag2"],
"labels": {"env": "prod"},
"autoscaler": {"enabled": false, "min": 0, "max": 0}
Expand Down
1 change: 1 addition & 0 deletions test/unit/fixtures/volume_get.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"linode_id": null,
"filesystem_path": "",
"tags": ["test"],
"locks": ["cannot_delete_with_subresources"],
"hardware_type": "",
"linode_label": "",
"encryption": "",
Expand Down
1 change: 1 addition & 0 deletions test/unit/fixtures/volumes_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"linode_id": null,
"filesystem_path": "",
"tags": ["test"],
"locks": ["cannot_delete"],
"hardware_type": "",
"linode_label": "",
"encryption": "",
Expand Down
3 changes: 3 additions & 0 deletions test/unit/lke_clusters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ func TestLKECluster_List(t *testing.T) {
assert.Equal(t, 123, clusters[0].SubnetID)
assert.Equal(t, 456, clusters[0].VpcID)
assert.Equal(t, linodego.LKEClusterStackIPv4, clusters[0].StackType)
assert.Equal(t, []linodego.LockType{linodego.LockTypeCannotDelete}, clusters[0].Locks)
assert.Equal(t, false, clusters[0].ControlPlane.AuditLogsEnabled)
assert.Empty(t, clusters[1].Locks)
}

func TestLKECluster_Get(t *testing.T) {
Expand All @@ -85,6 +87,7 @@ func TestLKECluster_Get(t *testing.T) {
assert.Equal(t, 123, cluster.SubnetID)
assert.Equal(t, 456, cluster.VpcID)
assert.Equal(t, linodego.LKEClusterStackIPv4, cluster.StackType)
assert.Equal(t, []linodego.LockType{linodego.LockTypeCannotDelete}, cluster.Locks)
assert.Equal(t, false, cluster.ControlPlane.AuditLogsEnabled)
}

Expand Down
3 changes: 3 additions & 0 deletions test/unit/lke_node_pools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func TestLKENodePool_Get(t *testing.T) {
assert.Equal(t, "g6-standard-2", nodePool.Type)
assert.Equal(t, 3, nodePool.Count)
assert.Equal(t, []string{"tag1", "tag2"}, nodePool.Tags)
assert.Equal(t, []linodego.LockType{linodego.LockTypeCannotDelete}, nodePool.Locks)
}

func TestLKENodePool_Create(t *testing.T) {
Expand Down Expand Up @@ -172,7 +173,9 @@ func TestLKENodePool_List(t *testing.T) {
assert.NoError(t, err)
assert.Len(t, nodePools, 2)
assert.Equal(t, 456, nodePools[0].ID)
assert.Equal(t, []linodego.LockType{linodego.LockTypeCannotDelete}, nodePools[0].Locks)
assert.Equal(t, 789, nodePools[1].ID)
assert.Empty(t, nodePools[1].Locks)
}

func TestLKENodePoolNode_Delete(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions test/unit/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestListVolumes(t *testing.T) {
assert.Equal(t, "us-east", volumes[0].Region, "Expected volume region to match")
assert.Equal(t, 20, volumes[0].Size, "Expected volume size to match")
assert.Equal(t, "test", volumes[0].Tags[0], "Expected volume tag to match")
assert.Equal(t, []linodego.LockType{linodego.LockTypeCannotDelete}, volumes[0].Locks, "Expected volume locks to match")
}

func TestGetVolume(t *testing.T) {
Expand Down Expand Up @@ -59,6 +60,7 @@ func TestGetVolume(t *testing.T) {
assert.Empty(t, volume.HardwareType, "Expected hardware type to be empty")
assert.Empty(t, volume.LinodeLabel, "Expected Linode label to be empty")
assert.True(t, volume.IOReady, "Expected IO Ready true")
assert.Equal(t, []linodego.LockType{linodego.LockTypeCannotDeleteWithSubresources}, volume.Locks, "Expected volume locks to match")
}

func TestCreateVolume(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type Volume struct {
Created *time.Time `json:"-"`
Updated *time.Time `json:"-"`
Encryption string `json:"encryption"`

// NOTE: Locks can only be used with v4beta.
Locks []LockType `json:"locks"`
}

// VolumeCreateOptions fields are those accepted by CreateVolume
Expand Down
Loading