Skip to content

Commit

Permalink
Do not flow version information with the request
Browse files Browse the repository at this point in the history
In absence of a fix for pulumi/pulumi#2753, passing a version here
means that every time you upgrade your package, all the resources it
managed will be replaced.

That's not an experience we want, so for now we are backing out this
part of the change.
  • Loading branch information
ellismg committed May 22, 2019
1 parent 31ed296 commit c2798a1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
30 changes: 16 additions & 14 deletions pkg/tfgen/generate_nodejs.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,14 +580,15 @@ func (g *nodeJSGenerator) emitResourceType(mod *module, res *resourceType) (stri
}
w.Writefmtln(" }")

// TODO[pulumi/pulumi#2753]: We should re-enable this code once we have a solution for #2753.
// If the caller didn't request a specific version, supply one using the version of this library.
w.Writefmtln(" if (!opts) {")
w.Writefmtln(" opts = {}")
w.Writefmtln(" }")
w.Writefmtln("")
w.Writefmtln(" if (!opts.version) {")
w.Writefmtln(" opts.version = utilities.getVersion();")
w.Writefmtln(" }")
// w.Writefmtln(" if (!opts) {")
// w.Writefmtln(" opts = {}")
// w.Writefmtln(" }")
// w.Writefmtln("")
// w.Writefmtln(" if (!opts.version) {")
// w.Writefmtln(" opts.version = utilities.getVersion();")
// w.Writefmtln(" }")

// Now invoke the super constructor with the type, name, and a property map.
w.Writefmtln(` super("%s", name, inputs, opts);`, res.info.Tok)
Expand Down Expand Up @@ -653,14 +654,15 @@ func (g *nodeJSGenerator) emitResourceFunc(mod *module, fun *resourceFunc) (stri
w.Writefmtln(" args = args || {};")
}

// TODO[pulumi/pulumi#2753]: We should re-enable this code once we have a solution for #2753.
// If the caller didn't request a specific version, supply one using the version of this library.
w.Writefmtln(" if (!opts) {")
w.Writefmtln(" opts = {}")
w.Writefmtln(" }")
w.Writefmtln("")
w.Writefmtln(" if (!opts.version) {")
w.Writefmtln(" opts.version = utilities.getVersion();")
w.Writefmtln(" }")
// w.Writefmtln(" if (!opts) {")
// w.Writefmtln(" opts = {}")
// w.Writefmtln(" }")
// w.Writefmtln("")
// w.Writefmtln(" if (!opts.version) {")
// w.Writefmtln(" opts.version = utilities.getVersion();")
// w.Writefmtln(" }")

// Now simply invoke the runtime function with the arguments, returning the results.
w.Writefmtln(" return pulumi.runtime.invoke(\"%s\", {", fun.info.Tok)
Expand Down
20 changes: 11 additions & 9 deletions pkg/tfgen/generate_python.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,12 @@ func (g *pythonGenerator) emitResourceType(mod *module, res *resourceType) (stri
w.Writefmtln("")
}

// TODO[pulumi/pulumi#2753]: We should re-enable this code once we have a solution for #2753.
// If the caller explicitly specified a version, use it, otherwise inject this package's version.
w.Writefmtln(" if opts is None:")
w.Writefmtln(" opts = pulumi.ResourceOptions()")
w.Writefmtln(" if opts.version is None:")
w.Writefmtln(" opts.version = utilities.get_version()")
// w.Writefmtln(" if opts is None:")
// w.Writefmtln(" opts = pulumi.ResourceOptions()")
// w.Writefmtln(" if opts.version is None:")
// w.Writefmtln(" opts.version = utilities.get_version()")

// Finally, chain to the base constructor, which will actually register the resource.
w.Writefmtln(" super(%s, __self__).__init__(", res.name)
Expand Down Expand Up @@ -570,11 +571,12 @@ func (g *pythonGenerator) emitResourceFunc(mod *module, fun *resourceFunc) (stri
w.Writefmtln(" __args__['%s'] = %s", arg.name, pyName(arg.name))
}

// If the caller explicitly specified a version, use it, otherwise inject this package's version.
w.Writefmtln(" if opts is None:")
w.Writefmtln(" opts = pulumi.ResourceOptions()")
w.Writefmtln(" if opts.version is None:")
w.Writefmtln(" opts.version = utilities.get_version()")
// TODO[pulumi/pulumi#2753]: We should re-enable this code once we have a solution for #2753.
// // If the caller explicitly specified a version, use it, otherwise inject this package's version.
// w.Writefmtln(" if opts is None:")
// w.Writefmtln(" opts = pulumi.ResourceOptions()")
// w.Writefmtln(" if opts.version is None:")
// w.Writefmtln(" opts.version = utilities.get_version()")

// Now simply invoke the runtime function with the arguments.
w.Writefmtln(" __ret__ = await pulumi.runtime.invoke('%s', __args__, opts=opts)", fun.info.Tok)
Expand Down

0 comments on commit c2798a1

Please sign in to comment.