Download plugins from get.pulumi.com (#4692)

* Remove long-since deprecated --cloud-url flag

* Download plugins from get.pulumi.com

* Update CHANGELOG.md

* Use more straight forward TrimSuffix
This commit is contained in:
Chris Smith 2020-05-25 09:16:57 -07:00 committed by GitHub
parent 33db097176
commit f613b6917b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 26 deletions

View file

@ -18,6 +18,9 @@ CHANGELOG
- Add support for publishing Python policy packs.
[#4644](https://github.com/pulumi/pulumi/pull/4644)
- Improve download perf by fetching plugins from a CDN.
[#4692](https://github.com/pulumi/pulumi/pull/4692)
## 2.2.1 (2020-05-13)
- Add new brew target to fix homebrew builds
[#4633](https://github.com/pulumi/pulumi/pull/4633)

View file

@ -26,13 +26,11 @@ import (
"github.com/pulumi/pulumi/pkg/v2/backend/display"
"github.com/pulumi/pulumi/sdk/v2/go/common/diag"
"github.com/pulumi/pulumi/sdk/v2/go/common/util/cmdutil"
"github.com/pulumi/pulumi/sdk/v2/go/common/util/contract"
"github.com/pulumi/pulumi/sdk/v2/go/common/workspace"
)
func newPluginInstallCmd() *cobra.Command {
var serverURL string
var cloudURL string
var exact bool
var file string
var reinstall bool
@ -56,23 +54,6 @@ func newPluginInstallCmd() *cobra.Command {
Color: cmdutil.GetGlobalColorization(),
}
if serverURL != "" && cloudURL != "" {
return errors.New("only one of server and cloud-url may be specified")
}
if cloudURL != "" {
cmdutil.Diag().Warningf(diag.Message("", "cloud-url is deprecated, please pass '--server "+
"%s/releases/plugins' instead."), cloudURL)
serverURL = cloudURL + "/releases/plugins"
}
// Note we don't presently set this as the default value for `--server` so we can play games like the above
// where we want to ensure at most one of `--server` or `--cloud-url` is set.
if serverURL == "" {
serverURL = "https://api.pulumi.com/releases/plugins"
}
// Parse the kind, name, and version, if specified.
var installs []workspace.PluginInfo
if len(args) > 0 {
@ -91,7 +72,7 @@ func newPluginInstallCmd() *cobra.Command {
Kind: workspace.PluginKind(args[0]),
Name: args[1],
Version: &version,
ServerURL: serverURL,
ServerURL: serverURL, // If empty, will use default plugin source.
})
} else {
if file != "" {
@ -179,8 +160,6 @@ func newPluginInstallCmd() *cobra.Command {
cmd.PersistentFlags().StringVar(&serverURL,
"server", "", "A URL to download plugins from")
cmd.PersistentFlags().StringVarP(&cloudURL,
"cloud-url", "c", "", "A cloud URL to download releases from")
cmd.PersistentFlags().BoolVar(&exact,
"exact", false, "Force installation of an exact version match (usually >= is accepted)")
cmd.PersistentFlags().StringVarP(&file,
@ -190,8 +169,5 @@ func newPluginInstallCmd() *cobra.Command {
cmd.PersistentFlags().BoolVar(&verbose,
"verbose", false, "Print detailed information about the installation steps")
// We are moving away from supporting this option, for now we mark it hidden.
contract.AssertNoError(cmd.PersistentFlags().MarkHidden("cloud-url"))
return cmd
}

View file

@ -26,6 +26,7 @@ import (
"regexp"
"runtime"
"sort"
"strings"
"time"
"github.com/blang/semver"
@ -190,8 +191,9 @@ func (info PluginInfo) Download() (io.ReadCloser, int64, error) {
// is hosted by Pulumi.
serverURL := info.ServerURL
if serverURL == "" {
serverURL = "https://api.pulumi.com/releases/plugins"
serverURL = "https://get.pulumi.com/releases/plugins"
}
serverURL = strings.TrimSuffix(serverURL, "/")
endpoint := fmt.Sprintf("%s/pulumi-%s-%s-v%s-%s-%s.tar.gz", serverURL, info.Kind, info.Name, info.Version, os, arch)
req, err := http.NewRequest("GET", endpoint, nil)