Skip to content

Commit b46d9da

Browse files
committed
Rename HCL_LABEL_INDEX_KEY
1 parent 92cc5d7 commit b46d9da

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cmd/packer-sdc/internal/mapstructure-to-hcl2/mapstructure-to-hcl2.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var (
5353
readme string
5454
)
5555

56-
const HCLLABELINDEXKEY = "hcllabelindex"
56+
const HCL_LABEL_INDEX_KEY = "hcllabelindex"
5757

5858
type Command struct {
5959
typeNames string
@@ -294,7 +294,7 @@ func goFieldToCtyType(accessor string, fieldType types.Type, tags *structtag.Tag
294294
case *types.Basic:
295295
if f.Kind() == types.String {
296296
hcl, err1 := tags.Get("hcl")
297-
hcllabelindex, err2 := tags.Get(HCLLABELINDEXKEY)
297+
hcllabelindex, err2 := tags.Get(HCL_LABEL_INDEX_KEY)
298298
if err1 == nil && err2 == nil && hcl.HasOption("label") {
299299
index, err := strconv.Atoi(hcllabelindex.Name)
300300
if err != nil {
@@ -397,7 +397,7 @@ func outputStructFields(w io.Writer, s *types.Struct) {
397397
if err == nil {
398398
// Remove hcllabelindex from the printout because it is not needed
399399
// in the generated struct.
400-
st.Delete(HCLLABELINDEXKEY)
400+
st.Delete(HCL_LABEL_INDEX_KEY)
401401
}
402402
fieldNameStr := field.String()
403403
fieldNameStr = strings.Replace(fieldNameStr, "field ", "", 1)
@@ -491,7 +491,7 @@ func addTagsToStruct(s *types.Struct) (*types.Struct, error) {
491491
return nil, fmt.Errorf("field %q has an hcl label struct tag but is not a string or string pointer", ctyAccessor)
492492
}
493493
hclOptions = append(hclOptions, "label")
494-
st.Set(&structtag.Tag{Key: HCLLABELINDEXKEY, Name: fmt.Sprintf("%d", hclLabelIndex)})
494+
st.Set(&structtag.Tag{Key: HCL_LABEL_INDEX_KEY, Name: fmt.Sprintf("%d", hclLabelIndex)})
495495
hclLabelIndex++
496496
if required, err := st.Get("required"); err == nil {
497497
required.Name = "true" // All labels are always required

0 commit comments

Comments
 (0)