From 25337b7217f156b50d0de3d2cea797dbd5eb84e7 Mon Sep 17 00:00:00 2001 From: Katy Moe Date: Tue, 11 Aug 2020 23:18:26 +0100 Subject: [PATCH] fix outdated message output order --- command/version.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/command/version.go b/command/version.go index 49f4f5f01..ea73870ef 100644 --- a/command/version.go +++ b/command/version.go @@ -53,6 +53,7 @@ Options: func (c *VersionCommand) Run(args []string) int { var outdated bool + var latest string var versionString bytes.Buffer args = c.Meta.process(args) var jsonOutput bool @@ -113,13 +114,7 @@ func (c *VersionCommand) Run(args []string) int { } if info.Outdated { outdated = true - if !jsonOutput { - c.Ui.Output(fmt.Sprintf( - "\nYour version of Terraform is out of date! The latest version\n"+ - "is %s. You can update by downloading from https://www.terraform.io/downloads.html", - info.Latest)) - } - + latest = info.Latest } } @@ -159,6 +154,12 @@ func (c *VersionCommand) Run(args []string) int { c.Ui.Output(str) } } + if outdated { + c.Ui.Output(fmt.Sprintf( + "\nYour version of Terraform is out of date! The latest version\n"+ + "is %s. You can update by downloading from https://www.terraform.io/downloads.html", + latest)) + } }