Skip to content

Commit 4572e1b

Browse files
authored
Use actual type of input value in morpher diagnostic. (#2054)
Use actual type of input value in morpher diagnostic.
1 parent 5af008f commit 4572e1b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

.changelog/2054.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
`resource/kubernetes_manifest`: Fix a panic when constructing the diagnostic message about incompatible attribute types
3+
```

manifest/morph/morph.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func morphListToType(v tftypes.Value, t tftypes.Type, p *tftypes.AttributePath)
278278
Attribute: p,
279279
Severity: tfprotov5.DiagnosticSeverityError,
280280
Summary: "Cannot transform List value into unsupported type",
281-
Detail: fmt.Sprintf("Required type %s, but got %s\n ...at attribute\n%s", typeNameNoPrefix(t), typeNameNoPrefix(tftypes.List{}), attributePathSummary(p)),
281+
Detail: fmt.Sprintf("Required type %s, but got %s\n ...at attribute\n%s", typeNameNoPrefix(t), typeNameNoPrefix(v.Type()), attributePathSummary(p)),
282282
})
283283
return tftypes.Value{}, diags
284284
}
@@ -391,7 +391,7 @@ func morphTupleIntoType(v tftypes.Value, t tftypes.Type, p *tftypes.AttributePat
391391
Attribute: p,
392392
Severity: tfprotov5.DiagnosticSeverityError,
393393
Summary: "Cannot transform Tuple value into unsupported type",
394-
Detail: fmt.Sprintf("Required type %s, but got %s\n ...at attribute\n%s", typeNameNoPrefix(t), typeNameNoPrefix(tftypes.Tuple{}), attributePathSummary(p)),
394+
Detail: fmt.Sprintf("Required type %s, but got %s\n ...at attribute\n%s", typeNameNoPrefix(t), typeNameNoPrefix(v.Type()), attributePathSummary(p)),
395395
})
396396
return tftypes.Value{}, diags
397397
}
@@ -492,7 +492,7 @@ func morphSetToType(v tftypes.Value, t tftypes.Type, p *tftypes.AttributePath) (
492492
Attribute: p,
493493
Severity: tfprotov5.DiagnosticSeverityError,
494494
Summary: "Cannot transform Set value into unsupported type",
495-
Detail: fmt.Sprintf("Required type %s, but got %s\n...at attribute:\n%s", typeNameNoPrefix(t), typeNameNoPrefix(tftypes.Set{}), attributePathSummary(p)),
495+
Detail: fmt.Sprintf("Required type %s, but got %s\n...at attribute:\n%s", typeNameNoPrefix(t), typeNameNoPrefix(v.Type()), attributePathSummary(p)),
496496
})
497497
return tftypes.Value{}, diags
498498
}
@@ -572,7 +572,7 @@ func morphMapToType(v tftypes.Value, t tftypes.Type, p *tftypes.AttributePath) (
572572
Attribute: p,
573573
Severity: tfprotov5.DiagnosticSeverityError,
574574
Summary: "Cannot transform Map value into unsupported type",
575-
Detail: fmt.Sprintf("Required type %s, but got %s\n...at attribute:\n%s", typeNameNoPrefix(t), typeNameNoPrefix(tftypes.Map{}), attributePathSummary(p)),
575+
Detail: fmt.Sprintf("Required type %s, but got %s\n...at attribute:\n%s", typeNameNoPrefix(t), typeNameNoPrefix(v.Type()), attributePathSummary(p)),
576576
})
577577
return tftypes.Value{}, diags
578578
}
@@ -668,7 +668,7 @@ func morphObjectToType(v tftypes.Value, t tftypes.Type, p *tftypes.AttributePath
668668
Attribute: p,
669669
Severity: tfprotov5.DiagnosticSeverityError,
670670
Summary: "Failed to transform Object into unsupported type",
671-
Detail: fmt.Sprintf("Required type %s, but got %s\n...at attribute:\n%s", typeNameNoPrefix(t), typeNameNoPrefix(tftypes.Object{}), attributePathSummary(p)),
671+
Detail: fmt.Sprintf("Required type %s, but got %s\n...at attribute:\n%s", typeNameNoPrefix(t), typeNameNoPrefix(v.Type()), attributePathSummary(p)),
672672
})
673673
return tftypes.Value{}, diags
674674
}

0 commit comments

Comments
 (0)