From 13881dc73aede7a7b143dc30639cd87f615e9087 Mon Sep 17 00:00:00 2001
From: Isaac Calligeros <101079287+IsaacCalligeros95@users.noreply.github.com>
Date: Tue, 20 Aug 2024 11:31:44 +0930
Subject: [PATCH] Chore!: Fix data source lists should be read only (#758)
* Update spaces and project group data sources
* Fix space datasource schema
* Fix AGF description
---
docs/data-sources/project_groups.md | 9 ++---
docs/data-sources/spaces.md | 7 ++--
docs/resources/artifactory_generic_feed.md | 2 +-
octopusdeploy_framework/datasource_spaces.go | 2 +-
.../schemas/artifactory_generic_feed.go | 2 +-
.../schemas/project_group.go | 6 ++--
octopusdeploy_framework/schemas/space.go | 33 +++++++++++++++++++
7 files changed, 44 insertions(+), 17 deletions(-)
diff --git a/docs/data-sources/project_groups.md b/docs/data-sources/project_groups.md
index f5a44f739..d956ca1b3 100644
--- a/docs/data-sources/project_groups.md
+++ b/docs/data-sources/project_groups.md
@@ -28,7 +28,6 @@ data "octopusdeploy_project_groups" "example" {
- `ids` (List of String) A filter to search by a list of IDs.
- `partial_name` (String) A filter to search by a partial name.
-- `project_groups` (Block List) A list of project groups that match the filter(s). (see [below for nested schema](#nestedblock--project_groups))
- `skip` (Number) A filter to specify the number of items to skip in the response.
- `space_id` (String) The space ID associated with this project group.
- `take` (Number) A filter to specify the number of items to take (or return) in the response.
@@ -36,18 +35,16 @@ data "octopusdeploy_project_groups" "example" {
### Read-Only
- `id` (String) The unique ID for this resource.
+- `project_groups` (Block List) A list of project groups that match the filter(s). (see [below for nested schema](#nestedblock--project_groups))
### Nested Schema for `project_groups`
-Optional:
+Read-Only:
- `description` (String) The description of this project group.
- `id` (String) The unique ID for this resource.
-- `space_id` (String) The space ID associated with this project group.
-
-Read-Only:
-
- `name` (String) The name of this resource.
+- `space_id` (String) The space ID associated with this project group.
diff --git a/docs/data-sources/spaces.md b/docs/data-sources/spaces.md
index ff5ae2193..612366c9e 100644
--- a/docs/data-sources/spaces.md
+++ b/docs/data-sources/spaces.md
@@ -29,26 +29,23 @@ data "octopusdeploy_spaces" "spaces" {
- `ids` (List of String) A filter to search by a list of IDs.
- `partial_name` (String) A filter to search by a partial name.
- `skip` (Number) A filter to specify the number of items to skip in the response.
-- `spaces` (Block List) Provides information about existing spaces. (see [below for nested schema](#nestedblock--spaces))
- `take` (Number) A filter to specify the number of items to take (or return) in the response.
### Read-Only
- `id` (String) The unique ID for this resource.
+- `spaces` (Block List) Provides information about existing spaces. (see [below for nested schema](#nestedblock--spaces))
### Nested Schema for `spaces`
-Required:
-
-- `name` (String) The name of this resource, no more than 20 characters long
-
Read-Only:
- `description` (String) The description of this space.
- `id` (String) The unique ID for this resource.
- `is_default` (Boolean) Specifies if this space is the default space in Octopus.
- `is_task_queue_stopped` (Boolean) Specifies the status of the task queue for this space.
+- `name` (String) The name of this resource, no more than 20 characters long
- `slug` (String) The unique slug of this space
- `space_managers_team_members` (Set of String) A list of user IDs designated to be managers of this space.
- `space_managers_teams` (Set of String) A list of team IDs designated to be managers of this space.
diff --git a/docs/resources/artifactory_generic_feed.md b/docs/resources/artifactory_generic_feed.md
index 4fbad74b8..2ae2cbf7e 100644
--- a/docs/resources/artifactory_generic_feed.md
+++ b/docs/resources/artifactory_generic_feed.md
@@ -38,7 +38,7 @@ resource "octopusdeploy_artifactory_generic_feed" "example" {
- `layout_regex` (String)
- `package_acquisition_location_options` (List of String)
- `password` (String, Sensitive) The password associated with this resource.
-- `space_id` (String) The space ID associated with this helm feed.
+- `space_id` (String) The space ID associated with this artifactory generic feed.
- `username` (String, Sensitive) The username associated with this resource.
## Import
diff --git a/octopusdeploy_framework/datasource_spaces.go b/octopusdeploy_framework/datasource_spaces.go
index 00ba2352c..1e447e16b 100644
--- a/octopusdeploy_framework/datasource_spaces.go
+++ b/octopusdeploy_framework/datasource_spaces.go
@@ -48,7 +48,7 @@ func (*spacesDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, r
"spaces": schema.ListNestedBlock{
Description: "Provides information about existing spaces.",
NestedObject: schema.NestedBlockObject{
- Attributes: schemas.GetSpaceDatasourceSchema(),
+ Attributes: schemas.GetSpacesDatasourceSchema(),
},
},
},
diff --git a/octopusdeploy_framework/schemas/artifactory_generic_feed.go b/octopusdeploy_framework/schemas/artifactory_generic_feed.go
index aecde79de..375c3c331 100644
--- a/octopusdeploy_framework/schemas/artifactory_generic_feed.go
+++ b/octopusdeploy_framework/schemas/artifactory_generic_feed.go
@@ -17,7 +17,7 @@ func GetArtifactoryGenericFeedResourceSchema() map[string]resourceSchema.Attribu
"name": util.GetNameResourceSchema(true),
"package_acquisition_location_options": util.GetPackageAcquisitionLocationOptionsResourceSchema(),
"password": util.GetPasswordResourceSchema(false),
- "space_id": util.GetSpaceIdResourceSchema(helmFeedDescription),
+ "space_id": util.GetSpaceIdResourceSchema(artifactoryGenericFeedDescription),
"username": util.GetUsernameResourceSchema(false),
"repository": resourceSchema.StringAttribute{
Computed: false,
diff --git a/octopusdeploy_framework/schemas/project_group.go b/octopusdeploy_framework/schemas/project_group.go
index d683f018f..a3731d9a9 100644
--- a/octopusdeploy_framework/schemas/project_group.go
+++ b/octopusdeploy_framework/schemas/project_group.go
@@ -11,10 +11,10 @@ const projectGroupDescription = "project group"
func GetProjectGroupDatasourceSchema() map[string]datasourceSchema.Attribute {
return map[string]datasourceSchema.Attribute{
- "id": util.GetIdResourceSchema(),
- "space_id": util.GetSpaceIdResourceSchema(projectGroupDescription),
+ "id": GetIdDatasourceSchema(true),
+ "space_id": GetSpaceIdDatasourceSchema(projectGroupDescription, true),
"name": GetReadonlyNameDatasourceSchema(),
- "description": util.GetDescriptionResourceSchema(projectGroupDescription),
+ "description": GetReadonlyDescriptionDatasourceSchema(projectGroupDescription),
}
}
diff --git a/octopusdeploy_framework/schemas/space.go b/octopusdeploy_framework/schemas/space.go
index 0c1159553..46342961a 100644
--- a/octopusdeploy_framework/schemas/space.go
+++ b/octopusdeploy_framework/schemas/space.go
@@ -58,6 +58,39 @@ func GetSpaceResourceSchema() map[string]resourceSchema.Attribute {
}
}
+func GetSpacesDatasourceSchema() map[string]datasourceSchema.Attribute {
+ return map[string]datasourceSchema.Attribute{
+ "id": GetIdDatasourceSchema(true),
+ "description": GetReadonlyDescriptionDatasourceSchema(spaceDescription),
+ "name": datasourceSchema.StringAttribute{
+ Description: fmt.Sprintf("The name of this resource, no more than %d characters long", 20),
+ Validators: []validator.String{
+ stringvalidator.LengthBetween(1, 20),
+ },
+ Computed: true,
+ },
+ "slug": GetSlugDatasourceSchema(spaceDescription, true),
+ "space_managers_teams": datasourceSchema.SetAttribute{
+ ElementType: types.StringType,
+ Description: "A list of team IDs designated to be managers of this space.",
+ Computed: true,
+ },
+ "space_managers_team_members": datasourceSchema.SetAttribute{
+ ElementType: types.StringType,
+ Description: "A list of user IDs designated to be managers of this space.",
+ Computed: true,
+ },
+ "is_task_queue_stopped": datasourceSchema.BoolAttribute{
+ Description: "Specifies the status of the task queue for this space.",
+ Computed: true,
+ },
+ "is_default": datasourceSchema.BoolAttribute{
+ Description: "Specifies if this space is the default space in Octopus.",
+ Computed: true,
+ },
+ }
+}
+
func GetSpaceDatasourceSchema() map[string]datasourceSchema.Attribute {
return map[string]datasourceSchema.Attribute{
"id": GetIdDatasourceSchema(true),