Update the NodeJS version compat checks. (#3083)

- Unify the 1.x.y series and the 0.17.z series
- Fix the check s.t. post-1.0, only the major versions are required to
  match
This commit is contained in:
Pat Gavlin 2019-08-13 15:40:25 -07:00 committed by GitHub
parent 2afe5b88b8
commit fdfef5f334
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 3 deletions

View file

@ -1,6 +1,11 @@
CHANGELOG
=========
## 1.0.0-beta.2 (2019-08-13)
- Fix the package version compatibility checks in the NodeJS language host.
[#3083](https://github.com/pulumi/pulumi/pull/3083)
## 1.0.0-beta.1 (2019-08-13)
- Do not propagate input properties to missing output properties during preview. The old behavior can cause issues that

View file

@ -160,6 +160,31 @@ func newLanguageHost(nodePath, runPath, engineAddress,
}
}
func compatibleVersions(a, b semver.Version) (bool, string) {
switch {
case a.Major == 0 && b.Major == 0:
// If both major versions are pre-1.0, we require that the major and minor versions match.
if a.Minor != b.Minor {
return false, "Differing major or minor versions are not supported."
}
case a.Major >= 1 && b.Major >= 1:
// If both major versions are post-1.0, we require that the major versions match.
if a.Major != b.Major {
return false, "Differing major versions are not supported."
}
case a.Major == 1 && b.Major == 0 && b.Minor == 17 || b.Major == 1 && a.Major == 0 && a.Minor == 17:
// If one version is pre-1.0 and the other is post-1.0, we unify 1.x.y and 0.17.z. This combination is legal.
default:
// All other combinations of versions are illegal.
return false, "Differing major or minor versions are not supported."
}
return true, ""
}
// GetRequiredPlugins computes the complete set of anticipated plugins required by a program.
func (host *nodeLanguageHost) GetRequiredPlugins(ctx context.Context,
req *pulumirpc.GetRequiredPluginsRequest) (*pulumirpc.GetRequiredPluginsResponse, error) {
@ -186,12 +211,12 @@ func (host *nodeLanguageHost) GetRequiredPlugins(ctx context.Context,
continue
}
if version.Major != firstVersion.Major || version.Minor != firstVersion.Minor {
if ok, message := compatibleVersions(version, firstVersion); !ok {
fmt.Fprintf(os.Stderr,
`Found incompatible versions of @pulumi/pulumi. Differing major or minor versions are not supported.
`Found incompatible versions of @pulumi/pulumi. %s
Version %s referenced at %s
Version %s referenced at %s
`, firstVersion, firstPath, version, path)
`, message, firstVersion, firstPath, version, path)
break
}
}