From 49e08bff21b443ee8653d9e7efdffbf4d8495708 Mon Sep 17 00:00:00 2001 From: Sharath Nair Date: Fri, 19 Aug 2022 17:06:39 +1000 Subject: Incorporate comments and fixes --- .../acceptancetests/data_serviceendpoint_azurerm_test.go | 4 ++-- .../acceptancetests/data_serviceendpoint_github_test.go | 4 ++-- azuredevops/internal/acceptancetests/testutils/hcl.go | 4 ++-- azuredevops/internal/service/serviceendpoint/commons.go | 8 ++++---- .../service/serviceendpoint/data_serviceendpoint_azurerm.go | 1 + .../service/serviceendpoint/data_serviceendpoint_github.go | 1 + website/docs/d/serviceendpoint_azurerm.html.markdown | 6 +++--- website/docs/d/serviceendpoint_github.html.markdown | 10 +++++----- 8 files changed, 20 insertions(+), 18 deletions(-) diff --git a/azuredevops/internal/acceptancetests/data_serviceendpoint_azurerm_test.go b/azuredevops/internal/acceptancetests/data_serviceendpoint_azurerm_test.go index 2ede34db..3fdb4f96 100644 --- a/azuredevops/internal/acceptancetests/data_serviceendpoint_azurerm_test.go +++ b/azuredevops/internal/acceptancetests/data_serviceendpoint_azurerm_test.go @@ -32,7 +32,7 @@ func TestAccServiceEndpointAzureRM_with_serviceEndpointID_DataSource(t *testing. Config: createServiceEndpointAzureRMWithServiceEndpointIDData, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(tfNode, "service_endpoint_name", serviceEndpointAzureRMName), - resource.TestCheckResourceAttrSet(tfNode, "id"), + resource.TestCheckResourceAttrSet(tfNode, "service_endpoint_id"), ), }, }, @@ -58,7 +58,7 @@ func TestAccServiceEndpointAzureRM_with_serviceEndpointName_DataSource(t *testin Config: createServiceEndpointAzureRMWithServiceEndpointNameData, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(tfNode, "service_endpoint_name", serviceEndpointAzureRMName), - resource.TestCheckResourceAttrSet(tfNode, "id"), + resource.TestCheckResourceAttrSet(tfNode, "service_endpoint_id"), ), }, }, diff --git a/azuredevops/internal/acceptancetests/data_serviceendpoint_github_test.go b/azuredevops/internal/acceptancetests/data_serviceendpoint_github_test.go index 2c16e550..aa468508 100644 --- a/azuredevops/internal/acceptancetests/data_serviceendpoint_github_test.go +++ b/azuredevops/internal/acceptancetests/data_serviceendpoint_github_test.go @@ -29,7 +29,7 @@ func TestAccServiceEndpointGitHub_with_serviceEndpointID_DataSource(t *testing.T Config: createServiceEndpointGitHubWithServiceEndpointIDData, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(tfNode, "service_endpoint_name", serviceEndpointGitHubName), - resource.TestCheckResourceAttrSet(tfNode, "id"), + resource.TestCheckResourceAttrSet(tfNode, "service_endpoint_id"), ), }, }, @@ -53,7 +53,7 @@ func TestAccServiceEndpointGitHub_with_serviceEndpointName_DataSource(t *testing Config: createServiceEndpointGitHubWithServiceEndpointNameData, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(tfNode, "service_endpoint_name", serviceEndpointGitHubName), - resource.TestCheckResourceAttrSet(tfNode, "id"), + resource.TestCheckResourceAttrSet(tfNode, "service_endpoint_id"), ), }, }, diff --git a/azuredevops/internal/acceptancetests/testutils/hcl.go b/azuredevops/internal/acceptancetests/testutils/hcl.go index 036ef5b9..377ec3d3 100644 --- a/azuredevops/internal/acceptancetests/testutils/hcl.go +++ b/azuredevops/internal/acceptancetests/testutils/hcl.go @@ -256,7 +256,7 @@ func HclServiceEndpointGitHubDataSourceWithServiceEndpointID() string { serviceEndpointDataSource := fmt.Sprintf(` data "azuredevops_serviceendpoint_github" "serviceendpoint" { project_id = azuredevops_project.project.id - id = azuredevops_serviceendpoint_github.serviceendpoint.id + service_endpoint_id = azuredevops_serviceendpoint_github.serviceendpoint.id } `) return fmt.Sprintf("%s", serviceEndpointDataSource) @@ -428,7 +428,7 @@ func HclServiceEndpointAzureRMDataSourceWithServiceEndpointID() string { serviceEndpointDataSource := fmt.Sprintf(` data "azuredevops_serviceendpoint_azurerm" "serviceendpointrm" { project_id = azuredevops_project.project.id - id = azuredevops_serviceendpoint_azurerm.serviceendpointrm.id + service_endpoint_id = azuredevops_serviceendpoint_azurerm.serviceendpointrm.id } `) return fmt.Sprintf("%s", serviceEndpointDataSource) diff --git a/azuredevops/internal/service/serviceendpoint/commons.go b/azuredevops/internal/service/serviceendpoint/commons.go index a0c5085d..5069f804 100644 --- a/azuredevops/internal/service/serviceendpoint/commons.go +++ b/azuredevops/internal/service/serviceendpoint/commons.go @@ -395,16 +395,16 @@ func dataSourceGenBaseServiceEndpointResource(dataSourceReadFunc schema.ReadFunc Type: schema.TypeString, Optional: true, Computed: true, - ExactlyOneOf: []string{"service_endpoint_name", "id"}, + ExactlyOneOf: []string{"service_endpoint_name", "service_endpoint_id"}, ValidateFunc: validation.StringIsNotEmpty, }, - "id": { + "service_endpoint_id": { Description: "The ID of the serviceendpoint", Type: schema.TypeString, Optional: true, Computed: true, - ExactlyOneOf: []string{"service_endpoint_name", "id"}, + ExactlyOneOf: []string{"service_endpoint_name", "service_endpoint_id"}, ValidateFunc: validation.IsUUID, }, @@ -443,7 +443,7 @@ func dataSourceGetBaseServiceEndpoint(d *schema.ResourceData, m interface{}) (*s projectID = &parsedProjectID - if serviceEndpointIDString, ok := d.GetOk("id"); ok { + if serviceEndpointIDString, ok := d.GetOk("service_endpoint_id"); ok { var serviceEndpointID *uuid.UUID parsedServiceEndpointID, err := uuid.Parse(serviceEndpointIDString.(string)) if err != nil { diff --git a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_azurerm.go b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_azurerm.go index 5507acba..a50b1f54 100644 --- a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_azurerm.go +++ b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_azurerm.go @@ -22,6 +22,7 @@ func dataSourceServiceEndpointAzureRMRead(d *schema.ResourceData, m interface{}) } if serviceEndpoint != nil { (*serviceEndpoint.Data)["creationMode"] = "" + d.Set("service_endpoint_id", serviceEndpoint.Id.String()) flattenServiceEndpointAzureRM(d, serviceEndpoint, projectID) return nil } diff --git a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_github.go b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_github.go index c9677393..7cccc100 100644 --- a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_github.go +++ b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_github.go @@ -17,6 +17,7 @@ func dataSourceServiceEndpointGithubRead(d *schema.ResourceData, m interface{}) return err } if serviceEndpoint != nil { + d.Set("service_endpoint_id", serviceEndpoint.Id.String()) doBaseFlattening(d, serviceEndpoint, projectID) return nil } diff --git a/website/docs/d/serviceendpoint_azurerm.html.markdown b/website/docs/d/serviceendpoint_azurerm.html.markdown index bde896ed..b233667f 100644 --- a/website/docs/d/serviceendpoint_azurerm.html.markdown +++ b/website/docs/d/serviceendpoint_azurerm.html.markdown @@ -20,7 +20,7 @@ data "azuredevops_project" "sample" { data "azuredevops_serviceendpoint_azurerm" "serviceendpoint" { project_id = data.azuredevops_project.sample.id - id = "00000000-0000-0000-0000-000000000000" + service_endpoint_id = "00000000-0000-0000-0000-000000000000" } output "service_endpoint_name" { @@ -51,11 +51,11 @@ The following arguments are supported: * `project_id` - (Required) The ID of the project. -* `id` - (Optional) the ID of the Service Endpoint. +* `service_endpoint_id` - (Optional) the ID of the Service Endpoint. * `service_endpoint_name` - (Optional) the Name of the Service Endpoint. -~> **NOTE:** One of either `id` or `service_endpoint_name` must be specified. +~> **NOTE:** One of either `service_endpoint_id` or `service_endpoint_name` must be specified. ~> **NOTE:** When supplying `service_endpoint_name`, take care to ensure that this is a unique name. ## Attributes Reference diff --git a/website/docs/d/serviceendpoint_github.html.markdown b/website/docs/d/serviceendpoint_github.html.markdown index 9030c167..f35d6ec2 100644 --- a/website/docs/d/serviceendpoint_github.html.markdown +++ b/website/docs/d/serviceendpoint_github.html.markdown @@ -2,12 +2,12 @@ layout: "azuredevops" page_title: "AzureDevops: Data Source: azuredevops_serviceendpoint_github" description: |- - Gets information about an existing AzureRM Service Endpoint. + Gets information about an existing GitHub Service Endpoint. --- # Data Source : azuredevops_serviceendpoint_github -Use this data source to access information about an existing AzureRM service Endpoint. +Use this data source to access information about an existing GitHub service Endpoint. ## Example Usage @@ -20,7 +20,7 @@ data "azuredevops_project" "sample" { data "azuredevops_serviceendpoint_github" "serviceendpoint" { project_id = data.azuredevops_project.sample.id - id = "00000000-0000-0000-0000-000000000000" + service_endpoint_id = "00000000-0000-0000-0000-000000000000" } output "service_endpoint_name" { @@ -51,11 +51,11 @@ The following arguments are supported: * `project_id` - (Required) The ID of the project. -* `id` - (Optional) the ID of the Service Endpoint. +* `service_endpoint_id` - (Optional) the ID of the Service Endpoint. * `service_endpoint_name` - (Optional) the Name of the Service Endpoint. -~> **NOTE:** One of either `id` or `service_endpoint_name` must be specified. +~> **NOTE:** One of either `service_endpoint_id` or `service_endpoint_name` must be specified. ~> **NOTE:** When supplying `service_endpoint_name`, take care to ensure that this is a unique name. ## Attributes Reference -- cgit v1.2.3