Skip to content

Commit

Permalink
Add const for the subnetwork in test and brief info on it.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsonov committed Aug 15, 2024
1 parent 9e26a11 commit 8f5d29a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions castai/resource_node_configuration_gke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

const (
// acceptanceTestClusterSubnetworkName points to the subnet that the acceptance test cluster uses.
// Actual value (should) be managed by our IaC repository and could be shared with other clusters as well.
acceptanceTestClusterSubnetworkName = "ext-prov-e2e-shared-ip-range-nodes'"
)

func TestAccResourceNodeConfiguration_gke(t *testing.T) {
rName := fmt.Sprintf("%v-node-cfg-%v", ResourcePrefix, acctest.RandString(8))
resourceName := "castai_node_configuration.test"
Expand Down Expand Up @@ -127,14 +133,15 @@ resource "castai_gke_cluster" "test" {
}

func testAccGCPConfig(rName, clusterName, projectID string) string {

return fmt.Sprintf(`
locals {
service_account_id = %[3]q
cluster_name = %[1]q
service_account_email = "${local.service_account_id}@$%[2]s.iam.gserviceaccount.com"
custom_role_id = "castai.tfAcc.${substr(sha1(local.service_account_id),0,8)}.tf"
subnet_id = "projects/%[2]s/regions/us-central1/subnetworks/ext-prov-e2e-shared-ip-range-nodes"
subnet_id = "projects/%[2]s/regions/us-central1/subnetworks/%[4]s"
}
resource "google_service_account" "castai_service_account" {
Expand Down Expand Up @@ -177,5 +184,5 @@ resource "google_service_account_key" "castai_key" {
public_key_type = "TYPE_X509_PEM_FILE"
}
`, clusterName, projectID, rName)
`, clusterName, projectID, rName, acceptanceTestClusterSubnetworkName)
}

0 comments on commit 8f5d29a

Please sign in to comment.