diff --git a/internal/flex/write_only.go b/internal/flex/write_only.go index d9aeaafb5f07..5e8cb06fb2ae 100644 --- a/internal/flex/write_only.go +++ b/internal/flex/write_only.go @@ -15,14 +15,14 @@ type writeOnlyAttrGetter interface { } // GetWriteOnlyStringValue returns the string value of the write-only attribute from the config. -func GetWriteOnlyStringValue(d writeOnlyAttrGetter, path cty.Path, attrType cty.Type) (string, diag.Diagnostics) { - valueWO, diags := GetWriteOnlyValue(d, path, attrType) +func GetWriteOnlyStringValue(d writeOnlyAttrGetter, path cty.Path) (string, diag.Diagnostics) { + valueWO, diags := GetWriteOnlyValue(d, path, cty.String) if diags.HasError() { return "", diags } var value string - if attrType == cty.String && !valueWO.IsNull() { + if !valueWO.IsNull() { value = valueWO.AsString() } diff --git a/internal/flex/write_only_test.go b/internal/flex/write_only_test.go index 4a51e3896ea7..4934285c26e5 100644 --- a/internal/flex/write_only_test.go +++ b/internal/flex/write_only_test.go @@ -90,21 +90,18 @@ func TestGetWriteOnlyStringValue(t *testing.T) { testCases := map[string]struct { input cty.Path setPath cty.Path - inputType cty.Type value cty.Value expectedValue string }{ "valid value": { input: cty.GetAttrPath("test_path"), setPath: cty.GetAttrPath("test_path"), - inputType: cty.String, value: cty.StringVal("test_value"), expectedValue: "test_value", }, "value empty string": { input: cty.GetAttrPath("test_path"), setPath: cty.GetAttrPath("test_path"), - inputType: cty.String, value: cty.StringVal(""), expectedValue: "", }, @@ -118,7 +115,7 @@ func TestGetWriteOnlyStringValue(t *testing.T) { path: testCase.setPath, value: testCase.value, } - value, diags := flex.GetWriteOnlyStringValue(&m, testCase.input, testCase.inputType) + value, diags := flex.GetWriteOnlyStringValue(&m, testCase.input) if diags.HasError() { t.Fatalf("unexpected error: %v", diags)