Skip to content

Commit

Permalink
Take feedback from code review
Browse files Browse the repository at this point in the history
Co-authored-by: kt <[email protected]>
  • Loading branch information
pomverte and katbyte committed May 7, 2021
1 parent c4dec2e commit 2f9efcc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,47 @@ func resourceArmDataFactoryLinkedServiceODataCreateUpdate(d *schema.ResourceData
}
}

description := d.Get("description").(string)

odataLinkedService := &datafactory.ODataLinkedService{
Description: &description,
Type: datafactory.TypeOData,
Description: utils.String(d.Get("description").(string)),
Type: datafactory.TypeOData,
ODataLinkedServiceTypeProperties: authenticationProperties(d),
}

if v, ok := d.GetOk("parameters"); ok {
odataLinkedService.Parameters = expandDataFactoryParameters(v.(map[string]interface{}))
}

if v, ok := d.GetOk("integration_runtime_name"); ok {
odataLinkedService.ConnectVia = expandDataFactoryLinkedServiceIntegrationRuntime(v.(string))
}

if v, ok := d.GetOk("additional_properties"); ok {
odataLinkedService.AdditionalProperties = v.(map[string]interface{})
}

if v, ok := d.GetOk("annotations"); ok {
annotations := v.([]interface{})
odataLinkedService.Annotations = &annotations
}

odataLinkedService.ODataLinkedServiceTypeProperties = authenticationProperties(d)
linkedService := datafactory.LinkedServiceResource{
Properties: odataLinkedService,
}

if _, err := client.CreateOrUpdate(ctx, resourceGroup, dataFactoryName, name, linkedService, ""); err != nil {
return fmt.Errorf("Error creating/updating Data Factory Linked Service OData Anonymous %q (Data Factory %q / Resource Group %q): %+v", name, dataFactoryName, resourceGroup, err)
}

resp, err := client.Get(ctx, resourceGroup, dataFactoryName, name, "")
if err != nil {
return fmt.Errorf("Error retrieving Data Factory Linked Service OData Anonymous %q (Data Factory %q / Resource Group %q): %+v", name, dataFactoryName, resourceGroup, err)
}

if resp.ID == nil {
return fmt.Errorf("Cannot read Data Factory Linked Service OData Anonymous %q (Data Factory %q / Resource Group %q): %+v", name, dataFactoryName, resourceGroup, err)
}

d.SetId(*resp.ID)

return resourceArmDataFactoryLinkedServiceODataRead(d, meta)
}
Expand Down Expand Up @@ -241,23 +274,18 @@ func resourceArmDataFactoryLinkedServiceODataDelete(d *schema.ResourceData, meta
}

func authenticationProperties(d *schema.ResourceData) *datafactory.ODataLinkedServiceTypeProperties {

url := d.Get("url").(string)

basic_authentication := d.Get("basic_authentication").([]interface{})
if basic_authentication != nil {
raw := basic_authentication[0].(map[string]interface{})
username := raw["username"].(string)
password := raw["password"].(string)
passwordSecureString := datafactory.SecureString{
Value: &password,
Type: datafactory.TypeSecureString,
}
return &datafactory.ODataLinkedServiceTypeProperties{
AuthenticationType: datafactory.ODataAuthenticationType(datafactory.ODataAuthenticationTypeBasic),
URL: utils.String(url),
UserName: username,
Password: &passwordSecureString,
UserName: raw["username"].(string),
Password: datafactory.SecureString{
Value: utils.String(raw["password"].(string)),
Type: datafactory.TypeSecureString,
},
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ resource "azurerm_data_factory_linked_service_odata" "basic_auth" {

The following arguments are supported:

* `name` - (Required) Specifies the name of the Data Factory Linked Service OData. Changing this forces a new resource to be created. Must be unique within a data
factory. See the [Microsoft documentation](https://docs.microsoft.com/en-us/azure/data-factory/naming-rules) for all restrictions.
* `name` - (Required) Specifies the name of the Data Factory Linked Service OData. Changing this forces a new resource to be created. Must be unique within a data factory. See the [Microsoft documentation](https://docs.microsoft.com/en-us/azure/data-factory/naming-rules) for all restrictions.

* `resource_group_name` - (Required) The name of the resource group in which to create the Data Factory Linked Service OData. Changing this forces a new resource

Expand Down

0 comments on commit 2f9efcc

Please sign in to comment.