Skip to content

Commit 03f545c

Browse files
use format.CtyPath for formatting go-cty paths
1 parent f06653d commit 03f545c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/deprecation/schema.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ package deprecation
55

66
import (
77
"fmt"
8+
"strings"
89

910
"github.com/hashicorp/terraform/internal/configs/configschema"
11+
"github.com/hashicorp/terraform/internal/lang/format"
1012
"github.com/hashicorp/terraform/internal/lang/marks"
1113
"github.com/zclconf/go-cty/cty"
1214
)
@@ -38,12 +40,12 @@ func MarkDeprecatedValues(val cty.Value, schema *configschema.Block, origin stri
3840

3941
attr := schema.AttributeByPath(p)
4042
if attr != nil && attr.Deprecated {
41-
v = v.Mark(marks.NewDeprecation(fmt.Sprintf("Deprecated resource attribute %q used", p), fmt.Sprintf("%s.%s", origin, p)))
43+
v = v.Mark(marks.NewDeprecation(fmt.Sprintf("Deprecated resource attribute %q used", strings.TrimPrefix(format.CtyPath(p), ".")), fmt.Sprintf("%s%s", origin, format.CtyPath(p))))
4244
}
4345

4446
block := schema.BlockByPath(p)
4547
if block != nil && block.Deprecated {
46-
v = v.Mark(marks.NewDeprecation(fmt.Sprintf("Deprecated resource block %q used", p), fmt.Sprintf("%s.%s", origin, p)))
48+
v = v.Mark(marks.NewDeprecation(fmt.Sprintf("Deprecated resource block %q used", strings.TrimPrefix(format.CtyPath(p), ".")), fmt.Sprintf("%s%s", origin, format.CtyPath(p))))
4749
}
4850

4951
return v, nil

0 commit comments

Comments
 (0)