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_trigger_schedule #4793

Merged
merged 6 commits into from Nov 13, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions azurerm/helpers/validate/datafactory.go
@@ -0,0 +1,30 @@
package validate

import (
"fmt"
"regexp"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func DataFactoryPipelineAndTriggerName() schema.SchemaValidateFunc {
return func(i interface{}, k string) (warnings []string, errors []error) {
value := i.(string)
if !regexp.MustCompile(`^[A-Za-z0-9_][^<>*#.%&:\\+?/]*$`).MatchString(value) {
errors = append(errors, fmt.Errorf("invalid name, see https://docs.microsoft.com/en-us/azure/data-factory/naming-rules %q: %q", k, value))
}

return warnings, errors
}
}

func DataFactoryName() schema.SchemaValidateFunc {
return func(i interface{}, k string) (warnings []string, errors []error) {
value := i.(string)
if !regexp.MustCompile(`^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`).MatchString(value) {
errors = append(errors, fmt.Errorf("invalid data_factory_name, see https://docs.microsoft.com/en-us/azure/data-factory/naming-rules %q: %q", k, value))
}

return warnings, errors
}
}
57 changes: 57 additions & 0 deletions azurerm/helpers/validate/datafactory_test.go
@@ -0,0 +1,57 @@
package validate

import "testing"

func TestValidateDataFactoryPipelineAndTriggerName(t *testing.T) {
validNames := []string{
"validname",
"valid02name",
"validName1",
}
for _, v := range validNames {
_, errors := DataFactoryPipelineAndTriggerName()(v, "valid")
if len(errors) != 0 {
t.Fatalf("%q should be an invalid DataFactory Pipeline or Trigger Name: %q", v, errors)
}
}

invalidNames := []string{
"invalid.",
":@£",
">invalid",
"invalid&name",
}
for _, v := range invalidNames {
_, errors := DataFactoryPipelineAndTriggerName()(v, "invalid")
if len(errors) == 0 {
t.Fatalf("%q should be an invalid DataFactory Pipeline or Trigger Name", v)
}
}
}

func TestValidateDataFactoryName(t *testing.T) {
validNames := []string{
"valid-name",
"valid02-name",
"validName1",
}
for _, v := range validNames {
_, errors := DataFactoryName()(v, "valid")
if len(errors) != 0 {
t.Fatalf("%q should be a valid DataFactory Name: %q", v, errors)
}
}

invalidNames := []string{
"invalid.",
":@£",
">invalid",
"invalid&name",
}
for _, v := range invalidNames {
_, errors := DataFactoryName()(v, "invalid")
if len(errors) == 0 {
t.Fatalf("%q should be an invalid DataFactory Name", v)
}
}
}
5 changes: 5 additions & 0 deletions azurerm/internal/services/datafactory/client.go
Expand Up @@ -11,6 +11,7 @@ type Client struct {
IntegrationRuntimesClient *datafactory.IntegrationRuntimesClient
LinkedServiceClient *datafactory.LinkedServicesClient
PipelinesClient *datafactory.PipelinesClient
TriggersClient *datafactory.TriggersClient
}

func BuildClient(o *common.ClientOptions) *Client {
Expand All @@ -29,11 +30,15 @@ func BuildClient(o *common.ClientOptions) *Client {
PipelinesClient := datafactory.NewPipelinesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&PipelinesClient.Client, o.ResourceManagerAuthorizer)

TriggersClient := datafactory.NewTriggersClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&TriggersClient.Client, o.ResourceManagerAuthorizer)

return &Client{
DatasetClient: &DatasetClient,
FactoriesClient: &FactoriesClient,
IntegrationRuntimesClient: &IntegrationRuntimesClient,
LinkedServiceClient: &LinkedServiceClient,
PipelinesClient: &PipelinesClient,
TriggersClient: &TriggersClient,
}
}
1 change: 1 addition & 0 deletions azurerm/provider.go
Expand Up @@ -242,6 +242,7 @@ func Provider() terraform.ResourceProvider {
"azurerm_data_factory_linked_service_postgresql": resourceArmDataFactoryLinkedServicePostgreSQL(),
"azurerm_data_factory_linked_service_sql_server": resourceArmDataFactoryLinkedServiceSQLServer(),
"azurerm_data_factory_pipeline": resourceArmDataFactoryPipeline(),
"azurerm_data_factory_trigger_schedule": resourceArmDataFactoryTriggerSchedule(),
"azurerm_data_lake_analytics_account": resourceArmDataLakeAnalyticsAccount(),
"azurerm_data_lake_analytics_firewall_rule": resourceArmDataLakeAnalyticsFirewallRule(),
"azurerm_data_lake_store_file": resourceArmDataLakeStoreFile(),
Expand Down
12 changes: 4 additions & 8 deletions azurerm/resource_arm_data_factory.go
Expand Up @@ -2,7 +2,6 @@ package azurerm

import (
"fmt"
"regexp"
"time"

"github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafactory"
Expand Down Expand Up @@ -37,13 +36,10 @@ func resourceArmDataFactory() *schema.Resource {

Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(
regexp.MustCompile(`^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`),
`Invalid name for Data Factory, see https://docs.microsoft.com/en-us/azure/data-factory/naming-rules`,
),
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.DataFactoryName(),
},

"location": azure.SchemaLocation(),
Expand Down
12 changes: 4 additions & 8 deletions azurerm/resource_arm_data_factory_dataset_mysql.go
Expand Up @@ -3,7 +3,6 @@ package azurerm
import (
"fmt"
"log"
"regexp"
"time"

"github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafactory"
Expand Down Expand Up @@ -44,13 +43,10 @@ func resourceArmDataFactoryDatasetMySQL() *schema.Resource {
},

"data_factory_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(
regexp.MustCompile(`^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`),
`Invalid name for Data Factory, see https://docs.microsoft.com/en-us/azure/data-factory/naming-rules`,
),
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.DataFactoryName(),
},

// There's a bug in the Azure API where this is returned in lower-case
Expand Down
12 changes: 4 additions & 8 deletions azurerm/resource_arm_data_factory_dataset_postgresql.go
Expand Up @@ -3,7 +3,6 @@ package azurerm
import (
"fmt"
"log"
"regexp"
"time"

"github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafactory"
Expand Down Expand Up @@ -44,13 +43,10 @@ func resourceArmDataFactoryDatasetPostgreSQL() *schema.Resource {
},

"data_factory_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(
regexp.MustCompile(`^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`),
`Invalid name for Data Factory, see https://docs.microsoft.com/en-us/azure/data-factory/naming-rules`,
),
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.DataFactoryName(),
},

