From 9ff23ad887719415c50a9ec7da8257bbeecf270a Mon Sep 17 00:00:00 2001 From: kt Date: Wed, 14 Feb 2024 14:54:14 -0800 Subject: [PATCH] azurerm_data_factory - allow the git_url to be blank/empty (#24879) * azurerm_data_factory - allow the git_url to be blank/empty * update docs --- .../datafactory/data_factory_resource.go | 5 +-- .../datafactory/data_factory_resource_test.go | 39 +++++++++++++++++++ website/docs/d/data_factory.html.markdown | 2 +- website/docs/r/data_factory.html.markdown | 2 +- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/internal/services/datafactory/data_factory_resource.go b/internal/services/datafactory/data_factory_resource.go index 26d654f440c2..25192dd07fdb 100644 --- a/internal/services/datafactory/data_factory_resource.go +++ b/internal/services/datafactory/data_factory_resource.go @@ -88,9 +88,8 @@ func resourceDataFactory() *pluginsdk.Resource { ValidateFunc: validation.StringIsNotEmpty, }, "git_url": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotEmpty, + Type: pluginsdk.TypeString, + Optional: true, }, "repository_name": { Type: pluginsdk.TypeString, diff --git a/internal/services/datafactory/data_factory_resource_test.go b/internal/services/datafactory/data_factory_resource_test.go index b4a357f92281..84ab88736cfc 100644 --- a/internal/services/datafactory/data_factory_resource_test.go +++ b/internal/services/datafactory/data_factory_resource_test.go @@ -154,6 +154,18 @@ func TestAccDataFactory_github(t *testing.T) { }) } +func TestAccDataFactory_githubEmpty(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_data_factory", "test") + r := DataFactoryResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + data.DisappearsStep(acceptance.DisappearsStepData{ + Config: r.githubUrlEmpty, + TestResource: r, + }), + }) +} + func TestAccDataFactory_publicNetworkDisabled(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_data_factory", "test") r := DataFactoryResource{} @@ -527,6 +539,33 @@ resource "azurerm_data_factory" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) } +func (DataFactoryResource) githubUrlEmpty(data acceptance.TestData) 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 + + github_configuration { + repository_name = "terraform-provider-azurerm" + branch_name = "main" + root_folder = "/" + account_name = "acctestGH-%d" + publishing_enabled = false + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) +} + func (DataFactoryResource) publicNetworkDisabled(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/website/docs/d/data_factory.html.markdown b/website/docs/d/data_factory.html.markdown index d9c9118efded..c88017d0a0a7 100644 --- a/website/docs/d/data_factory.html.markdown +++ b/website/docs/d/data_factory.html.markdown @@ -57,7 +57,7 @@ A `github_configuration` block exports the following: - `branch_name` - The branch of the repository to get code from. -- `git_url` - The GitHub Enterprise host name. +- `git_url` - The GitHub repository url. - `repository_name` - The name of the git repository. diff --git a/website/docs/r/data_factory.html.markdown b/website/docs/r/data_factory.html.markdown index 0381a1ace6d4..b51008c6f57a 100644 --- a/website/docs/r/data_factory.html.markdown +++ b/website/docs/r/data_factory.html.markdown @@ -63,7 +63,7 @@ A `github_configuration` block supports the following: * `branch_name` - (Required) Specifies the branch of the repository to get code from. -* `git_url` - (Required) Specifies the GitHub Enterprise host name. For example: . Use for open source repositories. +* `git_url` - (Optional) Specifies the GitHub Enterprise host name. For example: . Use for open source repositories. * `repository_name` - (Required) Specifies the name of the git repository.