Skip to content

Commit 3c96fec

Browse files
committed
Addressing PR comments.
1 parent ea8e074 commit 3c96fec

File tree

8 files changed

+17
-15
lines changed

8 files changed

+17
-15
lines changed

internal/kibana/maintenance_window/create.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/elastic/terraform-provider-elasticstack/internal/utils"
88
"github.com/hashicorp/go-version"
99
"github.com/hashicorp/terraform-plugin-framework/resource"
10+
"github.com/hashicorp/terraform-plugin-framework/types"
1011
)
1112

1213
func (r *MaintenanceWindowResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
@@ -74,6 +75,9 @@ func (r *MaintenanceWindowResource) Create(ctx context.Context, req resource.Cre
7475
return
7576
}
7677

78+
planMaintenanceWindow.ID = types.StringValue(maintenanceWindowID)
79+
planMaintenanceWindow.SpaceID = types.StringValue(spaceID)
80+
7781
diags = resp.State.Set(ctx, planMaintenanceWindow)
7882
resp.Diagnostics.Append(diags...)
7983
}

internal/kibana/maintenance_window/models.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,6 @@ func (model MaintenanceWindowModel) getMaintenanceWindowIDAndSpaceID() (maintena
157157
func (model *MaintenanceWindowModel) _fromAPIResponse(ctx context.Context, response ResponseJson) diag.Diagnostics {
158158
var diags = diag.Diagnostics{}
159159

160-
resourceID := clients.CompositeId{
161-
ClusterId: model.SpaceID.ValueString(),
162-
ResourceId: response.Id,
163-
}
164-
165-
model.ID = types.StringValue(resourceID.String())
166160
model.Title = types.StringValue(response.Title)
167161
model.Enabled = types.BoolValue(response.Enabled)
168162

internal/kibana/maintenance_window/read.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/elastic/terraform-provider-elasticstack/internal/clients/kibana_oapi"
77
"github.com/hashicorp/terraform-plugin-framework/path"
88
"github.com/hashicorp/terraform-plugin-framework/resource"
9+
"github.com/hashicorp/terraform-plugin-framework/types"
910
)
1011

1112
func (r *MaintenanceWindowResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
@@ -53,6 +54,9 @@ func (r *MaintenanceWindowResource) Read(ctx context.Context, req resource.ReadR
5354
return
5455
}
5556

57+
stateModel.ID = types.StringValue(maintenanceWindowID)
58+
stateModel.SpaceID = types.StringValue(spaceID)
59+
5660
diags = resp.State.Set(ctx, stateModel)
5761
resp.Diagnostics.Append(diags...)
5862
}

internal/kibana/maintenance_window/update.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/elastic/terraform-provider-elasticstack/internal/clients/kibana_oapi"
77
"github.com/hashicorp/terraform-plugin-framework/resource"
8+
"github.com/hashicorp/terraform-plugin-framework/types"
89
)
910

1011
func (r *MaintenanceWindowResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
@@ -71,6 +72,9 @@ func (r *MaintenanceWindowResource) Update(ctx context.Context, req resource.Upd
7172
return
7273
}
7374

75+
planMaintenanceWindow.ID = types.StringValue(maintenanceWindowID)
76+
planMaintenanceWindow.SpaceID = types.StringValue(spaceID)
77+
7478
diags = resp.State.Set(ctx, planMaintenanceWindow)
7579
resp.Diagnostics.Append(diags...)
7680
}

internal/kibana/validators/is_alerting_duration.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package validators
22

33
import (
44
"context"
5-
"fmt"
65
"regexp"
76

87
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
@@ -35,7 +34,7 @@ func (s StringIsAlertingDuration) ValidateString(_ context.Context, req validato
3534
resp.Diagnostics.AddAttributeError(
3635
req.Path,
3736
"expected value to be a valid alerting duration",
38-
fmt.Sprintf("This value must be a valid alerting duration in seconds (s), minutes (m), hours (h), or days (d) %s", err),
37+
"This value must be a valid alerting duration in seconds (s), minutes (m), hours (h), or days (d).",
3938
)
4039
return
4140
}
@@ -46,5 +45,5 @@ func (s StringIsAlertingDuration) ValidateString(_ context.Context, req validato
4645
//nolint:staticcheck
4746
func StringIsAlertingDurationSDKV2() schema.SchemaValidateFunc {
4847
r := regexp.MustCompile(alertingDurationPattern)
49-
return validation.StringMatch(r, "string is not a valid Alerting duration in seconds (s), minutes (m), hours (h), or days (d)")
48+
return validation.StringMatch(r, "string is not a valid Alerting duration in seconds (s), minutes (m), hours (h), or days (d).")
5049
}

internal/kibana/validators/is_iso8601_string.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package validators
22

33
import (
44
"context"
5-
"fmt"
65
"regexp"
76

87
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
@@ -32,7 +31,7 @@ func (s StringIsISO8601) ValidateString(_ context.Context, req validator.StringR
3231
resp.Diagnostics.AddAttributeError(
3332
req.Path,
3433
"expected value to be a valid ISO8601 string",
35-
fmt.Sprintf("This value must be a valid ISO8601 date and time formatted string %s", err),
34+
"This value must be a valid ISO8601 date and time formatted string.",
3635
)
3736
return
3837
}

internal/kibana/validators/is_maintenance_window_interval.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package validators
22

33
import (
44
"context"
5-
"fmt"
65
"regexp"
76

87
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
@@ -32,7 +31,7 @@ func (s StringIsMaintenanceWindowIntervalFrequency) ValidateString(_ context.Con
3231
resp.Diagnostics.AddAttributeError(
3332
req.Path,
3433
"expected value to be a valid interval/frequency",
35-
fmt.Sprintf("This value must be a valid interval/frequency. Allowed values are in the `<integer><unit>` format. `<unit>` is one of `d`, `w`, `M`, or `y` for days, weeks, months, years. For example: `15d`, `2w`, `3m`, `1y`. %s", err),
34+
"This value must be a valid interval/frequency. Allowed values are in the `<integer><unit>` format. `<unit>` is one of `d`, `w`, `M`, or `y` for days, weeks, months, years. For example: `15d`, `2w`, `3m`, `1y`.",
3635
)
3736
return
3837
}

internal/kibana/validators/is_maintenance_window_week_day.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package validators
22

33
import (
44
"context"
5-
"fmt"
65
"regexp"
76

87
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
@@ -32,7 +31,7 @@ func (s StringIsMaintenanceWindowOnWeekDay) ValidateString(_ context.Context, re
3231
resp.Diagnostics.AddAttributeError(
3332
req.Path,
3433
"expected value to be a valid OnWeekDay",
35-
fmt.Sprintf("This value must be a valid OnWeekDay. Accepted values are specific days of the week (`[MO,TU,WE,TH,FR,SA,SU]`) or nth day of month (`[+1MO, -3FR, +2WE, -4SA, -5SU]`). %s", err),
34+
"This value must be a valid OnWeekDay. Accepted values are specific days of the week (`[MO,TU,WE,TH,FR,SA,SU]`) or nth day of month (`[+1MO, -3FR, +2WE, -4SA, -5SU]`).",
3635
)
3736
return
3837
}

0 commit comments

Comments
 (0)