Skip to content

Commit 1e50190

Browse files
authored
Add detachDisk to the default policy for faster drain/deletes. (#657)
* Add detachDisk to the default policy for faster drain/deletes. * Generate sdk * Adjust tests to change * Adjust policy_test tests to change * Attempt to fix acc test
1 parent 325a2e5 commit 1e50190

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

castai/data_source_gke_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ func Test_dataSourceGKEPoliciesRead(t *testing.T) {
2525
loadBalancersTargetBackendPoolsFeature: true,
2626
loadBalancersUnmanagedInstanceGroupsFeature: true,
2727
},
28-
expected: 43, // -1 for the duplicate policy
28+
expected: 44, // -1 for the duplicate policy
2929
hasError: false,
3030
},
3131
{
3232
name: "loadBalancersTargetBackendPoolsFeature",
3333
features: map[string]bool{
3434
loadBalancersTargetBackendPoolsFeature: true,
3535
},
36-
expected: 42, // -1 for the duplicate policy
36+
expected: 43, // -1 for the duplicate policy
3737
hasError: false,
3838
},
3939
{
4040
name: "empty features",
41-
expected: 38,
41+
expected: 39,
4242
hasError: false,
4343
},
4444
}
@@ -85,14 +85,14 @@ func TestAccGKE_DataSourceGKEPolicies_basic(t *testing.T) {
8585
Check: resource.ComposeTestCheckFunc(
8686
resource.TestCheckResourceAttr("data.castai_gke_user_policies.gke", "features.load_balancers_target_backend_pools", "true"),
8787
resource.TestCheckResourceAttr("data.castai_gke_user_policies.gke", "features.load_balancers_unmanaged_instance_groups", "true"),
88-
resource.TestCheckResourceAttr("data.castai_gke_user_policies.gke", "policy.#", "43"),
88+
resource.TestCheckResourceAttr("data.castai_gke_user_policies.gke", "policy.#", "44"),
8989
),
9090
},
9191
{
9292
Config: testAccDataSourceGKEPoliciesConfigUpdated,
9393
Check: resource.ComposeTestCheckFunc(
9494
resource.TestCheckResourceAttr("data.castai_gke_user_policies.gke", "features.load_balancers_target_backend_pools", "true"),
95-
resource.TestCheckResourceAttr("data.castai_gke_user_policies.gke", "policy.#", "42"),
95+
resource.TestCheckResourceAttr("data.castai_gke_user_policies.gke", "policy.#", "43"),
9696
),
9797
},
9898
},

castai/policies/gke/iam-policy.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"compute.instances.setServiceAccount",
1515
"compute.instances.setMetadata",
1616
"compute.instances.setTags",
17+
"compute.instances.detachDisk",
1718
"compute.instanceGroupManagers.get",
1819
"compute.instanceGroupManagers.update",
1920
"compute.instanceGroups.get",

castai/policies/gke/policy_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package gke
22

33
import (
4-
"github.com/stretchr/testify/require"
54
"testing"
5+
6+
"github.com/stretchr/testify/require"
67
)
78

89
func TestPolicies(t *testing.T) {
@@ -21,7 +22,7 @@ func TestPolicies(t *testing.T) {
2122
if !contains(userpolicy, wantClustersGet) || !contains(userpolicy, wantZonesGet) {
2223
t.Fatalf("generated User policy document does not contain required policies")
2324
}
24-
require.Equal(t, 38, len(userpolicy))
25+
require.Equal(t, 39, len(userpolicy))
2526
})
2627
t.Run("LoadBalancersTargetBackendPools policy", func(t *testing.T) {
2728
lbTbpPolicy, err := GetLoadBalancersTargetBackendPoolsPolicy()

castai/sdk/api.gen.go

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)