summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxuzhang3 <Zhangxu894765>2022-10-11 15:26:37 +0800
committerxuzhang3 <Zhangxu894765>2022-10-11 15:26:37 +0800
commit76d7ce4b1b04ef12bf718ac7909c46ba59a3697a (patch)
tree6da1172a540a95d7e0586980529e19f1088c70fe
parentff0a8043c399c71a842b9ee31d0d7f2cfaec0419 (diff)
support export descriptor
-rw-r--r--azuredevops/internal/acceptancetests/resource_team_test.go9
-rw-r--r--azuredevops/internal/service/core/resource_team.go14
-rw-r--r--website/docs/r/team.html.markdown1
3 files changed, 23 insertions, 1 deletions
diff --git a/azuredevops/internal/acceptancetests/resource_team_test.go b/azuredevops/internal/acceptancetests/resource_team_test.go
index 1b6539c7..aa370308 100644
--- a/azuredevops/internal/acceptancetests/resource_team_test.go
+++ b/azuredevops/internal/acceptancetests/resource_team_test.go
@@ -37,6 +37,7 @@ func TestAccTeam_CreateAndUpdate(t *testing.T) {
resource.TestCheckResourceAttr(tfNode, "description", teamDescription),
resource.TestCheckResourceAttrSet(tfNode, "administrators.#"),
resource.TestCheckResourceAttrSet(tfNode, "members.#"),
+ resource.TestCheckResourceAttrSet(tfNode, "descriptor"),
),
},
{
@@ -47,7 +48,7 @@ func TestAccTeam_CreateAndUpdate(t *testing.T) {
resource.TestCheckResourceAttr(tfNode, "name", teamName2),
resource.TestCheckResourceAttr(tfNode, "description", teamDescription2),
resource.TestCheckResourceAttrSet(tfNode, "administrators.#"),
- resource.TestCheckResourceAttrSet(tfNode, "members.#"),
+ resource.TestCheckResourceAttrSet(tfNode, "descriptor"),
),
},
},
@@ -113,6 +114,7 @@ data "azuredevops_group" "builtin_project_readers" {
resource.TestCheckResourceAttr(tfNode, "description", teamDescription),
resource.TestCheckResourceAttr(tfNode, "administrators.#", "1"),
resource.TestCheckResourceAttrSet(tfNode, "members.#"),
+ resource.TestCheckResourceAttrSet(tfNode, "descriptor"),
),
},
{
@@ -124,6 +126,7 @@ data "azuredevops_group" "builtin_project_readers" {
resource.TestCheckResourceAttr(tfNode, "description", teamDescription),
resource.TestCheckResourceAttr(tfNode, "administrators.#", "2"),
resource.TestCheckResourceAttrSet(tfNode, "members.#"),
+ resource.TestCheckResourceAttrSet(tfNode, "descriptor"),
),
},
{
@@ -199,6 +202,7 @@ data "azuredevops_group" "builtin_project_readers" {
resource.TestCheckResourceAttr(tfNode, "description", teamDescription),
resource.TestCheckResourceAttrSet(tfNode, "administrators.#"),
resource.TestCheckResourceAttr(tfNode, "members.#", "1"),
+ resource.TestCheckResourceAttrSet(tfNode, "descriptor"),
),
},
{
@@ -210,6 +214,8 @@ data "azuredevops_group" "builtin_project_readers" {
resource.TestCheckResourceAttr(tfNode, "description", teamDescription),
resource.TestCheckResourceAttrSet(tfNode, "administrators.#"),
resource.TestCheckResourceAttr(tfNode, "members.#", "2"),
+ resource.TestCheckResourceAttrSet(tfNode, "descriptor"),
+ resource.TestCheckResourceAttrSet(tfNode, "descriptor"),
),
},
{
@@ -221,6 +227,7 @@ data "azuredevops_group" "builtin_project_readers" {
resource.TestCheckResourceAttr(tfNode, "description", teamDescription),
resource.TestCheckResourceAttrSet(tfNode, "administrators.#"),
resource.TestCheckResourceAttr(tfNode, "members.#", "1"),
+ resource.TestCheckResourceAttrSet(tfNode, "descriptor"),
),
},
},
diff --git a/azuredevops/internal/service/core/resource_team.go b/azuredevops/internal/service/core/resource_team.go
index 2508314f..fe575cfa 100644
--- a/azuredevops/internal/service/core/resource_team.go
+++ b/azuredevops/internal/service/core/resource_team.go
@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/microsoft/azure-devops-go-api/azuredevops/v6/core"
+ "github.com/microsoft/azure-devops-go-api/azuredevops/v6/graph"
"github.com/microsoft/azure-devops-go-api/azuredevops/v6/identity"
"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client"
securityhelper "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/permissions/utils"
@@ -66,6 +67,10 @@ func ResourceTeam() *schema.Resource {
ConfigMode: schema.SchemaConfigModeAttr,
Set: schema.HashString,
},
+ "descriptor": {
+ Type: schema.TypeString,
+ Computed: true,
+ },
},
}
}
@@ -171,6 +176,15 @@ func resourceTeamRead(d *schema.ResourceData, m interface{}) error {
}
flattenTeam(d, team, members, administrators)
+
+ descriptor, err := clients.GraphClient.GetDescriptor(clients.Ctx, graph.GetDescriptorArgs{
+ StorageKey: team.Id,
+ })
+ if err != nil {
+ return fmt.Errorf(" get team descriptor. Error: %+v", err)
+ }
+
+ d.Set("descriptor", descriptor.Value)
return nil
}
diff --git a/website/docs/r/team.html.markdown b/website/docs/r/team.html.markdown
index c7836b6d..e3dbef85 100644
--- a/website/docs/r/team.html.markdown
+++ b/website/docs/r/team.html.markdown
@@ -68,6 +68,7 @@ The following arguments are supported:
In addition to all arguments above, the following attributes are exported:
- `id` - The ID of the Team.
+- `descriptor` - The descriptor of the Team.
## Relevant Links