Skip to content

Commit

Permalink
Chore!: Fix data source lists should be read only (#758)
Browse files Browse the repository at this point in the history
* Update spaces and project group data sources

* Fix space datasource schema

* Fix AGF description
  • Loading branch information
IsaacCalligeros95 authored Aug 20, 2024
1 parent 76e118c commit 13881dc
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 17 deletions.
9 changes: 3 additions & 6 deletions docs/data-sources/project_groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,23 @@ 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.

### 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))

<a id="nestedblock--project_groups"></a>
### 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.


7 changes: 2 additions & 5 deletions docs/data-sources/spaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

<a id="nestedblock--spaces"></a>
### 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.
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/artifactory_generic_feed.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/datasource_spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions octopusdeploy_framework/schemas/project_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}

Expand Down
33 changes: 33 additions & 0 deletions octopusdeploy_framework/schemas/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 13881dc

Please sign in to comment.