Skip to content

Commit 0bec889

Browse files
Copilottobio
andcommitted
Convert schema from blocks to nested attributes
Co-authored-by: tobio <444668+tobio@users.noreply.github.com>
1 parent dd27d0a commit 0bec889

File tree

3 files changed

+33
-32
lines changed

3 files changed

+33
-32
lines changed

docs/resources/elasticsearch_alias.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ Manages an Elasticsearch alias. See, https://www.elastic.co/guide/en/elasticsear
2222

2323
### Optional
2424

25-
- `read_indices` (Block Set) Set of read indices for the alias. (see [below for nested schema](#nestedblock--read_indices))
26-
- `write_index` (Block, Optional) The write index for the alias. Only one write index is allowed per alias. (see [below for nested schema](#nestedblock--write_index))
25+
- `read_indices` (Attributes Set) Set of read indices for the alias. (see [below for nested schema](#nestedatt--read_indices))
26+
- `write_index` (Attributes) The write index for the alias. Only one write index is allowed per alias. (see [below for nested schema](#nestedatt--write_index))
2727

2828
### Read-Only
2929

3030
- `id` (String) Generated ID of the alias resource.
3131

32-
<a id="nestedblock--read_indices"></a>
32+
<a id="nestedatt--read_indices"></a>
3333
### Nested Schema for `read_indices`
3434

3535
Required:
@@ -45,7 +45,7 @@ Optional:
4545
- `search_routing` (String) Value used to route search operations to a specific shard.
4646

4747

48-
<a id="nestedblock--write_index"></a>
48+
<a id="nestedatt--write_index"></a>
4949
### Nested Schema for `write_index`
5050

5151
Required:

internal/elasticsearch/index/alias/acc_test.go

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ resource "elasticstack_elasticsearch_data_stream" "test_ds" {
214214
resource "elasticstack_elasticsearch_alias" "test_alias" {
215215
name = var.alias_name
216216
217-
write_index {
217+
write_index = {
218218
name = elasticstack_elasticsearch_data_stream.test_ds.name
219219
}
220220
}
@@ -313,7 +313,7 @@ provider "elasticstack" {
313313
resource "elasticstack_elasticsearch_alias" "test_alias" {
314314
name = var.alias_name
315315
316-
write_index {
316+
write_index = {
317317
name = var.index_name
318318
}
319319
}
@@ -342,13 +342,13 @@ provider "elasticstack" {
342342
resource "elasticstack_elasticsearch_alias" "test_alias" {
343343
name = var.alias_name
344344
345-
write_index {
345+
write_index = {
346346
name = var.index_name2
347347
}
348348
349-
read_indices {
349+
read_indices = [{
350350
name = var.index_name
351-
}
351+
}]
352352
}
353353
`
354354

@@ -375,7 +375,7 @@ provider "elasticstack" {
375375
resource "elasticstack_elasticsearch_alias" "test_alias" {
376376
name = var.alias_name
377377
378-
write_index {
378+
write_index = {
379379
name = var.index_name
380380
index_routing = "write-routing"
381381
filter = jsonencode({
@@ -385,14 +385,14 @@ resource "elasticstack_elasticsearch_alias" "test_alias" {
385385
})
386386
}
387387
388-
read_indices {
388+
read_indices = [{
389389
name = var.index_name2
390390
filter = jsonencode({
391391
term = {
392392
status = "draft"
393393
}
394394
})
395-
}
395+
}]
396396
}
397397
`
398398

@@ -424,7 +424,7 @@ provider "elasticstack" {
424424
resource "elasticstack_elasticsearch_alias" "test_alias" {
425425
name = var.alias_name
426426
427-
write_index {
427+
write_index = {
428428
name = var.index_name1
429429
}
430430
}
@@ -458,13 +458,13 @@ provider "elasticstack" {
458458
resource "elasticstack_elasticsearch_alias" "test_alias" {
459459
name = var.alias_name
460460
461-
write_index {
461+
write_index = {
462462
name = var.index_name2
463463
}
464464
465-
read_indices {
465+
read_indices = [{
466466
name = var.index_name1
467-
}
467+
}]
468468
}
469469
`
470470

@@ -496,17 +496,18 @@ provider "elasticstack" {
496496
resource "elasticstack_elasticsearch_alias" "test_alias" {
497497
name = var.alias_name
498498
499-
write_index {
499+
write_index = {
500500
name = var.index_name3
501501
}
502502
503-
read_indices {
504-
name = var.index_name1
505-
}
506-
507-
read_indices {
508-
name = var.index_name2
509-
}
503+
read_indices = [
504+
{
505+
name = var.index_name1
506+
},
507+
{
508+
name = var.index_name2
509+
}
510+
]
510511
}
511512
`
512513

@@ -538,12 +539,12 @@ provider "elasticstack" {
538539
resource "elasticstack_elasticsearch_alias" "test_alias" {
539540
name = var.alias_name
540541
541-
write_index {
542+
write_index = {
542543
name = var.index_name3
543544
}
544545
545-
read_indices {
546+
read_indices = [{
546547
name = var.index_name2
547-
}
548+
}]
548549
}
549550
`

internal/elasticsearch/index/alias/schema.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ func (r *aliasResource) Schema(ctx context.Context, req resource.SchemaRequest,
3131
stringplanmodifier.RequiresReplace(),
3232
},
3333
},
34-
},
35-
Blocks: map[string]schema.Block{
36-
"write_index": schema.SingleNestedBlock{
34+
"write_index": schema.SingleNestedAttribute{
3735
Description: "The write index for the alias. Only one write index is allowed per alias.",
36+
Optional: true,
3837
Attributes: map[string]schema.Attribute{
3938
"name": schema.StringAttribute{
4039
Description: "Name of the write index.",
@@ -65,9 +64,10 @@ func (r *aliasResource) Schema(ctx context.Context, req resource.SchemaRequest,
6564
},
6665
},
6766
},
68-
"read_indices": schema.SetNestedBlock{
67+
"read_indices": schema.SetNestedAttribute{
6968
Description: "Set of read indices for the alias.",
70-
NestedObject: schema.NestedBlockObject{
69+
Optional: true,
70+
NestedObject: schema.NestedAttributeObject{
7171
Attributes: map[string]schema.Attribute{
7272
"name": schema.StringAttribute{
7373
Description: "Name of the read index.",

0 commit comments

Comments
 (0)