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

New Resource: azurerm_data_factory_dataset_sql_server_table #3236

Merged
merged 7 commits into from
Apr 12, 2019
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
5 changes: 5 additions & 0 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ type ArmClient struct {

// Data Factory
dataFactoryClient datafactory.FactoriesClient
dataFactoryDatasetClient datafactory.DatasetsClient
dataFactoryLinkedServiceClient datafactory.LinkedServicesClient

// Data Lake Store
Expand Down Expand Up @@ -886,6 +887,10 @@ func (c *ArmClient) registerDataFactoryClients(endpoint, subscriptionId string,
c.configureClient(&dataFactoryClient.Client, auth)
c.dataFactoryClient = dataFactoryClient

dataFactoryDatasetClient := datafactory.NewDatasetsClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&dataFactoryDatasetClient.Client, auth)
c.dataFactoryDatasetClient = dataFactoryDatasetClient

dataFactoryLinkedServiceClient := datafactory.NewLinkedServicesClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&dataFactoryLinkedServiceClient.Client, auth)
c.dataFactoryLinkedServiceClient = dataFactoryLinkedServiceClient
Expand Down
54 changes: 54 additions & 0 deletions azurerm/data_factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package azurerm

import (
"log"

"github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafactory"
)

func expandDataFactoryParameters(input map[string]interface{}) map[string]*datafactory.ParameterSpecification {
output := make(map[string]*datafactory.ParameterSpecification)

for k, v := range input {
output[k] = &datafactory.ParameterSpecification{
Type: datafactory.ParameterTypeString,
DefaultValue: v.(string),
}
}

return output
}

func flattenDataFactoryParameters(input map[string]*datafactory.ParameterSpecification) map[string]interface{} {
output := make(map[string]interface{})

for k, v := range input {
if v != nil {
// we only support string parameters at this time
val, ok := v.DefaultValue.(string)
if !ok {
log.Printf("[DEBUG] Skipping parameter %q since it's not a string", k)
}

output[k] = val
}
}

return output
}

func flattenDataFactoryAnnotations(input *[]interface{}) []string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you could use utils.FlattenStringArray instead of this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Weirdly enough, I think it'd be a call to utils.ExpandStringArray

Copy link
Member Author

Choose a reason for hiding this comment

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

On second thought. I think it's needed because it's an *[]interface{} and we'd need to do some finagling to get it to a []string

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahh yea sorry, its so close to the signature, and as much as i'd want to ask if terraform would accept the interface array i know we should check they are all strings.

Copy link
Member Author

Choose a reason for hiding this comment

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

No worries!

annotations := make([]string, 0)
if input == nil {
return annotations
}

for _, annotation := range *input {
val, ok := annotation.(string)
if !ok {
log.Printf("[DEBUG] Skipping annotation %q since it's not a string", val)
}
annotations = append(annotations, val)
}
return annotations
}
1 change: 1 addition & 0 deletions azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func Provider() terraform.ResourceProvider {
"azurerm_container_service": resourceArmContainerService(),
"azurerm_cosmosdb_account": resourceArmCosmosDBAccount(),
"azurerm_data_factory": resourceArmDataFactory(),
"azurerm_data_factory_dataset_sql_server_table": resourceArmDataFactoryDatasetSQLServerTable(),
"azurerm_data_factory_linked_service_sql_server": resourceArmDataFactoryLinkedServiceSQLServer(),
"azurerm_data_lake_analytics_account": resourceArmDataLakeAnalyticsAccount(),
"azurerm_data_lake_analytics_firewall_rule": resourceArmDataLakeAnalyticsFirewallRule(),
Expand Down
Loading