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_data_factory_dataset_{cosmosdb_sqlapi|mysql|postgresql} - Fix incorrect type/error message during read #22438

Merged
merged 3 commits into from Jul 11, 2023

Conversation

magodo
Copy link
Collaborator

@magodo magodo commented Jul 10, 2023

azurerm_data_factory_dataset_{cosmosdb_sqlapi|mysql|postgresql} - Fix incorrect type/error message during read

…ix incorrect type/error message during read
Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @magodo, this is looking in the right direction but it also breaks one of the resources. It also looks like the resources weren't built correctly either as the mysql dataset is being built as a relational dataset rather than a mysql one. It looks to be the same for the postgresql dataset as well

@@ -249,7 +249,7 @@ func resourceDataFactoryDatasetPostgreSQLRead(d *pluginsdk.ResourceData, meta in
d.Set("name", id.Name)
d.Set("data_factory_id", dataFactoryId.ID())

postgresqlTable, ok := resp.Properties.AsRelationalTableDataset()
postgresqlTable, ok := resp.Properties.AsPostgreSQLTableDataset()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the resource

Error: classifying Data Factory Dataset PostgreSQL Data Set: (Name "acctestds230710174416108434" / Factory Name "acctestdf230710174416108434" / Resource Group "acctestRG-df-230710174416108434"): Expected: "PostgreSqlTable" Received: "Microsoft.DataFactory/factories/datasets"

@magodo
Copy link
Collaborator Author

magodo commented Jul 11, 2023

Thank you @mbfrahry for the feedback! I was mislead by

datasetType := string(datafactory.TypeBasicDatasetTypePostgreSQLTable)
dataset := datafactory.DatasetResource{
Properties: &postgresqlTableset,
Type: &datasetType,
}
in the create function, while I now realized this Type property at the top level is actually thrown away during Marshalling:

https://github.com/hashicorp/terraform-provider-azurerm/blob/e9b169893b48619ebad95fa6410b99d8f8ef6f78/vendor/github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafactory/models.go#L83713-L83718

This brings me to wonder whether postgresql data set is actually implemented as expected, as it is now using the same type as the mysql dataset...

Regardlessly, I've also updated the error message to make it useful, otherwise, the "Expect" always print the same (useless) resource type, instead of the variant type.

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea...I'm not sure if the underlying model changed or the resource was written incorrectly(by me 🙈) but mysql and postgresql definitely look to be using the wrong model.

But these error messages look better so we can move forward with this! Thanks @magodo

@mbfrahry mbfrahry merged commit c7412c8 into hashicorp:main Jul 11, 2023
13 checks passed
@mbfrahry mbfrahry added this to the v3.65.0 milestone Jul 11, 2023
mbfrahry added a commit that referenced this pull request Jul 11, 2023
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants