Skip to content

Commit

Permalink
Fixed gradually deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jayctran committed Jun 18, 2024
1 parent 070de52 commit 0ec8499
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,20 @@ func (r ArcKubernetesFluxConfigurationResource) azureBlobWithServicePrincipalSec
return fmt.Sprintf(`
%[1]s
provider "azuread" {}
resource "azuread_application" "test" {
display_name = "acctestspa-%[2]d"
}
resource "azuread_service_principal" "test" {
application_id = azuread_application.test.application_id
}
resource "azuread_service_principal_password" "test" {
service_principal_id = azuread_service_principal.test.object_id
}
resource "azurerm_storage_account" "test" {
name = "sa%[2]d"
resource_group_name = azurerm_resource_group.test.name
Expand All @@ -537,13 +551,13 @@ data "azurerm_client_config" "test" {
resource "azurerm_role_assignment" "test_queue" {
scope = azurerm_storage_account.test.id
role_definition_name = "Storage Queue Data Contributor"
principal_id = data.azurerm_client_config.test.object_id
principal_id = azuread_service_principal.test.object_id
}
resource "azurerm_role_assignment" "test_blob" {
scope = azurerm_storage_account.test.id
role_definition_name = "Storage Blob Data Contributor"
principal_id = data.azurerm_client_config.test.object_id
principal_id = azuread_service_principal.test.object_id
}
resource "azurerm_arc_kubernetes_flux_configuration" "test" {
Expand All @@ -554,9 +568,9 @@ resource "azurerm_arc_kubernetes_flux_configuration" "test" {
blob_storage {
container_id = azurerm_storage_container.test.id
service_principal {
client_id = "%[3]s"
tenant_id = "%[4]s"
client_secret = "%[5]s"
client_id = azuread_service_principal.test.client_id
tenant_id = data.azurerm_client_config.test.tenant_id
client_secret = azuread_service_principal_password.test.value
}
}
Expand All @@ -570,13 +584,23 @@ resource "azurerm_arc_kubernetes_flux_configuration" "test" {
azurerm_role_assignment.test_blob
]
}
`, r.template(data, credential, privateKey, publicKey), data.RandomInteger, os.Getenv("ARM_CLIENT_ID"), os.Getenv("ARM_TENANT_ID"), os.Getenv("ARM_CLIENT_SECRET"))
`, r.template(data, credential, privateKey, publicKey), data.RandomInteger)
}

func (r ArcKubernetesFluxConfigurationResource) azureBlobWithServicePrincipalCertificate(data acceptance.TestData, credential string, privateKey string, publicKey string) string {
return fmt.Sprintf(`
%[1]s
provider "azuread" {}
resource "azuread_application" "test" {
display_name = "acctestspa-%[2]d"
}
resource "azuread_service_principal" "test" {
application_id = azuread_application.test.application_id
}
resource "azurerm_storage_account" "test" {
name = "sa%[2]d"
resource_group_name = azurerm_resource_group.test.name
Expand All @@ -597,13 +621,13 @@ data "azurerm_client_config" "test" {
resource "azurerm_role_assignment" "test_queue" {
scope = azurerm_storage_account.test.id
role_definition_name = "Storage Queue Data Contributor"
principal_id = data.azurerm_client_config.test.object_id
principal_id = azuread_service_principal.test.object_id
}
resource "azurerm_role_assignment" "test_blob" {
scope = azurerm_storage_account.test.id
role_definition_name = "Storage Blob Data Contributor"
principal_id = data.azurerm_client_config.test.object_id
principal_id = azuread_service_principal.test.object_id
}
resource "azurerm_arc_kubernetes_flux_configuration" "test" {
Expand All @@ -614,10 +638,10 @@ resource "azurerm_arc_kubernetes_flux_configuration" "test" {
blob_storage {
container_id = azurerm_storage_container.test.id
service_principal {
client_id = "%[3]s"
tenant_id = "%[4]s"
client_certificate_base64 = "%[5]s"
client_certificate_password = "%[6]s"
client_id = azuread_service_principal.test.client_id
tenant_id = data.azurerm_client_config.test.tenant_id
client_certificate_base64 = "%[3]s"
client_certificate_password = "%[4]s"
client_certificate_send_chain = true
}
}
Expand All @@ -632,7 +656,7 @@ resource "azurerm_arc_kubernetes_flux_configuration" "test" {
azurerm_role_assignment.test_blob
]
}
`, r.template(data, credential, privateKey, publicKey), data.RandomInteger, os.Getenv("ARM_CLIENT_ID"), os.Getenv("ARM_TENANT_ID"), os.Getenv("ARM_CLIENT_CERTIFICATE"), os.Getenv("ARM_CLIENT_CERTIFICATE_PASSWORD"))
`, r.template(data, credential, privateKey, publicKey), data.RandomInteger, os.Getenv("ARM_CLIENT_CERTIFICATE"), os.Getenv("ARM_CLIENT_CERTIFICATE_PASSWORD"))
}

func (r ArcKubernetesFluxConfigurationResource) kustomizationNameDuplicated(data acceptance.TestData, credential string, privateKey string, publicKey string) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,20 @@ func (r KubernetesFluxConfigurationResource) azureBlobWithServicePrincipalSecret
return fmt.Sprintf(`
%[1]s
provider "azuread" {}
resource "azuread_application" "test" {
display_name = "acctestspa-%[2]d"
}
resource "azuread_service_principal" "test" {
application_id = azuread_application.test.application_id
}
resource "azuread_service_principal_password" "test" {
service_principal_id = azuread_service_principal.test.object_id
}
resource "azurerm_storage_account" "test" {
name = "sa%[2]d"
resource_group_name = azurerm_resource_group.test.name
Expand All @@ -600,13 +614,13 @@ data "azurerm_client_config" "test" {
resource "azurerm_role_assignment" "test_queue" {
scope = azurerm_storage_account.test.id
role_definition_name = "Storage Queue Data Contributor"
principal_id = data.azurerm_client_config.test.object_id
principal_id = azuread_service_principal.test.object_id
}
resource "azurerm_role_assignment" "test_blob" {
scope = azurerm_storage_account.test.id
role_definition_name = "Storage Blob Data Contributor"
principal_id = data.azurerm_client_config.test.object_id
principal_id = azuread_service_principal.test.object_id
}
resource "azurerm_kubernetes_flux_configuration" "test" {
Expand All @@ -617,9 +631,9 @@ resource "azurerm_kubernetes_flux_configuration" "test" {
blob_storage {
container_id = azurerm_storage_container.test.id
service_principal {
client_id = "%[3]s"
tenant_id = "%[4]s"
client_secret = "%[5]s"
client_id = azuread_service_principal.test.client_id
tenant_id = data.azurerm_client_config.test.tenant_id
client_secret = azuread_service_principal_password.test.value
}
}
Expand All @@ -633,13 +647,23 @@ resource "azurerm_kubernetes_flux_configuration" "test" {
azurerm_role_assignment.test_blob
]
}
`, r.template(data), data.RandomInteger, os.Getenv("ARM_CLIENT_ID"), os.Getenv("ARM_TENANT_ID"), os.Getenv("ARM_CLIENT_SECRET"))
`, r.template(data), data.RandomInteger)
}

func (r KubernetesFluxConfigurationResource) azureBlobWithServicePrincipalCertificate(data acceptance.TestData) string {
return fmt.Sprintf(`
%[1]s
provider "azuread" {}
resource "azuread_application" "test" {
display_name = "acctestspa-%[2]d"
}
resource "azuread_service_principal" "test" {
application_id = azuread_application.test.application_id
}
resource "azurerm_storage_account" "test" {
name = "sa%[2]d"
resource_group_name = azurerm_resource_group.test.name
Expand All @@ -660,13 +684,13 @@ data "azurerm_client_config" "test" {
resource "azurerm_role_assignment" "test_queue" {
scope = azurerm_storage_account.test.id
role_definition_name = "Storage Queue Data Contributor"
principal_id = data.azurerm_client_config.test.object_id
principal_id = azuread_service_principal.test.object_id
}
resource "azurerm_role_assignment" "test_blob" {
scope = azurerm_storage_account.test.id
role_definition_name = "Storage Blob Data Contributor"
principal_id = data.azurerm_client_config.test.object_id
principal_id = azuread_service_principal.test.object_id
}
resource "azurerm_kubernetes_flux_configuration" "test" {
Expand All @@ -677,10 +701,10 @@ resource "azurerm_kubernetes_flux_configuration" "test" {
blob_storage {
container_id = azurerm_storage_container.test.id
service_principal {
client_id = "%[3]s"
tenant_id = "%[4]s"
client_certificate_base64 = "%[5]s"
client_certificate_password = "%[6]s"
client_id = azuread_service_principal.test.client_id
tenant_id = data.azurerm_client_config.test.tenant_id
client_certificate_base64 = "%[3]s"
client_certificate_password = "%[4]s"
client_certificate_send_chain = true
}
}
Expand All @@ -695,7 +719,7 @@ resource "azurerm_kubernetes_flux_configuration" "test" {
azurerm_role_assignment.test_blob
]
}
`, r.template(data), data.RandomInteger, os.Getenv("ARM_CLIENT_ID"), os.Getenv("ARM_TENANT_ID"), os.Getenv("ARM_CLIENT_CERTIFICATE"), os.Getenv("ARM_CLIENT_CERTIFICATE_PASSWORD"))
`, r.template(data), data.RandomInteger, os.Getenv("ARM_CLIENT_CERTIFICATE"), os.Getenv("ARM_CLIENT_CERTIFICATE_PASSWORD"))
}

func (r KubernetesFluxConfigurationResource) kustomizationNameDuplicated(data acceptance.TestData) string {
Expand Down

0 comments on commit 0ec8499

Please sign in to comment.