Skip to content

Commit b6010e2

Browse files
author
Nicholas M. Iodice
authored
Remove repo_name in favor of repo_id field (#321)
* Remove repo_name property in favor of repo ID * fixes * Tested builds w/ all repo types * Removing documentation references to repo name
1 parent 805113c commit b6010e2

File tree

8 files changed

+6
-21
lines changed

8 files changed

+6
-21
lines changed

.azdo/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ resource "azuredevops_build_definition" "nightly_build" {
3737
repository {
3838
repo_type = "GitHub"
3939
repo_id = "microsoft/terraform-provider-azuredevops"
40-
repo_name = "microsoft/terraform-provider-azuredevops"
4140
branch_name = "master"
4241
yml_path = ".azdo/azure-pipeline-nightly.yml"
4342
service_connection_id = azuredevops_serviceendpoint_github.github_serviceendpoint.id

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ resource "azuredevops_build_definition" "build_definition" {
4444
repository {
4545
repo_type = "TfsGit"
4646
repo_id = azuredevops_git_repository.repository.id
47-
repo_name = azuredevops_git_repository.repository.name
4847
branch_name = azuredevops_git_repository.repository.default_branch
4948
yml_path = "azure-pipelines.yml"
5049
}

azuredevops/resource_build_definition.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,6 @@ func resourceBuildDefinition() *schema.Resource {
136136
Type: schema.TypeString,
137137
Required: true,
138138
},
139-
"repo_name": {
140-
Type: schema.TypeString,
141-
Required: true,
142-
},
143139
"repo_type": {
144140
Type: schema.TypeString,
145141
Required: true,
@@ -429,7 +425,6 @@ func flattenRepository(buildDefinition *build.BuildDefinition) interface{} {
429425
return []map[string]interface{}{{
430426
"yml_path": yamlFilePath,
431427
"repo_id": *buildDefinition.Repository.Id,
432-
"repo_name": *buildDefinition.Repository.Name,
433428
"repo_type": *buildDefinition.Repository.Type,
434429
"branch_name": *buildDefinition.Repository.DefaultBranch,
435430
"service_connection_id": (*buildDefinition.Repository.Properties)["connectedServiceId"],
@@ -735,14 +730,16 @@ func expandBuildDefinition(d *schema.ResourceData) (*build.BuildDefinition, stri
735730
repository := repositories[0].(map[string]interface{})
736731

737732
repoID := repository["repo_id"].(string)
738-
repoName := repository["repo_name"].(string)
733+
repoName := ""
739734
repoType := RepoType(repository["repo_type"].(string))
740735
repoURL := ""
741736
if strings.EqualFold(string(repoType), string(RepoTypeValues.GitHub)) {
742-
repoURL = fmt.Sprintf("https://github.com/%s.git", repoName)
737+
repoURL = fmt.Sprintf("https://github.com/%s.git", repoID)
738+
repoName = repoID
743739
}
744740
if strings.EqualFold(string(repoType), string(RepoTypeValues.Bitbucket)) {
745-
repoURL = fmt.Sprintf("https://bitbucket.org/%s.git", repoName)
741+
repoURL = fmt.Sprintf("https://bitbucket.org/%s.git", repoID)
742+
repoName = repoID
746743
}
747744

748745
ciTriggers := expandBuildDefinitionTriggerList(

azuredevops/resource_build_definition_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,6 @@ func TestAccAzureDevOpsBuildDefinition_Create_Update_Import(t *testing.T) {
442442
resource.TestCheckResourceAttrSet(tfBuildDefNode, "project_id"),
443443
resource.TestCheckResourceAttrSet(tfBuildDefNode, "revision"),
444444
resource.TestCheckResourceAttrSet(tfBuildDefNode, "repository.0.repo_id"),
445-
resource.TestCheckResourceAttr(tfBuildDefNode, "repository.0.repo_name", gitRepoName),
446445
resource.TestCheckResourceAttr(tfBuildDefNode, "name", buildDefinitionNameThird),
447446
resource.TestCheckResourceAttr(tfBuildDefNode, "path", buildDefinitionPathEmpty),
448447
),

azuredevops/utils/testhelper/hcl.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ func TestAccBuildDefinitionResourceGitHub(projectName string, buildDefinitionNam
293293
buildPath,
294294
"GitHub",
295295
"repoOrg/repoName",
296-
"repoOrg/repoName",
297296
"master",
298297
"path/to/yaml",
299298
"")
@@ -307,7 +306,6 @@ func TestAccBuildDefinitionResourceBitbucket(projectName string, buildDefinition
307306
buildPath,
308307
"Bitbucket",
309308
"repoOrg/repoName",
310-
"repoOrg/repoName",
311309
"master",
312310
"path/to/yaml",
313311
serviceConnectionID)
@@ -321,7 +319,6 @@ func TestAccBuildDefinitionResourceTfsGit(projectName string, gitRepoName string
321319
buildPath,
322320
"TfsGit",
323321
"${azuredevops_git_repository.gitrepo.id}",
324-
"${azuredevops_git_repository.gitrepo.name}",
325322
"master",
326323
"path/to/yaml",
327324
"")
@@ -338,7 +335,6 @@ func TestAccBuildDefinitionResource(
338335
buildPath string,
339336
repoType string,
340337
repoID string,
341-
repoName string,
342338
branchName string,
343339
yamlPath string,
344340
serviceConnectionID string,
@@ -347,11 +343,10 @@ func TestAccBuildDefinitionResource(
347343
repository {
348344
repo_type = "%s"
349345
repo_id = "%s"
350-
repo_name = "%s"
351346
branch_name = "%s"
352347
yml_path = "%s"
353348
service_connection_id = "%s"
354-
}`, repoType, repoID, repoName, branchName, yamlPath, serviceConnectionID)
349+
}`, repoType, repoID, branchName, yamlPath, serviceConnectionID)
355350

356351
buildDefinitionResource := fmt.Sprintf(`
357352
resource "azuredevops_build_definition" "build" {

examples/azdo-based-cicd/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ resource "azuredevops_build_definition" "build" {
4343
repository {
4444
repo_type = "TfsGit"
4545
repo_id = azuredevops_git_repository.repository.id
46-
repo_name = azuredevops_git_repository.repository.name
4746
branch_name = azuredevops_git_repository.repository.default_branch
4847
yml_path = "azure-pipelines.yml"
4948
}

examples/github-based-cicd-simple/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ resource "azuredevops_build_definition" "nightly_build" {
3131
repository {
3232
repo_type = "GitHub"
3333
repo_id = "microsoft/terraform-provider-azuredevops"
34-
repo_name = "microsoft/terraform-provider-azuredevops"
3534
branch_name = "master"
3635
yml_path = ".azdo/azure-pipeline-nightly.yml"
3736
service_connection_id = azuredevops_serviceendpoint_github.github_serviceendpoint.id

website/docs/r/build_definition.html.markdown

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ resource "azuredevops_build_definition" "build" {
5858
repository {
5959
repo_type = "TfsGit"
6060
repo_id = azuredevops_git_repository.repository.id
61-
repo_name = azuredevops_git_repository.repository.name
6261
branch_name = azuredevops_git_repository.repository.default_branch
6362
yml_path = "azure-pipelines.yml"
6463
}
@@ -85,7 +84,6 @@ The following arguments are supported:
8584

8685
* `branch_name` - (Optional) The branch name for which builds are triggered. Defaults to `master`.
8786
* `repo_id` - (Required) The id of the repository.
88-
* `repo_name` - (Required) The name of the repository.
8987
* `repo_type` - (Optional) The repository type. Valid values: `GitHub` or `TfsGit` or `Bitbucket`. Defaults to `Github`.
9088
* `service_connection_id` - (Optional) The service connection ID. Used if the `repo_type` is `GitHub`.
9189
* `yml_path` - (Required) The path of the Yaml file describing the build definition.

0 commit comments

Comments
 (0)