From 2b84e786e9f77f30ea273c5275dc5c34d4e7fd1c Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 14 Jul 2017 15:52:41 -0400 Subject: [PATCH] allow missing x-terraform-protocol-version If the release site is missing the "x-terraform-protocol-version" header, we should fetch the latest spec'ed release. Downloading the wrong protocol version can't do any damage, and the version present is more than likely compatible. --- plugin/discovery/get.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugin/discovery/get.go b/plugin/discovery/get.go index e5ffeb49b..241b5cb3b 100644 --- a/plugin/discovery/get.go +++ b/plugin/discovery/get.go @@ -242,7 +242,9 @@ func (i *ProviderInstaller) getProviderChecksum(name, version string) (string, e return checksumForFile(checksums, i.providerFileName(name, version)), nil } -// Return the plugin version by making a HEAD request to the provided url +// Return the plugin version by making a HEAD request to the provided url. +// If the header is not present, we assume the latest version will be +// compatible, and leave the check for discovery or execution. func checkPlugin(url string, pluginProtocolVersion uint) bool { resp, err := httpClient.Head(url) if err != nil { @@ -257,8 +259,10 @@ func checkPlugin(url string, pluginProtocolVersion uint) bool { proto := resp.Header.Get(protocolVersionHeader) if proto == "" { + // The header isn't present, but we don't make this error fatal since + // the latest version will probably work. log.Printf("[WARNING] missing %s from: %s", protocolVersionHeader, url) - return false + return true } protoVersion, err := strconv.Atoi(proto)