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_linked_service_azure_file_storage - Fix assignment to user_id #17398

Merged
merged 1 commit into from
Jun 27, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func resourceDataFactoryLinkedServiceAzureFileStorageCreateUpdate(d *pluginsdk.R
},
FileShare: d.Get("file_share").(string),
Host: d.Get("host").(string),
UserID: d.Get("connection_string").(string),
UserID: d.Get("user_id").(string),
}

password := d.Get("password").(string)
Expand Down Expand Up @@ -267,6 +267,10 @@ func resourceDataFactoryLinkedServiceAzureFileStorageRead(d *pluginsdk.ResourceD
}
}

if fileStorage.UserID != nil {
d.Set("user_id", fileStorage.UserID.(string))
}

annotations := flattenDataFactoryAnnotations(fileStorage.Annotations)
if err := d.Set("annotations", annotations); err != nil {
return fmt.Errorf("setting `annotations` for Data Factory Azure File Storage %s: %+v", *id, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,22 @@ func TestAccDataFactoryLinkedServiceAzureFileStorage_KeyVaultReference(t *testin
})
}

func TestAccDataFactoryLinkedServiceAzureFileStorage_UserId(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_data_factory_linked_service_azure_file_storage", "test")
r := LinkedServiceAzureFileStorageResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.userIdAndPassword(data, "admin"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("user_id").HasValue("admin"),
),
},
data.ImportStep("connection_string"),
})
}

func (t LinkedServiceAzureFileStorageResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := parse.LinkedServiceID(state.ID)
if err != nil {
Expand Down Expand Up @@ -234,6 +250,32 @@ resource "azurerm_data_factory_linked_service_azure_file_storage" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func (LinkedServiceAzureFileStorageResource) userIdAndPassword(data acceptance.TestData, userId string) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "test" {
name = "acctestRG-df-%d"
location = "%s"
}

resource "azurerm_data_factory" "test" {
name = "acctestdf%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}

resource "azurerm_data_factory_linked_service_azure_file_storage" "test" {
name = "acctestlsblob%d"
data_factory_id = azurerm_data_factory.test.id
connection_string = "DefaultEndpointsProtocol=https;AccountName=foo;AccountKey=bar"
user_id = "%s"
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, userId)
}

func (LinkedServiceAzureFileStorageResource) key_vault_reference(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down