// There's a bug in the Azure API where this is returned in lower-case
Expand Down
12 changes: 4 additions & 8 deletions azurerm/resource_arm_data_factory_dataset_sql_server_table.go
Expand Up @@ -3,7 +3,6 @@ package azurerm
import (
"fmt"
"log"
"regexp"
"time"

"github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafactory"
Expand Down Expand Up @@ -44,13 +43,10 @@ func resourceArmDataFactoryDatasetSQLServerTable() *schema.Resource {
},

"data_factory_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(
regexp.MustCompile(`^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`),
`Invalid name for Data Factory, see https://docs.microsoft.com/en-us/azure/data-factory/naming-rules`,
),
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.DataFactoryName(),
},

// There's a bug in the Azure API where this is returned in lower-case
Expand Down
11 changes: 4 additions & 7 deletions azurerm/resource_arm_data_factory_integration_runtime_managed.go
Expand Up @@ -42,13 +42,10 @@ func resourceArmDataFactoryIntegrationRuntimeManaged() *schema.Resource {
},

"data_factory_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(
regexp.MustCompile(`^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`),
`Invalid name for Data Factory, see https://docs.microsoft.com/en-us/azure/data-factory/naming-rules`,
),
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.DataFactoryName(),
},

"resource_group_name": azure.SchemaResourceGroupName(),
Expand Down
Expand Up @@ -2,12 +2,10 @@ package azurerm

import (
"fmt"
"regexp"
"time"

"github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafactory"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
Expand Down Expand Up @@ -43,13 +41,10 @@ func resourceArmDataFactoryLinkedServiceDataLakeStorageGen2() *schema.Resource {
},

"data_factory_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(
regexp.MustCompile(`^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`),
`Invalid name for Data Factory, see https://docs.microsoft.com/en-us/azure/data-factory/naming-rules`,
),
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.DataFactoryName(),
},

// There's a bug in the Azure API where this is returned in lower-case
Expand Down
13 changes: 4 additions & 9 deletions azurerm/resource_arm_data_factory_linked_service_mysql.go
Expand Up @@ -2,12 +2,10 @@ package azurerm

import (
"fmt"
"regexp"
"time"

"github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafactory"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
Expand Down Expand Up @@ -43,13 +41,10 @@ func resourceArmDataFactoryLinkedServiceMySQL() *schema.Resource {
},

"data_factory_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(
regexp.MustCompile(`^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`),
`Invalid name for Data Factory, see https://docs.microsoft.com/en-us/azure/data-factory/naming-rules`,
),
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.DataFactoryName(),
},

// There's a bug in the Azure API where this is returned in lower-case
Expand Down
13 changes: 4 additions & 9 deletions azurerm/resource_arm_data_factory_linked_service_postgresql.go
Expand Up @@ -2,12 +2,10 @@ package azurerm

import (
"fmt"
"regexp"
"time"

"github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafactory"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
Expand Down Expand Up @@ -43,13 +41,10 @@ func resourceArmDataFactoryLinkedServicePostgreSQL() *schema.Resource {
},

"data_factory_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(
regexp.MustCompile(`^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`),
`Invalid name for Data Factory, see https://docs.microsoft.com/en-us/azure/data-factory/naming-rules`,
),
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.DataFactoryName(),
},

// There's a bug in the Azure API where this is returned in lower-case
Expand Down
13 changes: 4 additions & 9 deletions azurerm/resource_arm_data_factory_linked_service_sql_server.go
Expand Up @@ -3,12 +3,10 @@ package azurerm
import (
"fmt"
"log"
"regexp"
"time"

"github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafactory"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
Expand Down Expand Up @@ -44,13 +42,10 @@ func resourceArmDataFactoryLinkedServiceSQLServer() *schema.Resource {
},

"data_factory_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(
regexp.MustCompile(`^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`),
`Invalid name for Data Factory, see https://docs.microsoft.com/en-us/azure/data-factory/naming-rules`,
),
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.DataFactoryName(),
},

// There's a bug in the Azure API where this is returned in lower-case
Expand Down