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.
This commit is contained in:
James Bardin 2017-07-14 15:52:41 -04:00
parent 87b2c0cf8f
commit 2b84e786e9
1 changed files with 6 additions and 2 deletions

View File

@ -242,7 +242,9 @@ func (i *ProviderInstaller) getProviderChecksum(name, version string) (string, e
return checksumForFile(checksums, i.providerFileName(name, version)), nil 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 { func checkPlugin(url string, pluginProtocolVersion uint) bool {
resp, err := httpClient.Head(url) resp, err := httpClient.Head(url)
if err != nil { if err != nil {
@ -257,8 +259,10 @@ func checkPlugin(url string, pluginProtocolVersion uint) bool {
proto := resp.Header.Get(protocolVersionHeader) proto := resp.Header.Get(protocolVersionHeader)
if proto == "" { 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) log.Printf("[WARNING] missing %s from: %s", protocolVersionHeader, url)
return false return true
} }
protoVersion, err := strconv.Atoi(proto) protoVersion, err := strconv.Atoi(proto)