From aa55ddab7418bdbc04dda59750b333f608583e60 Mon Sep 17 00:00:00 2001 From: Jason Ouellet Date: Tue, 19 Nov 2024 18:19:38 +0000 Subject: [PATCH 1/5] feat: add jfrog v2 serviceendpoint data resources --- ...ta_serviceendpoint_jfrog_artifactory_v2.go | 100 ++++++++++++++++++ ...a_serviceendpoint_jfrog_distribution_v2.go | 99 +++++++++++++++++ .../data_serviceendpoint_jfrog_platform_v2.go | 43 ++++++++ .../data_serviceendpoint_jfrog_xray_v2.go | 100 ++++++++++++++++++ 4 files changed, 342 insertions(+) create mode 100644 azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_artifactory_v2.go create mode 100644 azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_distribution_v2.go create mode 100644 azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_platform_v2.go create mode 100644 azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_xray_v2.go diff --git a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_artifactory_v2.go b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_artifactory_v2.go new file mode 100644 index 000000000..1bee1f12c --- /dev/null +++ b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_artifactory_v2.go @@ -0,0 +1,100 @@ +package serviceendpoint + +import ( + "fmt" + "maps" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/validate" +) + +// DataSourceServiceEndpointJFrogArtifactoryV2 schema and implementation for JFrog Artifactory service endpoint resource +func DataSourceServiceEndpointJFrogArtifactoryV2() *schema.Resource { + r := &schema.Resource{ + Read: DataSourceServiceEndpointJFrogArtifactoryV2Read, + Timeouts: &schema.ResourceTimeout{ + Read: schema.DefaultTimeout(1 * time.Minute), + }, + Importer: tfhelper.ImportProjectQualifiedResourceUUID(), + Schema: baseSchema(), + } + + maps.Copy(r.Schema, map[string]*schema.Schema{ + "url": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.Url, + Description: "Url for the JFrog Artifactory Server", + }, + + "authentication_token": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "token": { + Description: "The JFrog Artifactory access token.", + Type: schema.TypeString, + Required: true, + Sensitive: true, + }, + }, + }, + ExactlyOneOf: []string{"authentication_basic", "authentication_token"}, + }, + + "authentication_basic": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "username": { + Description: "The JFrog Artifactory user name.", + Type: schema.TypeString, + Required: true, + Sensitive: true, + }, + "password": { + Description: "The JFrog Artifactory password.", + Type: schema.TypeString, + Required: true, + Sensitive: true, + }, + }, + }, + }, + }) + + return r +} + +func DataSourceServiceEndpointJFrogArtifactoryV2Read(d *schema.ResourceData, m interface{}) error { + clients := m.(*client.AggregatedClient) + getArgs, err := serviceEndpointGetArgs(d) + if err != nil { + return err + } + + serviceEndpoint, err := clients.ServiceEndpointClient.GetServiceEndpointDetails(clients.Ctx, *getArgs) + if err != nil { + if utils.ResponseWasNotFound(err) { + d.SetId("") + return nil + } + return fmt.Errorf(" looking up service endpoint given ID (%v) and project ID (%v): %v", getArgs.EndpointId, getArgs.Project, err) + } + + if err = checkServiceConnection(serviceEndpoint); err != nil { + return err + } + flattenServiceEndpointArtifactoryV2(d, serviceEndpoint) + return nil +} diff --git a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_distribution_v2.go b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_distribution_v2.go new file mode 100644 index 000000000..28f778c94 --- /dev/null +++ b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_distribution_v2.go @@ -0,0 +1,99 @@ +package serviceendpoint + +import ( + "fmt" + "maps" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/validate" +) + +// DataSourceServiceEndpointJFrogDistributionV2 schema and implementation for JFrog Artifactory service endpoint resource +func DataSourceServiceEndpointJFrogDistributionV2() *schema.Resource { + r := &schema.Resource{ + Read: DataSourceServiceEndpointJFrogDistributionV2Read, + Timeouts: &schema.ResourceTimeout{ + Read: schema.DefaultTimeout(1 * time.Minute), + }, + Importer: tfhelper.ImportProjectQualifiedResourceUUID(), + Schema: baseSchema(), + } + maps.Copy(r.Schema, map[string]*schema.Schema{ + "url": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.Url, + Description: "Url for the JFrog Artifactory Server", + }, + + "authentication_token": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "token": { + Description: "The JFrog Artifactory access token.", + Type: schema.TypeString, + Required: true, + Sensitive: true, + }, + }, + }, + ExactlyOneOf: []string{"authentication_basic", "authentication_token"}, + }, + + "authentication_basic": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "username": { + Description: "The JFrog Artifactory user name.", + Type: schema.TypeString, + Required: true, + Sensitive: true, + }, + "password": { + Description: "The JFrog Artifactory password.", + Type: schema.TypeString, + Required: true, + Sensitive: true, + }, + }, + }, + }, + }) + + return r +} + +func DataSourceServiceEndpointJFrogDistributionV2Read(d *schema.ResourceData, m interface{}) error { + clients := m.(*client.AggregatedClient) + getArgs, err := serviceEndpointGetArgs(d) + if err != nil { + return err + } + + serviceEndpoint, err := clients.ServiceEndpointClient.GetServiceEndpointDetails(clients.Ctx, *getArgs) + if err != nil { + if utils.ResponseWasNotFound(err) { + d.SetId("") + return nil + } + return fmt.Errorf(" looking up service endpoint given ID (%v) and project ID (%v): %v", getArgs.EndpointId, getArgs.Project, err) + } + + if err = checkServiceConnection(serviceEndpoint); err != nil { + return err + } + flattenServiceEndpointArtifactoryV2(d, serviceEndpoint) + return nil +} diff --git a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_platform_v2.go b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_platform_v2.go new file mode 100644 index 000000000..bd1d297e8 --- /dev/null +++ b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_platform_v2.go @@ -0,0 +1,43 @@ +package serviceendpoint + +import ( + "fmt" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils" +) + +func DataResourceServiceEndpointJFrogPlatformV2() *schema.Resource { + return &schema.Resource{ + Read: dataSourceServiceEndpointJFrogPlatformV2Read, + Timeouts: &schema.ResourceTimeout{ + Read: schema.DefaultTimeout(5 * time.Minute), + }, + Schema: dataSourceGenBaseSchema(), + } +} + +func dataSourceServiceEndpointJFrogPlatformV2Read(d *schema.ResourceData, m interface{}) error { + clients := m.(*client.AggregatedClient) + getArgs, err := serviceEndpointGetArgs(d) + if err != nil { + return err + } + + serviceEndpoint, err := clients.ServiceEndpointClient.GetServiceEndpointDetails(clients.Ctx, *getArgs) + if err != nil { + if utils.ResponseWasNotFound(err) { + d.SetId("") + return nil + } + return fmt.Errorf(" looking up service endpoint given ID (%v) and project ID (%v): %v", getArgs.EndpointId, getArgs.Project, err) + } + + if err = checkServiceConnection(serviceEndpoint); err != nil { + return err + } + flattenServiceEndpointArtifactoryV2(d, serviceEndpoint) + return nil +} diff --git a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_xray_v2.go b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_xray_v2.go new file mode 100644 index 000000000..7c6bd3fe5 --- /dev/null +++ b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_xray_v2.go @@ -0,0 +1,100 @@ +package serviceendpoint + +import ( + "fmt" + "maps" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/validate" +) + +// DataSourceServiceEndpointJFrogXRayV2 schema and implementation for JFrog Artifactory service endpoint resource +func DataSourceServiceEndpointJFrogXRayV2() *schema.Resource { + r := &schema.Resource{ + Read: DataSourceServiceEndpointJFrogXRayV2Read, + Timeouts: &schema.ResourceTimeout{ + Read: schema.DefaultTimeout(1 * time.Minute), + }, + Importer: tfhelper.ImportProjectQualifiedResourceUUID(), + Schema: baseSchema(), + } + + maps.Copy(r.Schema, map[string]*schema.Schema{ + "url": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.Url, + Description: "Url for the JFrog Artifactory Server", + }, + + "authentication_token": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "token": { + Description: "The JFrog Artifactory access token.", + Type: schema.TypeString, + Required: true, + Sensitive: true, + }, + }, + }, + ExactlyOneOf: []string{"authentication_basic", "authentication_token"}, + }, + + "authentication_basic": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "username": { + Description: "The JFrog Artifactory user name.", + Type: schema.TypeString, + Required: true, + Sensitive: true, + }, + "password": { + Description: "The JFrog Artifactory password.", + Type: schema.TypeString, + Required: true, + Sensitive: true, + }, + }, + }, + }, + }) + + return r +} + +func DataSourceServiceEndpointJFrogXRayV2Read(d *schema.ResourceData, m interface{}) error { + clients := m.(*client.AggregatedClient) + getArgs, err := serviceEndpointGetArgs(d) + if err != nil { + return err + } + + serviceEndpoint, err := clients.ServiceEndpointClient.GetServiceEndpointDetails(clients.Ctx, *getArgs) + if err != nil { + if utils.ResponseWasNotFound(err) { + d.SetId("") + return nil + } + return fmt.Errorf(" looking up service endpoint given ID (%v) and project ID (%v): %v", getArgs.EndpointId, getArgs.Project, err) + } + + if err = checkServiceConnection(serviceEndpoint); err != nil { + return err + } + flattenServiceEndpointArtifactoryV2(d, serviceEndpoint) + return nil +} From 0bba34f949c42b63e8bb74e5bc2ec4502ccb1ff6 Mon Sep 17 00:00:00 2001 From: Jason Ouellet Date: Tue, 19 Nov 2024 19:53:43 +0000 Subject: [PATCH 2/5] feat: add jfrog v2 data doc --- website/azuredevops.erb | 12 +++++ ...ndpoint_jfrog_artifactory_v2.html.markdown | 46 +++++++++++++++++++ ...iceendpoint_jfrog_distribution_v2.markdown | 46 +++++++++++++++++++ ...serviceendpoint_jfrog_platform_v2.markdown | 46 +++++++++++++++++++ ...erviceendpoint_jfrog_xray_v2.html.markdown | 46 +++++++++++++++++++ 5 files changed, 196 insertions(+) create mode 100644 website/docs/d/serviceendpoint_jfrog_artifactory_v2.html.markdown create mode 100644 website/docs/d/serviceendpoint_jfrog_distribution_v2.markdown create mode 100644 website/docs/d/serviceendpoint_jfrog_platform_v2.markdown create mode 100644 website/docs/d/serviceendpoint_jfrog_xray_v2.html.markdown diff --git a/website/azuredevops.erb b/website/azuredevops.erb index 212ea44cd..b18f5bc22 100644 --- a/website/azuredevops.erb +++ b/website/azuredevops.erb @@ -97,6 +97,18 @@
  • azuredevops_serviceendpoint_azurecr
  • +
  • + azuredevops_serviceendpoint_jfrog_artifactory_v2 +
  • +
  • + azuredevops_serviceendpoint_jfrog_distribution_v2 +
  • +
  • + azuredevops_serviceendpoint_jfrog_platform_v2 +
  • +
  • + azuredevops_serviceendpoint_jfrog_xray_v2 +
  • azuredevops_serviceendpoint_sonarcloud
  • diff --git a/website/docs/d/serviceendpoint_jfrog_artifactory_v2.html.markdown b/website/docs/d/serviceendpoint_jfrog_artifactory_v2.html.markdown new file mode 100644 index 000000000..462c9d82d --- /dev/null +++ b/website/docs/d/serviceendpoint_jfrog_artifactory_v2.html.markdown @@ -0,0 +1,46 @@ +--- +layout: "azuredevops" +page_title: "AzureDevops: azuredevops_serviceendpoint_jfrog_artifactory_v2" +description: |- + Gets information about an existing JFrog Artifactory V2 Service Endpoint. +--- + +# Data Source : azuredevops_serviceendpoint_jfrog_artifactory_v2 + +Use this data source to access information about an existing JFrog Artifactory V2 Service Endpoint. + +## Example Usage + +```hcl +data "azuredevops_project" "example" { + name = "Example Project" +} + +data "azuredevops_serviceendpoint_jfrog_artifactory_v2" "example" { + project_id = data.azuredevops_project.example.id + service_endpoint_name = "Example JFrog Artifactory V2" +} + +output "service_endpoint_id" { + value = data.azuredevops_serviceendpoint_jfrog_artifactory_v2.example.id +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `project_id` - (Required) The ID of the project. + +* `service_endpoint_id` - (Optional) the ID of the Service Endpoint. + +* `service_endpoint_name` - (Optional) the Name of the Service Endpoint. + +~> **NOTE:** One of either `service_endpoint_id` or `service_endpoint_name` must be specified. + +## Attributes Reference + +In addition to the Arguments list above - the following Attributes are exported: + +* `authorization` - Specifies the Authorization Scheme Map. +* `description` - Specifies the description of the Service Endpoint. diff --git a/website/docs/d/serviceendpoint_jfrog_distribution_v2.markdown b/website/docs/d/serviceendpoint_jfrog_distribution_v2.markdown new file mode 100644 index 000000000..592b36eaf --- /dev/null +++ b/website/docs/d/serviceendpoint_jfrog_distribution_v2.markdown @@ -0,0 +1,46 @@ +--- +layout: "azuredevops" +page_title: "AzureDevops: azuredevops_serviceendpoint_jfrog_distribution_v2" +description: |- + Gets information about an existing JFrog Distribution V2 Service Endpoint. +--- + +# Data Source : azuredevops_serviceendpoint_jfrog_distribution_v2 + +Use this data source to access information about an existing JFrog Distribution V2 Service Endpoint. + +## Example Usage + +```hcl +data "azuredevops_project" "example" { + name = "Example Project" +} + +data "azuredevops_serviceendpoint_jfrog_distribution_v2" "example" { + project_id = data.azuredevops_project.example.id + service_endpoint_name = "Example JFrog Distribution V2" +} + +output "service_endpoint_id" { + value = data.azuredevops_serviceendpoint_jfrog_distribution_v2.example.id +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `project_id` - (Required) The ID of the project. + +* `service_endpoint_id` - (Optional) the ID of the Service Endpoint. + +* `service_endpoint_name` - (Optional) the Name of the Service Endpoint. + +~> **NOTE:** One of either `service_endpoint_id` or `service_endpoint_name` must be specified. + +## Attributes Reference + +In addition to the Arguments list above - the following Attributes are exported: + +* `authorization` - Specifies the Authorization Scheme Map. +* `description` - Specifies the description of the Service Endpoint. diff --git a/website/docs/d/serviceendpoint_jfrog_platform_v2.markdown b/website/docs/d/serviceendpoint_jfrog_platform_v2.markdown new file mode 100644 index 000000000..67ba42a74 --- /dev/null +++ b/website/docs/d/serviceendpoint_jfrog_platform_v2.markdown @@ -0,0 +1,46 @@ +--- +layout: "azuredevops" +page_title: "AzureDevops: azuredevops_serviceendpoint_jfrog_platform_v2" +description: |- + Gets information about an existing JFrog Platform V2 Service Endpoint. +--- + +# Data Source : azuredevops_serviceendpoint_jfrog_platform_v2 + +Use this data source to access information about an existing JFrog Platform V2 Service Endpoint. + +## Example Usage + +```hcl +data "azuredevops_project" "example" { + name = "Example Project" +} + +data "azuredevops_serviceendpoint_jfrog_platform_v2" "example" { + project_id = data.azuredevops_project.example.id + service_endpoint_name = "Example JFrog Platform V2" +} + +output "service_endpoint_id" { + value = data.azuredevops_serviceendpoint_jfrog_platform_v2.example.id +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `project_id` - (Required) The ID of the project. + +* `service_endpoint_id` - (Optional) the ID of the Service Endpoint. + +* `service_endpoint_name` - (Optional) the Name of the Service Endpoint. + +~> **NOTE:** One of either `service_endpoint_id` or `service_endpoint_name` must be specified. + +## Attributes Reference + +In addition to the Arguments list above - the following Attributes are exported: + +* `authorization` - Specifies the Authorization Scheme Map. +* `description` - Specifies the description of the Service Endpoint. diff --git a/website/docs/d/serviceendpoint_jfrog_xray_v2.html.markdown b/website/docs/d/serviceendpoint_jfrog_xray_v2.html.markdown new file mode 100644 index 000000000..c6466eaba --- /dev/null +++ b/website/docs/d/serviceendpoint_jfrog_xray_v2.html.markdown @@ -0,0 +1,46 @@ +--- +layout: "azuredevops" +page_title: "AzureDevops: azuredevops_serviceendpoint_jfrog_xray_v2" +description: |- + Gets information about an existing JFrog XRay V2 Service Endpoint. +--- + +# Data Source : azuredevops_serviceendpoint_jfrog_xray_v2 + +Use this data source to access information about an existing JFrog XRay V2 Service Endpoint. + +## Example Usage + +```hcl +data "azuredevops_project" "example" { + name = "Example Project" +} + +data "azuredevops_serviceendpoint_jfrog_xray_v2" "example" { + project_id = data.azuredevops_project.example.id + service_endpoint_name = "Example JFrog XRay V2" +} + +output "service_endpoint_id" { + value = data.azuredevops_serviceendpoint_jfrog_xray_v2.example.id +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `project_id` - (Required) The ID of the project. + +* `service_endpoint_id` - (Optional) the ID of the Service Endpoint. + +* `service_endpoint_name` - (Optional) the Name of the Service Endpoint. + +~> **NOTE:** One of either `service_endpoint_id` or `service_endpoint_name` must be specified. + +## Attributes Reference + +In addition to the Arguments list above - the following Attributes are exported: + +* `authorization` - Specifies the Authorization Scheme Map. +* `description` - Specifies the description of the Service Endpoint. From 9fbad744d51fcaf70e85c1c6f1fb9099bd766de0 Mon Sep 17 00:00:00 2001 From: Jason Ouellet Date: Tue, 19 Nov 2024 19:55:07 +0000 Subject: [PATCH 3/5] add: jfrog v2 data to provider --- .../data_serviceendpoint_jfrog_platform_v2.go | 6 +- azuredevops/provider.go | 62 ++++++++++--------- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_platform_v2.go b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_platform_v2.go index bd1d297e8..332d411fb 100644 --- a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_platform_v2.go +++ b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_platform_v2.go @@ -9,9 +9,9 @@ import ( "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils" ) -func DataResourceServiceEndpointJFrogPlatformV2() *schema.Resource { +func DataSourceServiceEndpointJFrogPlatformV2() *schema.Resource { return &schema.Resource{ - Read: dataSourceServiceEndpointJFrogPlatformV2Read, + Read: DataSourceServiceEndpointJFrogPlatformV2Read, Timeouts: &schema.ResourceTimeout{ Read: schema.DefaultTimeout(5 * time.Minute), }, @@ -19,7 +19,7 @@ func DataResourceServiceEndpointJFrogPlatformV2() *schema.Resource { } } -func dataSourceServiceEndpointJFrogPlatformV2Read(d *schema.ResourceData, m interface{}) error { +func DataSourceServiceEndpointJFrogPlatformV2Read(d *schema.ResourceData, m interface{}) error { clients := m.(*client.AggregatedClient) getArgs, err := serviceEndpointGetArgs(d) if err != nil { diff --git a/azuredevops/provider.go b/azuredevops/provider.go index fa9720c53..4a87964d8 100644 --- a/azuredevops/provider.go +++ b/azuredevops/provider.go @@ -131,35 +131,39 @@ func Provider() *schema.Provider { "azuredevops_feed_permission": feed.ResourceFeedPermission(), }, DataSourcesMap: map[string]*schema.Resource{ - "azuredevops_build_definition": build.DataBuildDefinition(), - "azuredevops_agent_pool": taskagent.DataAgentPool(), - "azuredevops_agent_pools": taskagent.DataAgentPools(), - "azuredevops_agent_queue": taskagent.DataAgentQueue(), - "azuredevops_client_config": service.DataClientConfig(), - "azuredevops_environment": taskagent.DataEnvironment(), - "azuredevops_group": graph.DataGroup(), - "azuredevops_project": core.DataProject(), - "azuredevops_projects": core.DataProjects(), - "azuredevops_git_repositories": git.DataGitRepositories(), - "azuredevops_git_repository": git.DataGitRepository(), - "azuredevops_users": graph.DataUsers(), - "azuredevops_area": workitemtracking.DataArea(), - "azuredevops_iteration": workitemtracking.DataIteration(), - "azuredevops_team": core.DataTeam(), - "azuredevops_teams": core.DataTeams(), - "azuredevops_groups": graph.DataGroups(), - "azuredevops_identity_groups": identity.DataIdentityGroups(), - "azuredevops_identity_group": identity.DataIdentityGroup(), - "azuredevops_identity_user": identity.DataIdentityUser(), - "azuredevops_variable_group": taskagent.DataVariableGroup(), - "azuredevops_securityrole_definitions": securityroles.DataSecurityRoleDefinitions(), - "azuredevops_serviceendpoint_azurerm": serviceendpoint.DataServiceEndpointAzureRM(), - "azuredevops_serviceendpoint_github": serviceendpoint.DataServiceEndpointGithub(), - "azuredevops_serviceendpoint_bitbucket": serviceendpoint.DataResourceServiceEndpointBitbucket(), - "azuredevops_serviceendpoint_npm": serviceendpoint.DataResourceServiceEndpointNpm(), - "azuredevops_serviceendpoint_azurecr": serviceendpoint.DataResourceServiceEndpointAzureCR(), - "azuredevops_serviceendpoint_sonarcloud": serviceendpoint.DataResourceServiceEndpointSonarCloud(), - "azuredevops_feed": feed.DataFeed(), + "azuredevops_build_definition": build.DataBuildDefinition(), + "azuredevops_agent_pool": taskagent.DataAgentPool(), + "azuredevops_agent_pools": taskagent.DataAgentPools(), + "azuredevops_agent_queue": taskagent.DataAgentQueue(), + "azuredevops_client_config": service.DataClientConfig(), + "azuredevops_environment": taskagent.DataEnvironment(), + "azuredevops_group": graph.DataGroup(), + "azuredevops_project": core.DataProject(), + "azuredevops_projects": core.DataProjects(), + "azuredevops_git_repositories": git.DataGitRepositories(), + "azuredevops_git_repository": git.DataGitRepository(), + "azuredevops_users": graph.DataUsers(), + "azuredevops_area": workitemtracking.DataArea(), + "azuredevops_iteration": workitemtracking.DataIteration(), + "azuredevops_team": core.DataTeam(), + "azuredevops_teams": core.DataTeams(), + "azuredevops_groups": graph.DataGroups(), + "azuredevops_identity_groups": identity.DataIdentityGroups(), + "azuredevops_identity_group": identity.DataIdentityGroup(), + "azuredevops_identity_user": identity.DataIdentityUser(), + "azuredevops_variable_group": taskagent.DataVariableGroup(), + "azuredevops_securityrole_definitions": securityroles.DataSecurityRoleDefinitions(), + "azuredevops_serviceendpoint_azurerm": serviceendpoint.DataServiceEndpointAzureRM(), + "azuredevops_serviceendpoint_github": serviceendpoint.DataServiceEndpointGithub(), + "azuredevops_serviceendpoint_bitbucket": serviceendpoint.DataResourceServiceEndpointBitbucket(), + "azuredevops_serviceendpoint_npm": serviceendpoint.DataResourceServiceEndpointNpm(), + "azuredevops_serviceendpoint_azurecr": serviceendpoint.DataResourceServiceEndpointAzureCR(), + "azuredevops_serviceendpoint_jfrog_artifactory_v2": serviceendpoint.DataSourceServiceEndpointJFrogArtifactoryV2(), + "azuredevops_serviceendpoint_jfrog_distribution_v2": serviceendpoint.DataSourceServiceEndpointJFrogDistributionV2(), + "azuredevops_serviceendpoint_jfrog_platform_v2": serviceendpoint.DataSourceServiceEndpointJFrogPlatformV2(), + "azuredevops_serviceendpoint_jfrog_xray_v2": serviceendpoint.DataSourceServiceEndpointJFrogXRayV2(), + "azuredevops_serviceendpoint_sonarcloud": serviceendpoint.DataResourceServiceEndpointSonarCloud(), + "azuredevops_feed": feed.DataFeed(), }, Schema: map[string]*schema.Schema{ "org_service_url": { From 427f5c661fc75442e18421a6ba4d395095c4e9f6 Mon Sep 17 00:00:00 2001 From: Jason Ouellet Date: Tue, 10 Dec 2024 18:44:42 +0000 Subject: [PATCH 4/5] add: acceptance tests --- ...rviceendpoint_jfrog_artifactory_v2_test.go | 55 +++++++++++++++++++ ...viceendpoint_jfrog_distribution_v2_test.go | 55 +++++++++++++++++++ ..._serviceendpoint_jfrog_platform_v2_test.go | 55 +++++++++++++++++++ ...data_serviceendpoint_jfrog_xray_v2_test.go | 55 +++++++++++++++++++ 4 files changed, 220 insertions(+) create mode 100644 azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_artifactory_v2_test.go create mode 100644 azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_distribution_v2_test.go create mode 100644 azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_platform_v2_test.go create mode 100644 azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_xray_v2_test.go diff --git a/azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_artifactory_v2_test.go b/azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_artifactory_v2_test.go new file mode 100644 index 000000000..2ec550e02 --- /dev/null +++ b/azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_artifactory_v2_test.go @@ -0,0 +1,55 @@ +//go:build (all || data_sources || data_serviceendpoint_jfrog_artifactory_v2) && (!exclude_data_sources || !exclude_data_serviceendpoint_jfrog_artifactory_v2) +// +build all data_sources data_serviceendpoint_jfrog_artifactory_v2 +// +build !exclude_data_sources !exclude_data_serviceendpoint_jfrog_artifactory_v2 + +package acceptancetests + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/acceptancetests/testutils" +) + +func TestAccServiceEndpointJfrogArtifactoryV2_dataSource(t *testing.T) { + name := testutils.GenerateResourceName() + + tfNode := "data.azuredevops_serviceendpoint_jfrog_artifactory_v2.test" + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testutils.PreCheck(t, nil) }, + Providers: testutils.GetProviders(), + Steps: []resource.TestStep{ + { + Config: hclServiceEndpointJfrogArtifactoryV2DataSource(name), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(tfNode, "service_endpoint_name", name), + resource.TestCheckResourceAttrSet(tfNode, "service_endpoint_name"), + ), + }, + }, + }) +} + +func hclServiceEndpointJfrogArtifactoryV2DataSource(name string) string { + return fmt.Sprintf(` +resource "azuredevops_project" "test" { + name = "%[1]s" + visibility = "private" + version_control = "Git" + work_item_template = "Agile" +} + +resource "azuredevops_serviceendpoint_jfrog_artifactory_v2" "test" { + project_id = azuredevops_project.test.id + service_endpoint_name = "%[1]s" + token = "0000000000000000000000000000000000000000" + description = "Managed by Terraform" +} + +data "azuredevops_serviceendpoint_jfrog_artifactory_v2" "test" { + project_id = azuredevops_project.test.id + service_endpoint_name = azuredevops_serviceendpoint_jfrog_artifactory_v2.test.service_endpoint_name +} +`, name) +} diff --git a/azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_distribution_v2_test.go b/azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_distribution_v2_test.go new file mode 100644 index 000000000..744d108a6 --- /dev/null +++ b/azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_distribution_v2_test.go @@ -0,0 +1,55 @@ +//go:build (all || data_sources || data_serviceendpoint_jfrog_distribution_v2) && (!exclude_data_sources || !exclude_data_serviceendpoint_jfrog_distribution_v2) +// +build all data_sources data_serviceendpoint_jfrog_distribution_v2 +// +build !exclude_data_sources !exclude_data_serviceendpoint_jfrog_distribution_v2 + +package acceptancetests + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/acceptancetests/testutils" +) + +func TestAccServiceEndpointJfrogDistributionV2_dataSource(t *testing.T) { + name := testutils.GenerateResourceName() + + tfNode := "data.azuredevops_serviceendpoint_jfrog_distribution_v2.test" + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testutils.PreCheck(t, nil) }, + Providers: testutils.GetProviders(), + Steps: []resource.TestStep{ + { + Config: hclServiceEndpointJfrogDistributionV2DataSource(name), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(tfNode, "service_endpoint_name", name), + resource.TestCheckResourceAttrSet(tfNode, "service_endpoint_name"), + ), + }, + }, + }) +} + +func hclServiceEndpointJfrogDistributionV2DataSource(name string) string { + return fmt.Sprintf(` +resource "azuredevops_project" "test" { + name = "%[1]s" + visibility = "private" + version_control = "Git" + work_item_template = "Agile" +} + +resource "azuredevops_serviceendpoint_jfrog_distribution_v2" "test" { + project_id = azuredevops_project.test.id + service_endpoint_name = "%[1]s" + token = "0000000000000000000000000000000000000000" + description = "Managed by Terraform" +} + +data "azuredevops_serviceendpoint_jfrog_distribution_v2" "test" { + project_id = azuredevops_project.test.id + service_endpoint_name = azuredevops_serviceendpoint_jfrog_distribution_v2.test.service_endpoint_name +} +`, name) +} diff --git a/azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_platform_v2_test.go b/azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_platform_v2_test.go new file mode 100644 index 000000000..79c01f0d2 --- /dev/null +++ b/azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_platform_v2_test.go @@ -0,0 +1,55 @@ +//go:build (all || data_sources || data_serviceendpoint_jfrog_platform_v2) && (!exclude_data_sources || !exclude_data_serviceendpoint_jfrog_platform_v2) +// +build all data_sources data_serviceendpoint_jfrog_platform_v2 +// +build !exclude_data_sources !exclude_data_serviceendpoint_jfrog_platform_v2 + +package acceptancetests + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/acceptancetests/testutils" +) + +func TestAccServiceEndpointJfrogPlatformV2_dataSource(t *testing.T) { + name := testutils.GenerateResourceName() + + tfNode := "data.azuredevops_serviceendpoint_jfrog_platform_v2.test" + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testutils.PreCheck(t, nil) }, + Providers: testutils.GetProviders(), + Steps: []resource.TestStep{ + { + Config: hclServiceEndpointJfrogPlatformV2DataSource(name), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(tfNode, "service_endpoint_name", name), + resource.TestCheckResourceAttrSet(tfNode, "service_endpoint_name"), + ), + }, + }, + }) +} + +func hclServiceEndpointJfrogPlatformV2DataSource(name string) string { + return fmt.Sprintf(` +resource "azuredevops_project" "test" { + name = "%[1]s" + visibility = "private" + version_control = "Git" + work_item_template = "Agile" +} + +resource "azuredevops_serviceendpoint_jfrog_platform_v2" "test" { + project_id = azuredevops_project.test.id + service_endpoint_name = "%[1]s" + token = "0000000000000000000000000000000000000000" + description = "Managed by Terraform" +} + +data "azuredevops_serviceendpoint_jfrog_platform_v2" "test" { + project_id = azuredevops_project.test.id + service_endpoint_name = azuredevops_serviceendpoint_jfrog_platform_v2.test.service_endpoint_name +} +`, name) +} diff --git a/azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_xray_v2_test.go b/azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_xray_v2_test.go new file mode 100644 index 000000000..bd76a04ac --- /dev/null +++ b/azuredevops/internal/acceptancetests/data_serviceendpoint_jfrog_xray_v2_test.go @@ -0,0 +1,55 @@ +//go:build (all || data_sources || data_serviceendpoint_jfrog_xray_v2) && (!exclude_data_sources || !exclude_data_serviceendpoint_jfrog_xray_v2) +// +build all data_sources data_serviceendpoint_jfrog_xray_v2 +// +build !exclude_data_sources !exclude_data_serviceendpoint_jfrog_xray_v2 + +package acceptancetests + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/acceptancetests/testutils" +) + +func TestAccServiceEndpointJfrogXrayV2_dataSource(t *testing.T) { + name := testutils.GenerateResourceName() + + tfNode := "data.azuredevops_serviceendpoint_jfrog_xray_v2.test" + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testutils.PreCheck(t, nil) }, + Providers: testutils.GetProviders(), + Steps: []resource.TestStep{ + { + Config: hclServiceEndpointJfrogXrayV2DataSource(name), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(tfNode, "service_endpoint_name", name), + resource.TestCheckResourceAttrSet(tfNode, "service_endpoint_name"), + ), + }, + }, + }) +} + +func hclServiceEndpointJfrogXrayV2DataSource(name string) string { + return fmt.Sprintf(` +resource "azuredevops_project" "test" { + name = "%[1]s" + visibility = "private" + version_control = "Git" + work_item_template = "Agile" +} + +resource "azuredevops_serviceendpoint_jfrog_xray_v2" "test" { + project_id = azuredevops_project.test.id + service_endpoint_name = "%[1]s" + token = "0000000000000000000000000000000000000000" + description = "Managed by Terraform" +} + +data "azuredevops_serviceendpoint_jfrog_xray_v2" "test" { + project_id = azuredevops_project.test.id + service_endpoint_name = azuredevops_serviceendpoint_jfrog_xray_v2.test.service_endpoint_name +} +`, name) +} From b2598adc3b7766fce8ab2c37499e5c721bf76a84 Mon Sep 17 00:00:00 2001 From: Jason Ouellet Date: Fri, 20 Dec 2024 22:07:48 +0000 Subject: [PATCH 5/5] fix: code review comments --- ...ta_serviceendpoint_jfrog_artifactory_v2.go | 39 ++------------- ...a_serviceendpoint_jfrog_distribution_v2.go | 48 ++----------------- .../data_serviceendpoint_jfrog_platform_v2.go | 19 +++++++- .../data_serviceendpoint_jfrog_xray_v2.go | 48 ++----------------- 4 files changed, 28 insertions(+), 126 deletions(-) diff --git a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_artifactory_v2.go b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_artifactory_v2.go index 1bee1f12c..0406faaea 100644 --- a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_artifactory_v2.go +++ b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_artifactory_v2.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils" - "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/validate" ) @@ -19,8 +18,7 @@ func DataSourceServiceEndpointJFrogArtifactoryV2() *schema.Resource { Timeouts: &schema.ResourceTimeout{ Read: schema.DefaultTimeout(1 * time.Minute), }, - Importer: tfhelper.ImportProjectQualifiedResourceUUID(), - Schema: baseSchema(), + Schema: dataSourceGenBaseSchema(), } maps.Copy(r.Schema, map[string]*schema.Schema{ @@ -28,14 +26,10 @@ func DataSourceServiceEndpointJFrogArtifactoryV2() *schema.Resource { Type: schema.TypeString, Required: true, ValidateFunc: validate.Url, - Description: "Url for the JFrog Artifactory Server", - }, - - "authentication_token": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 1, + Computed: true, + Optional: true, + MinItems: 1, + MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "token": { @@ -48,29 +42,6 @@ func DataSourceServiceEndpointJFrogArtifactoryV2() *schema.Resource { }, ExactlyOneOf: []string{"authentication_basic", "authentication_token"}, }, - - "authentication_basic": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "username": { - Description: "The JFrog Artifactory user name.", - Type: schema.TypeString, - Required: true, - Sensitive: true, - }, - "password": { - Description: "The JFrog Artifactory password.", - Type: schema.TypeString, - Required: true, - Sensitive: true, - }, - }, - }, - }, }) return r diff --git a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_distribution_v2.go b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_distribution_v2.go index 28f778c94..8d9ebf640 100644 --- a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_distribution_v2.go +++ b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_distribution_v2.go @@ -8,19 +8,17 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils" - "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/validate" ) -// DataSourceServiceEndpointJFrogDistributionV2 schema and implementation for JFrog Artifactory service endpoint resource +// DataSourceServiceEndpointJFrogDistributionV2 schema and implementation for JFrog Distribution service endpoint resource func DataSourceServiceEndpointJFrogDistributionV2() *schema.Resource { r := &schema.Resource{ Read: DataSourceServiceEndpointJFrogDistributionV2Read, Timeouts: &schema.ResourceTimeout{ Read: schema.DefaultTimeout(1 * time.Minute), }, - Importer: tfhelper.ImportProjectQualifiedResourceUUID(), - Schema: baseSchema(), + Schema: dataSourceGenBaseSchema(), } maps.Copy(r.Schema, map[string]*schema.Schema{ "url": { @@ -28,47 +26,7 @@ func DataSourceServiceEndpointJFrogDistributionV2() *schema.Resource { Required: true, ValidateFunc: validate.Url, Description: "Url for the JFrog Artifactory Server", - }, - - "authentication_token": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "token": { - Description: "The JFrog Artifactory access token.", - Type: schema.TypeString, - Required: true, - Sensitive: true, - }, - }, - }, - ExactlyOneOf: []string{"authentication_basic", "authentication_token"}, - }, - - "authentication_basic": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "username": { - Description: "The JFrog Artifactory user name.", - Type: schema.TypeString, - Required: true, - Sensitive: true, - }, - "password": { - Description: "The JFrog Artifactory password.", - Type: schema.TypeString, - Required: true, - Sensitive: true, - }, - }, - }, + Computed: true, }, }) diff --git a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_platform_v2.go b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_platform_v2.go index 332d411fb..d32ebfe4c 100644 --- a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_platform_v2.go +++ b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_platform_v2.go @@ -2,21 +2,36 @@ package serviceendpoint import ( "fmt" + "maps" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/validate" ) +// DataSourceServiceEndpointJFrogPlatformV2 schema and implementation for JFrog Platform service endpoint resource func DataSourceServiceEndpointJFrogPlatformV2() *schema.Resource { - return &schema.Resource{ + r := &schema.Resource{ Read: DataSourceServiceEndpointJFrogPlatformV2Read, Timeouts: &schema.ResourceTimeout{ - Read: schema.DefaultTimeout(5 * time.Minute), + Read: schema.DefaultTimeout(1 * time.Minute), }, Schema: dataSourceGenBaseSchema(), } + + maps.Copy(r.Schema, map[string]*schema.Schema{ + "url": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.Url, + Description: "Url for the JFrog Artifactory Server", + Computed: true, + }, + }) + + return r } func DataSourceServiceEndpointJFrogPlatformV2Read(d *schema.ResourceData, m interface{}) error { diff --git a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_xray_v2.go b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_xray_v2.go index 7c6bd3fe5..56b56407f 100644 --- a/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_xray_v2.go +++ b/azuredevops/internal/service/serviceendpoint/data_serviceendpoint_jfrog_xray_v2.go @@ -8,19 +8,17 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils" - "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/validate" ) -// DataSourceServiceEndpointJFrogXRayV2 schema and implementation for JFrog Artifactory service endpoint resource +// DataSourceServiceEndpointJFrogXRayV2 schema and implementation for JFrog XRay service endpoint resource func DataSourceServiceEndpointJFrogXRayV2() *schema.Resource { r := &schema.Resource{ Read: DataSourceServiceEndpointJFrogXRayV2Read, Timeouts: &schema.ResourceTimeout{ Read: schema.DefaultTimeout(1 * time.Minute), }, - Importer: tfhelper.ImportProjectQualifiedResourceUUID(), - Schema: baseSchema(), + Schema: dataSourceGenBaseSchema(), } maps.Copy(r.Schema, map[string]*schema.Schema{ @@ -29,47 +27,7 @@ func DataSourceServiceEndpointJFrogXRayV2() *schema.Resource { Required: true, ValidateFunc: validate.Url, Description: "Url for the JFrog Artifactory Server", - }, - - "authentication_token": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "token": { - Description: "The JFrog Artifactory access token.", - Type: schema.TypeString, - Required: true, - Sensitive: true, - }, - }, - }, - ExactlyOneOf: []string{"authentication_basic", "authentication_token"}, - }, - - "authentication_basic": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "username": { - Description: "The JFrog Artifactory user name.", - Type: schema.TypeString, - Required: true, - Sensitive: true, - }, - "password": { - Description: "The JFrog Artifactory password.", - Type: schema.TypeString, - Required: true, - Sensitive: true, - }, - }, - }, + Computed: true, }, })