Skip to content

Commit

Permalink
fix: fix datasource result blocks (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
benPearce1 authored Aug 22, 2024
1 parent 6b47b61 commit 7217313
Show file tree
Hide file tree
Showing 20 changed files with 90 additions and 74 deletions.
4 changes: 2 additions & 2 deletions docs/data-sources/environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ data "octopusdeploy_environments" "example" {

### Read-Only

- `environments` (Block List) Provides information about existing environments. (see [below for nested schema](#nestedblock--environments))
- `environments` (Attributes List) (see [below for nested schema](#nestedatt--environments))
- `id` (String) The unique ID for this resource.

<a id="nestedblock--environments"></a>
<a id="nestedatt--environments"></a>
### Nested Schema for `environments`

Read-Only:
Expand Down
4 changes: 2 additions & 2 deletions docs/data-sources/feeds.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ data "octopusdeploy_feeds" "example" {

### Read-Only

- `feeds` (Block List) (see [below for nested schema](#nestedblock--feeds))
- `feeds` (Attributes List) (see [below for nested schema](#nestedatt--feeds))
- `id` (String) The unique ID for this resource.

<a id="nestedblock--feeds"></a>
<a id="nestedatt--feeds"></a>
### Nested Schema for `feeds`

Read-Only:
Expand Down
4 changes: 2 additions & 2 deletions docs/data-sources/library_variable_sets.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Provides information about existing library variable sets.
### Read-Only

- `id` (String) The unique ID for this resource.
- `library_variable_sets` (Block List) A list of library variable sets that match the filter(s). (see [below for nested schema](#nestedblock--library_variable_sets))
- `library_variable_sets` (Attributes List) (see [below for nested schema](#nestedatt--library_variable_sets))

<a id="nestedblock--library_variable_sets"></a>
<a id="nestedatt--library_variable_sets"></a>
### Nested Schema for `library_variable_sets`

Read-Only:
Expand Down
4 changes: 2 additions & 2 deletions docs/data-sources/project_groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ 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))
- `project_groups` (Attributes List) A list of project groups that match the filter(s). (see [below for nested schema](#nestedatt--project_groups))

<a id="nestedblock--project_groups"></a>
<a id="nestedatt--project_groups"></a>
### Nested Schema for `project_groups`

Read-Only:
Expand Down
4 changes: 2 additions & 2 deletions docs/data-sources/spaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ data "octopusdeploy_spaces" "spaces" {
### 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))
- `spaces` (Attributes List) (see [below for nested schema](#nestedatt--spaces))

<a id="nestedblock--spaces"></a>
<a id="nestedatt--spaces"></a>
### Nested Schema for `spaces`

Read-Only:
Expand Down
12 changes: 6 additions & 6 deletions docs/data-sources/tag_sets.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ Provides information about existing tag sets.
### Read-Only

- `id` (String) The ID of this resource.
- `tag_sets` (List of Object) A list of tag sets that match the filter(s). (see [below for nested schema](#nestedatt--tag_sets))
- `tag_sets` (Attributes List) A list of tag sets that match the filter(s). (see [below for nested schema](#nestedatt--tag_sets))

<a id="nestedatt--tag_sets"></a>
### Nested Schema for `tag_sets`

Read-Only:

- `description` (String)
- `id` (String)
- `name` (String)
- `sort_order` (Number)
- `space_id` (String)
- `description` (String) The description of this tag set.
- `id` (String) The unique ID for this resource.
- `name` (String) The name of this resource.
- `sort_order` (Number) The sort order associated with this resource.
- `space_id` (String) The space ID associated with this resource.


4 changes: 2 additions & 2 deletions docs/data-sources/tenant_projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Provides information about existing tenants.

### Read-Only

- `tenant_projects` (Block List) A list of related tenants, projects and environments that match the filter(s). (see [below for nested schema](#nestedblock--tenant_projects))
- `tenant_projects` (Attributes List) A list of related tenants, projects and environments that match the filter(s). (see [below for nested schema](#nestedatt--tenant_projects))

<a id="nestedblock--tenant_projects"></a>
<a id="nestedatt--tenant_projects"></a>
### Nested Schema for `tenant_projects`

Read-Only:
Expand Down
4 changes: 2 additions & 2 deletions docs/data-sources/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ data "octopusdeploy_variables" "example" {

- `name` (String) The name of variable to find.
- `owner_id` (String) Owner ID for the variable to find.
- `scope` (Attributes List) As variable names can appear more than once under different scopes, a VariableScope must also be provided (see [below for nested schema](#nestedatt--scope))

### Optional

- `scope` (Block List) As variable names can appear more than once under different scopes, a VariableScope must also be provided (see [below for nested schema](#nestedblock--scope))
- `space_id` (String) A Space ID to filter by. Will revert what is specified on the provider if not set.

### Read-Only
Expand All @@ -41,7 +41,7 @@ data "octopusdeploy_variables" "example" {
- `type` (String) The type of variable represented by this resource. Valid types are `AmazonWebServicesAccount`, `AzureAccount`, `GoogleCloudAccount`, `UsernamePasswordAccount`, `Certificate`, `Sensitive`, `String`, `WorkerPool`.
- `value` (String)

<a id="nestedblock--scope"></a>
<a id="nestedatt--scope"></a>
### Nested Schema for `scope`

Optional:
Expand Down
9 changes: 4 additions & 5 deletions octopusdeploy_framework/datasource_environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ func (*environmentDataSource) Schema(_ context.Context, req datasource.SchemaReq

//response
"id": schemas.GetIdDatasourceSchema(true),
},
Blocks: map[string]schema.Block{
"environments": schema.ListNestedBlock{
Description: "Provides information about existing environments.",
NestedObject: schema.NestedBlockObject{
"environments": schema.ListNestedAttribute{
Computed: true,
Optional: false,
NestedObject: schema.NestedAttributeObject{
Attributes: schemas.GetEnvironmentDatasourceSchema(),
},
},
Expand Down
7 changes: 0 additions & 7 deletions octopusdeploy_framework/datasource_feeds.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ func (*feedsDataSource) Schema(_ context.Context, req datasource.SchemaRequest,
resp.Schema = datasourceSchema.Schema{
Description: "Provides information about existing feeds.",
Attributes: schemas.GetFeedsDataSourceSchema(),
Blocks: map[string]datasourceSchema.Block{
"feeds": datasourceSchema.ListNestedBlock{
NestedObject: datasourceSchema.NestedBlockObject{
Attributes: schemas.GetFeedDataSourceSchema(),
},
},
},
}
}

Expand Down
7 changes: 3 additions & 4 deletions octopusdeploy_framework/datasource_project_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ func (p *projectGroupsDataSource) Schema(_ context.Context, _ datasource.SchemaR

// response
"id": schemas.GetIdDatasourceSchema(true),
},
Blocks: map[string]schema.Block{
"project_groups": schema.ListNestedBlock{
"project_groups": schema.ListNestedAttribute{
Computed: true,
Description: "A list of project groups that match the filter(s).",
NestedObject: schema.NestedBlockObject{
NestedObject: schema.NestedAttributeObject{
Attributes: schemas.GetProjectGroupDatasourceSchema(),
},
},
Expand Down
9 changes: 4 additions & 5 deletions octopusdeploy_framework/datasource_spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ func (*spacesDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, r

// response
"id": schemas.GetIdDatasourceSchema(true),
},
Blocks: map[string]schema.Block{
"spaces": schema.ListNestedBlock{
Description: "Provides information about existing spaces.",
NestedObject: schema.NestedBlockObject{
"spaces": schema.ListNestedAttribute{
Computed: true,
Optional: false,
NestedObject: schema.NestedAttributeObject{
Attributes: schemas.GetSpacesDatasourceSchema(),
},
},
Expand Down
8 changes: 4 additions & 4 deletions octopusdeploy_framework/datasource_tenant_projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ func (*tenantProjectsDataSource) Schema(_ context.Context, req datasource.Schema
"project_ids": schemas.GetQueryIDsDatasourceSchema(),
"environment_ids": schemas.GetQueryIDsDatasourceSchema(),
"space_id": schemas.GetSpaceIdDatasourceSchema("tenant projects", false),
},
Blocks: map[string]datasourceSchema.Block{
"tenant_projects": datasourceSchema.ListNestedBlock{
"tenant_projects": datasourceSchema.ListNestedAttribute{
Computed: true,
Optional: false,
Description: "A list of related tenants, projects and environments that match the filter(s).",
NestedObject: datasourceSchema.NestedBlockObject{
NestedObject: datasourceSchema.NestedAttributeObject{
Attributes: map[string]datasourceSchema.Attribute{
"id": schemas.GetIdDatasourceSchema(true),
"tenant_id": datasourceSchema.StringAttribute{
Expand Down
7 changes: 7 additions & 0 deletions octopusdeploy_framework/schemas/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ func GetFeedsDataSourceSchema() map[string]datasourceSchema.Attribute {

// response
"id": GetIdDatasourceSchema(true),
"feeds": datasourceSchema.ListNestedAttribute{
Computed: true,
Optional: false,
NestedObject: datasourceSchema.NestedAttributeObject{
Attributes: GetFeedDataSourceSchema(),
},
},
}
}

Expand Down
1 change: 1 addition & 0 deletions octopusdeploy_framework/schemas/gitCredential.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func GetGitCredentialDataSourceSchema() datasourceSchema.Schema {
"take": util.DataSourceInt64().Optional().Description("The number of records to take.").Build(),
"git_credentials": datasourceSchema.ListNestedAttribute{
Computed: true,
Optional: false,
Description: "Provides information about existing GitCredentials.",
NestedObject: datasourceSchema.NestedAttributeObject{
Attributes: GetGitCredentialDatasourceAttributes(),
Expand Down
35 changes: 15 additions & 20 deletions octopusdeploy_framework/schemas/library_variable_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,29 @@ type LibraryVariableSetResourceModel struct {

func GetLibraryVariableSetDataSourceSchema() datasourceSchema.Schema {
return datasourceSchema.Schema{
Attributes: getLibraryVariableSetDataSchema(),
Description: "Provides information about existing library variable sets.",
Blocks: map[string]datasourceSchema.Block{
"library_variable_sets": datasourceSchema.ListNestedBlock{
Description: "A list of library variable sets that match the filter(s).",
NestedObject: datasourceSchema.NestedBlockObject{
Attributes: map[string]datasourceSchema.Attribute{
"content_type": datasourceSchema.StringAttribute{
Description: "A filter to search by content type.",
Optional: true,
},
"id": GetIdDatasourceSchema(true),
"space_id": GetSpaceIdDatasourceSchema("library variable set", false),
"ids": util.GetQueryIDsDatasourceSchema(),
"partial_name": util.GetQueryPartialNameDatasourceSchema(),
"skip": util.GetQuerySkipDatasourceSchema(),
"take": util.GetQueryTakeDatasourceSchema(),
"library_variable_sets": datasourceSchema.ListNestedAttribute{
Computed: true,
Optional: false,
NestedObject: datasourceSchema.NestedAttributeObject{
Attributes: GetLibraryVariableSetObjectDatasourceSchema(),
},
},
},
}
}

func getLibraryVariableSetDataSchema() map[string]datasourceSchema.Attribute {
return map[string]datasourceSchema.Attribute{
"content_type": datasourceSchema.StringAttribute{
Description: "A filter to search by content type.",
Optional: true,
},
"id": GetIdDatasourceSchema(true),
"space_id": GetSpaceIdDatasourceSchema("library variable set", false),
"ids": util.GetQueryIDsDatasourceSchema(),
"partial_name": util.GetQueryPartialNameDatasourceSchema(),
"skip": util.GetQuerySkipDatasourceSchema(),
"take": util.GetQueryTakeDatasourceSchema(),
}
}

func GetLibraryVariableSetObjectDatasourceSchema() map[string]datasourceSchema.Attribute {
return map[string]datasourceSchema.Attribute{
"description": GetReadonlyDescriptionDatasourceSchema("library variable set"),
Expand Down
1 change: 1 addition & 0 deletions octopusdeploy_framework/schemas/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func getResourceRetentionPolicyBlockSchema() resourceSchema.ListNestedBlock {
func getLifecyclesAttribute() datasourceSchema.ListNestedAttribute {
return datasourceSchema.ListNestedAttribute{
Computed: true,
Optional: false,
NestedObject: datasourceSchema.NestedAttributeObject{
Attributes: map[string]datasourceSchema.Attribute{
"id": util.DataSourceString().Computed().Description("The ID of the lifecycle.").Build(),
Expand Down
28 changes: 26 additions & 2 deletions octopusdeploy_framework/schemas/tag_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,34 @@ func GetTagSetDataSourceSchema() datasourceSchema.Schema {
Optional().
Description("A filter to specify the number of items to take (or return) in the response.").
Build(),
"tag_sets": datasourceSchema.ListAttribute{
"tag_sets": datasourceSchema.ListNestedAttribute{
Computed: true,
ElementType: types.ObjectType{AttrTypes: GetTagSetAttrTypes()},
Optional: false,
Description: "A list of tag sets that match the filter(s).",
NestedObject: datasourceSchema.NestedAttributeObject{
Attributes: map[string]datasourceSchema.Attribute{
"id": util.DataSourceString().
Computed().
Description("The unique ID for this resource.").
Build(),
"name": util.DataSourceString().
Computed().
Description("The name of this resource.").
Build(),
"description": util.DataSourceString().
Computed().
Description("The description of this tag set.").
Build(),
"sort_order": util.DataSourceInt64().
Computed().
Description("The sort order associated with this resource.").
Build(),
"space_id": util.DataSourceString().
Computed().
Description("The space ID associated with this resource.").
Build(),
},
},
},
},
}
Expand Down
4 changes: 1 addition & 3 deletions octopusdeploy_framework/schemas/variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ func GetVariableDatasourceSchema() datasourceSchema.Schema {
Computed: true,
},
VariableSchemaAttributeNames.Prompt: getVariablePromptDatasourceSchema(),
},
Blocks: map[string]datasourceSchema.Block{
VariableSchemaAttributeNames.Scope: getVariableScopeDatasourceSchema(),
VariableSchemaAttributeNames.Scope: getVariableScopeDatasourceSchema(),
},
}
}
Expand Down
8 changes: 4 additions & 4 deletions octopusdeploy_framework/schemas/variable_scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ func getVariableScopeFieldResourceSchema(scopeDescription string) resourceSchema
}
}

func getVariableScopeDatasourceSchema() datasourceSchema.ListNestedBlock {
return datasourceSchema.ListNestedBlock{
func getVariableScopeDatasourceSchema() datasourceSchema.ListNestedAttribute {
return datasourceSchema.ListNestedAttribute{
Description: "As variable names can appear more than once under different scopes, a VariableScope must also be provided",
NestedObject: datasourceSchema.NestedBlockObject{
Required: true,
NestedObject: datasourceSchema.NestedAttributeObject{
Attributes: map[string]datasourceSchema.Attribute{
variableScopeFieldNames.Actions: getVariableScopeFieldDatasourceSchema(variableScopeFieldNames.Actions),
variableScopeFieldNames.Channels: getVariableScopeFieldDatasourceSchema(variableScopeFieldNames.Channels),
Expand All @@ -143,7 +144,6 @@ func getVariableScopeDatasourceSchema() datasourceSchema.ListNestedBlock {
},
},
Validators: []validator.List{
listvalidator.IsRequired(),
listvalidator.SizeAtMost(1),
},
}
Expand Down

0 comments on commit 7217313

Please sign in to comment.