-
Notifications
You must be signed in to change notification settings - Fork 289
Feature: Add JFrog V2 Service Endpoint Data Source (Issue #1231) #1232
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
base: main
Are you sure you want to change the base?
Changes from all commits
123392b
cf06f39
9cc5d07
2591e83
dd87c4c
f78778e
c46f5d5
928db8c
ac246f1
ebeaa67
d2e418a
ed6989c
2b42bd1
63ecf0a
b8fcc20
799f6c3
baea2b2
c319bb0
3f1ef56
3ddf396
dc61358
532aae1
f3317fa
9edc989
c0ddf88
738c25c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This import is not used. |
||
) | ||
|
||
// 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), | ||
}, | ||
Schema: dataSourceGenBaseSchema(), | ||
} | ||
|
||
maps.Copy(r.Schema, map[string]*schema.Schema{ | ||
"url": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary |
||
}, | ||
}) | ||
|
||
return r | ||
} | ||
|
||
func DataSourceServiceEndpointJFrogArtifactoryV2Read(d *schema.ResourceData, m interface{}) error { | ||
serviceEndpoint, err := dataSourceGetBaseServiceEndpoint(d, m) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err = checkServiceConnection(serviceEndpoint); err != nil { | ||
return err | ||
} | ||
doBaseFlattening(d, serviceEndpoint) | ||
d.Set("url", serviceEndpoint.Url) | ||
jasonouellet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This import is not used. |
||
) | ||
|
||
// 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), | ||
}, | ||
Schema: dataSourceGenBaseSchema(), | ||
} | ||
maps.Copy(r.Schema, map[string]*schema.Schema{ | ||
"url": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
}) | ||
|
||
return r | ||
} | ||
|
||
func DataSourceServiceEndpointJFrogDistributionV2Read(d *schema.ResourceData, m interface{}) error { | ||
serviceEndpoint, err := dataSourceGetBaseServiceEndpoint(d, m) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err = checkServiceConnection(serviceEndpoint); err != nil { | ||
return err | ||
} | ||
doBaseFlattening(d, serviceEndpoint) | ||
d.Set("url", serviceEndpoint.Url) | ||
jasonouellet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This import is not used. |
||
) | ||
|
||
// DataSourceServiceEndpointJFrogPlatformV2 schema and implementation for JFrog Platform service endpoint resource | ||
func DataSourceServiceEndpointJFrogPlatformV2() *schema.Resource { | ||
r := &schema.Resource{ | ||
Read: DataSourceServiceEndpointJFrogPlatformV2Read, | ||
Timeouts: &schema.ResourceTimeout{ | ||
Read: schema.DefaultTimeout(1 * time.Minute), | ||
}, | ||
Schema: dataSourceGenBaseSchema(), | ||
} | ||
|
||
maps.Copy(r.Schema, map[string]*schema.Schema{ | ||
"url": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
}) | ||
|
||
return r | ||
} | ||
|
||
func DataSourceServiceEndpointJFrogPlatformV2Read(d *schema.ResourceData, m interface{}) error { | ||
serviceEndpoint, err := dataSourceGetBaseServiceEndpoint(d, m) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err = checkServiceConnection(serviceEndpoint); err != nil { | ||
return err | ||
} | ||
doBaseFlattening(d, serviceEndpoint) | ||
d.Set("url", serviceEndpoint.Url) | ||
jasonouellet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This HCL is not configured correctly.