From 7f02f7a5d90db7cefeab7c10d00a18f6769e376a Mon Sep 17 00:00:00 2001 From: Shaun Hevey Date: Fri, 6 Dec 2024 10:56:31 +1100 Subject: [PATCH] Adjusting schema attributes --- docs/data-sources/teams.md | 24 ++++++------- octopusdeploy/data_source_teams.go | 46 ------------------------- octopusdeploy_framework/schemas/team.go | 33 +++++++++--------- 3 files changed, 28 insertions(+), 75 deletions(-) delete mode 100644 octopusdeploy/data_source_teams.go diff --git a/docs/data-sources/teams.md b/docs/data-sources/teams.md index 1075d7295..7c314f2ff 100644 --- a/docs/data-sources/teams.md +++ b/docs/data-sources/teams.md @@ -3,12 +3,12 @@ page_title: "octopusdeploy_teams Data Source - terraform-provider-octopusdeploy" subcategory: "" description: |- - Provides information about existing users. + Provides information about existing teams. --- # octopusdeploy_teams (Data Source) -Provides information about existing users. +Provides information about existing teams. @@ -27,7 +27,7 @@ Provides information about existing users. ### Read-Only - `id` (String) An auto-generated identifier that includes the timestamp when this data source was last modified. -- `teams` (List of Object) A list of teams that match the filter(s). (see [below for nested schema](#nestedatt--teams)) +- `teams` (Attributes List) A list of teams that match the filter(s). (see [below for nested schema](#nestedatt--teams)) ### Nested Schema for `teams` @@ -38,20 +38,20 @@ Read-Only: - `can_be_renamed` (Boolean) - `can_change_members` (Boolean) - `can_change_roles` (Boolean) -- `description` (String) -- `external_security_group` (List of Object) (see [below for nested schema](#nestedobjatt--teams--external_security_group)) -- `id` (String) -- `name` (String) -- `space_id` (String) -- `users` (Set of String) - - +- `description` (String) The user-friendly description of this team. +- `external_security_group` (Attributes List) (see [below for nested schema](#nestedatt--teams--external_security_group)) +- `id` (String) The unique ID for this resource. +- `name` (String) The name of this team. +- `space_id` (String) The space associated with this team. +- `users` (Set of String) A list of user IDs designated to be members of this team. + + ### Nested Schema for `teams.external_security_group` Read-Only: - `display_id_and_name` (Boolean) - `display_name` (String) -- `id` (String) +- `id` (String) The unique ID for this resource. diff --git a/octopusdeploy/data_source_teams.go b/octopusdeploy/data_source_teams.go deleted file mode 100644 index 2d520aeee..000000000 --- a/octopusdeploy/data_source_teams.go +++ /dev/null @@ -1,46 +0,0 @@ -package octopusdeploy - -import ( - "context" - "time" - - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/teams" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func dataSourceTeams() *schema.Resource { - return &schema.Resource{ - Description: "Provides information about existing users.", - ReadContext: dataSourceTeamsRead, - Schema: getTeamDataSchema(), - } -} - -func dataSourceTeamsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - query := teams.TeamsQuery{ - IDs: expandArray(d.Get("ids").([]interface{})), - IncludeSystem: d.Get("include_system").(bool), - PartialName: d.Get("partial_name").(string), - Spaces: expandArray(d.Get("spaces").([]interface{})), - Skip: d.Get("skip").(int), - Take: d.Get("take").(int), - } - - client := meta.(*client.Client) - existingTeams, err := client.Teams.Get(query) - if err != nil { - return diag.FromErr(err) - } - - flattenedTeams := []interface{}{} - for _, team := range existingTeams.Items { - flattenedTeams = append(flattenedTeams, flattenTeam(team)) - } - - d.Set("teams", flattenedTeams) - d.SetId("Teams " + time.Now().UTC().String()) - - return nil -} diff --git a/octopusdeploy_framework/schemas/team.go b/octopusdeploy_framework/schemas/team.go index 4b837c416..30ad7818b 100644 --- a/octopusdeploy_framework/schemas/team.go +++ b/octopusdeploy_framework/schemas/team.go @@ -28,7 +28,7 @@ func (l TeamSchema) GetDatasourceSchema() datasourceSchema.Schema { Description: "Provides information about existing teams.", Attributes: map[string]datasourceSchema.Attribute{ "id": util.DataSourceString().Computed().Description("An auto-generated identifier that includes the timestamp when this data source was last modified.").Build(), - "ids": util.DataSourceList(types.StringType).Optional().Description("A filter to search by a list of IDs..").Build(), + "ids": util.DataSourceList(types.StringType).Optional().Description("A filter to search by a list of IDs.").Build(), "include_system": util.DataSourceBool().Optional().Description("A filter to include system teams.").Build(), "partial_name": util.DataSourceString().Optional().Description("A filter to search by the partial match of a name.").Build(), "spaces": util.DataSourceList(types.StringType).Optional().Description("A filter to search by a list of space IDs.").Build(), @@ -46,30 +46,29 @@ func getDatasourceTeamsAttributes() datasourceSchema.ListNestedAttribute { Optional: false, NestedObject: datasourceSchema.NestedAttributeObject{ Attributes: map[string]datasourceSchema.Attribute{ - "can_be_deleted": util.DataSourceBool().Computed().Optional().Build(), - "can_be_renamed": util.DataSourceBool().Computed().Optional().Build(), - "can_change_members": util.DataSourceBool().Computed().Optional().Build(), - "can_change_roles": util.DataSourceBool().Computed().Optional().Build(), - "description": util.DataSourceString().Optional().Description("The user-friendly description of this team.").Build(), - "external_security_group": getDatasrouceExternalSecurityGroupsAttributes(), - "id": util.DataSourceString().Computed().Optional().Description("The unique ID for this resource.").Build(), - "name": util.DataSourceString().Required().Description("The name of this team.").Build(), - "space_id": util.DataSourceString().Computed().Optional().Description("The space associated with this team.").Build(), - "users": util.DataSourceSet(types.StringType).Computed().Optional().Description("A list of user IDs designated to be members of this team.").Build(), + "can_be_deleted": util.DataSourceBool().Computed().Build(), + "can_be_renamed": util.DataSourceBool().Computed().Build(), + "can_change_members": util.DataSourceBool().Computed().Build(), + "can_change_roles": util.DataSourceBool().Computed().Build(), + "description": util.DataSourceString().Computed().Description("The user-friendly description of this team.").Build(), + "external_security_group": getDatasourceExternalSecurityGroupsAttributes(), + "id": util.DataSourceString().Computed().Description("The unique ID for this resource.").Build(), + "name": util.DataSourceString().Computed().Description("The name of this team.").Build(), + "space_id": util.DataSourceString().Computed().Description("The space associated with this team.").Build(), + "users": util.DataSourceSet(types.StringType).Computed().Description("A list of user IDs designated to be members of this team.").Build(), }, }, } } -func getDatasrouceExternalSecurityGroupsAttributes() datasourceSchema.ListNestedAttribute { +func getDatasourceExternalSecurityGroupsAttributes() datasourceSchema.ListNestedAttribute { return datasourceSchema.ListNestedAttribute{ - Computed: false, - Optional: true, + Computed: true, NestedObject: datasourceSchema.NestedAttributeObject{ Attributes: map[string]datasourceSchema.Attribute{ - "display_id_and_name": util.DataSourceBool().Computed().Optional().Build(), - "display_name": util.DataSourceString().Computed().Optional().Build(), - "id": util.DataSourceString().Computed().Optional().Description("The unique ID for this resource.").Build(), + "display_id_and_name": util.DataSourceBool().Computed().Build(), + "display_name": util.DataSourceString().Computed().Build(), + "id": util.DataSourceString().Computed().Description("The unique ID for this resource.").Build(), }, }, }