From 7bdb7dd395780673775256e632c7f5f6cd690046 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Thu, 17 Jun 2021 12:58:57 +0100 Subject: [PATCH] tfexec: Improve error message for incompatible version --- tfexec/exit_errors.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tfexec/exit_errors.go b/tfexec/exit_errors.go index 5596fa2a..359e6ad0 100644 --- a/tfexec/exit_errors.go +++ b/tfexec/exit_errors.go @@ -243,5 +243,16 @@ type ErrTFVersionMismatch struct { } func (e *ErrTFVersionMismatch) Error() string { - return "terraform core version not supported by configuration" + version := "version" + if e.TFVersion != "" { + version = e.TFVersion + } + + requirement := "" + if e.Constraint != "" { + requirement = fmt.Sprintf(" (%s required)", e.Constraint) + } + + return fmt.Sprintf("terraform %s not supported by configuration%s", + version, requirement) }