DataTeam now uses an explicit schema instead of derived schema from ResourceTeam
@@ -2,20 +2,49 @@ package core
import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
+ "github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client"
)
func DataTeam() *schema.Resource {
- baseSchema := ResourceTeam()
- for k := range baseSchema.Schema {
- if k != "name" && k != "project_id" {
- baseSchema.Schema[k].Computed = true
- baseSchema.Schema[k].Required = false
- }
- }
return &schema.Resource{
Read: dataTeamRead,
- Schema: baseSchema.Schema,
+ Schema: map[string]*schema.Schema{
+ "project_id": {
+ Type: schema.TypeString,
+ Required: true,
+ ValidateFunc: validation.IsUUID,
+ },
+ "name": {
+ Type: schema.TypeString,
+ Required: true,
+ ValidateFunc: validation.StringIsNotWhiteSpace,
+ },
+ "description": {
+ Type: schema.TypeString,
+ Computed: true,
+ },
+ "administrators": {
+ Type: schema.TypeSet,
+ Elem: &schema.Schema{
+ Type: schema.TypeString,
+ ValidateFunc: validation.StringIsNotWhiteSpace,
+ },
+ Computed: true,
+ ConfigMode: schema.SchemaConfigModeAttr,
+ Set: schema.HashString,
+ },
+ "members": {
+ Type: schema.TypeSet,
+ Elem: &schema.Schema{
+ Type: schema.TypeString,
+ ValidateFunc: validation.StringIsNotWhiteSpace,
+ },
+ Computed: true,
+ ConfigMode: schema.SchemaConfigModeAttr,
+ Set: schema.HashString,
+ },
+ },
}
}
@@ -30,6 +59,11 @@ func dataTeamRead(d *schema.ResourceData, m interface{}) error {
return err
}
- flattenTeam(d, team, members, administrators)
+ d.SetId(team.Id.String())
+ d.Set("name", team.Name)
+ d.Set("description", team.Description)
+ d.Set("administrators", administrators)
+ d.Set("members", members)
+
return nil
}
