Skip to content

Commit 858e669

Browse files
committed
Tidy up
1 parent 8a64b68 commit 858e669

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

docs/resources/elasticsearch_alias.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
page_title: "elasticstack_elasticsearch_alias Resource - terraform-provider-elasticstack"
55
subcategory: "Elasticsearch"
66
description: |-
7-
Manages an Elasticsearch alias. See the alias documentation for more details.
7+
Manages an Elasticsearch alias. See the alias documentation https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html for more details.
88
---
99

1010
# elasticstack_elasticsearch_alias (Resource)
1111

12-
Manages an Elasticsearch alias. See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html">alias documentation</a> for more details.
12+
Manages an Elasticsearch alias. See the [alias documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html) for more details.
1313

1414

1515

internal/elasticsearch/index/alias/models.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/elastic/terraform-provider-elasticstack/internal/models"
88
"github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes"
9-
"github.com/hashicorp/terraform-plugin-framework/attr"
109
"github.com/hashicorp/terraform-plugin-framework/diag"
1110
"github.com/hashicorp/terraform-plugin-framework/types"
1211
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
@@ -61,18 +60,18 @@ func (model *tfModel) populateFromAPI(ctx context.Context, aliasName string, ind
6160

6261
// Set write index
6362
if writeIndex != nil {
64-
writeIndexObj, diags := types.ObjectValueFrom(ctx, indexModel{}.attrTypes(), *writeIndex)
63+
writeIndexObj, diags := types.ObjectValueFrom(ctx, getIndexAttrTypes(), *writeIndex)
6564
if diags.HasError() {
6665
return diags
6766
}
6867
model.WriteIndex = writeIndexObj
6968
} else {
70-
model.WriteIndex = types.ObjectNull(indexModel{}.attrTypes())
69+
model.WriteIndex = types.ObjectNull(getIndexAttrTypes())
7170
}
7271

7372
// Set read indices
7473
readIndicesSet, diags := types.SetValueFrom(ctx, types.ObjectType{
75-
AttrTypes: indexModel{}.attrTypes(),
74+
AttrTypes: getIndexAttrTypes(),
7675
}, readIndices)
7776
if diags.HasError() {
7877
return diags
@@ -174,8 +173,3 @@ func indexToConfig(index indexModel, isWriteIndex bool) (AliasIndexConfig, diag.
174173

175174
return config, nil
176175
}
177-
178-
// Helper functions for attribute types
179-
func (indexModel) attrTypes() map[string]attr.Type {
180-
return getIndexAttrTypes()
181-
}

internal/elasticsearch/index/alias/read.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ func readAliasIntoModel(ctx context.Context, client *clients.ApiClient, aliasNam
4848
// If no indices returned, the alias doesn't exist
4949
if len(indices) == 0 {
5050
// Set both to null to indicate the alias doesn't exist
51-
model.WriteIndex = types.ObjectNull(indexModel{}.attrTypes())
52-
model.ReadIndices = types.SetNull(types.ObjectType{AttrTypes: indexModel{}.attrTypes()})
51+
model.WriteIndex = types.ObjectNull(getIndexAttrTypes())
52+
model.ReadIndices = types.SetNull(types.ObjectType{AttrTypes: getIndexAttrTypes()})
5353
return nil
5454
}
5555

@@ -63,8 +63,8 @@ func readAliasIntoModel(ctx context.Context, client *clients.ApiClient, aliasNam
6363

6464
if len(aliasData) == 0 {
6565
// Set both to null to indicate the alias doesn't exist
66-
model.WriteIndex = types.ObjectNull(indexModel{}.attrTypes())
67-
model.ReadIndices = types.SetNull(types.ObjectType{AttrTypes: indexModel{}.attrTypes()})
66+
model.WriteIndex = types.ObjectNull(getIndexAttrTypes())
67+
model.ReadIndices = types.SetNull(types.ObjectType{AttrTypes: getIndexAttrTypes()})
6868
return nil
6969
}
7070

internal/elasticsearch/index/alias/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func (r *aliasResource) Schema(ctx context.Context, req resource.SchemaRequest,
1919
func getSchema() schema.Schema {
2020
return schema.Schema{
2121
Description: "Manages an Elasticsearch alias. " +
22-
"See the <a href=\"https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html\">alias documentation</a> for more details.",
22+
"See the [alias documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html) for more details.",
2323

2424
Attributes: map[string]schema.Attribute{
2525
"id": schema.StringAttribute{

0 commit comments

Comments
 (0)