Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_synapse_workspace - return an empty workspace config repo object instead of nil #26421

Merged
merged 1 commit into from
Jun 24, 2024
Merged
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
3 changes: 2 additions & 1 deletion internal/services/synapse/synapse_workspace_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,8 @@ func expandWorkspaceRepositoryConfiguration(d *pluginsdk.ResourceData) *synapse.
}
}

return nil
// API won't clear an existing repository config with nil
return &synapse.WorkspaceRepositoryConfiguration{}
}

func expandIdentityControlSQLSettings(enabled bool) *synapse.ManagedIdentitySQLControlSettingsModel {
Expand Down
54 changes: 37 additions & 17 deletions internal/services/synapse/synapse_workspace_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,16 @@ func TestAccSynapseWorkspace_azdo(t *testing.T) {
Config: r.azureDevOps(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("azure_devops_repo.0.account_name").HasValue("myorg"),
check.That(data.ResourceName).Key("azure_devops_repo.0.project_name").HasValue("myproj"),
check.That(data.ResourceName).Key("azure_devops_repo.0.repository_name").HasValue("myrepo"),
check.That(data.ResourceName).Key("azure_devops_repo.0.branch_name").HasValue("dev"),
check.That(data.ResourceName).Key("azure_devops_repo.0.root_folder").HasValue("/"),
check.That(data.ResourceName).Key("azure_devops_repo.0.tenant_id").IsEmpty(),
),
},
data.ImportStep("sql_administrator_login_password"),
{
Config: r.repoConfigRemoved(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("sql_administrator_login_password"),
})
}

Expand All @@ -138,14 +140,9 @@ func TestAccSynapseWorkspace_azdoTenant(t *testing.T) {
Config: r.azureDevOpsTenant(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("azure_devops_repo.0.account_name").HasValue("myorg"),
check.That(data.ResourceName).Key("azure_devops_repo.0.project_name").HasValue("myproj"),
check.That(data.ResourceName).Key("azure_devops_repo.0.repository_name").HasValue("myrepo"),
check.That(data.ResourceName).Key("azure_devops_repo.0.branch_name").HasValue("dev"),
check.That(data.ResourceName).Key("azure_devops_repo.0.root_folder").HasValue("/"),
check.That(data.ResourceName).Key("azure_devops_repo.0.tenant_id").Exists(),
),
},
data.ImportStep("sql_administrator_login_password"),
})
}

Expand All @@ -158,13 +155,16 @@ func TestAccSynapseWorkspace_github(t *testing.T) {
Config: r.github(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("github_repo.0.account_name").HasValue("myuser"),
check.That(data.ResourceName).Key("github_repo.0.git_url").HasValue("https://github.mydomain.com"),
check.That(data.ResourceName).Key("github_repo.0.repository_name").HasValue("myrepo"),
check.That(data.ResourceName).Key("github_repo.0.branch_name").HasValue("dev"),
check.That(data.ResourceName).Key("github_repo.0.root_folder").HasValue("/"),
),
},
data.ImportStep("sql_administrator_login_password"),
{
Config: r.repoConfigRemoved(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("sql_administrator_login_password"),
})
}

Expand Down Expand Up @@ -512,6 +512,26 @@ resource "azurerm_synapse_workspace" "test" {
`, template, data.RandomInteger)
}

func (r SynapseWorkspaceResource) repoConfigRemoved(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
%s

resource "azurerm_synapse_workspace" "test" {
name = "acctestsw%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
storage_data_lake_gen2_filesystem_id = azurerm_storage_data_lake_gen2_filesystem.test.id
sql_administrator_login = "sqladminuser"
sql_administrator_login_password = "H@Sh1CoR3!"

identity {
type = "SystemAssigned"
}
}
`, template, data.RandomInteger)
}

func (r SynapseWorkspaceResource) azureDevOpsTenant(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
Expand Down
Loading