From f3ba00328bbbed34c0dd3d92955d3ff7a7d72556 Mon Sep 17 00:00:00 2001 From: Carolyn Van Slyck Date: Fri, 12 Apr 2019 16:44:40 -0500 Subject: [PATCH] Incorporate review feedback --- cmd/porter/mixins.go | 5 ++++- pkg/mixin/install.go | 4 ++-- pkg/mixin/provider/install.go | 7 ++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/porter/mixins.go b/cmd/porter/mixins.go index f577fe0d8..d6f6d6541 100644 --- a/cmd/porter/mixins.go +++ b/cmd/porter/mixins.go @@ -50,8 +50,11 @@ func buildMixinsListCommand(p *porter.Porter) *cobra.Command { func BuildMixinInstallCommand(p *porter.Porter) *cobra.Command { opts := mixin.InstallOptions{} cmd := &cobra.Command{ - Use: "install", + Use: "install NAME", Short: "Install a mixin", + Example: ` porter mixin install helm --url https://deislabs.blob.core.windows.net/porter/mixins/helm + porter mixin install azure --version v0.4.0-ralpha.1+dubonnet --url https://deislabs.blob.core.windows.net/porter/mixins/azure + porter mixin install kubernetes --version canary --url https://deislabs.blob.core.windows.net/porter/mixins/kubernetes`, PreRunE: func(cmd *cobra.Command, args []string) error { return opts.Validate(args) }, diff --git a/pkg/mixin/install.go b/pkg/mixin/install.go index 50913e604..4a19258a6 100644 --- a/pkg/mixin/install.go +++ b/pkg/mixin/install.go @@ -14,7 +14,7 @@ type InstallOptions struct { parsedURL *url.URL } -// CopyParsedURL returns a copy of of the parsed URL that is safe to modify. +// GetParsedURL returns a copy of of the parsed URL that is safe to modify. func (o *InstallOptions) GetParsedURL() url.URL { return *o.parsedURL } @@ -51,7 +51,7 @@ func (o *InstallOptions) defaultVersion() { } } -// validateClaimName grabs the claim name from the first positional argument. +// validateMixinName grabs the mixin name from the first positional argument. func (o *InstallOptions) validateMixinName(args []string) error { switch len(args) { case 0: diff --git a/pkg/mixin/provider/install.go b/pkg/mixin/provider/install.go index e9b9aa362..fa99543bd 100644 --- a/pkg/mixin/provider/install.go +++ b/pkg/mixin/provider/install.go @@ -45,6 +45,10 @@ func (p *FileSystem) Install(opts mixin.InstallOptions) (mixin.Metadata, error) } func (p *FileSystem) downloadFile(url url.URL, destPath string) error { + if p.Debug { + fmt.Fprintf(p.Err, "Downloading %s to %s\n", url.String(), destPath) + } + // Ensure the parent directories exist parentDir := filepath.Dir(destPath) err := p.FileSystem.MkdirAll(parentDir, 0755) @@ -71,9 +75,6 @@ func (p *FileSystem) downloadFile(url url.URL, destPath string) error { return errors.Wrapf(err, "could not set the mixin as executable at %s", destPath) } - if p.Debug { - fmt.Fprintf(p.Err, "Downloading %s to %s\n", url.String(), destPath) - } _, err = io.Copy(destFile, resp.Body) if err != nil { return errors.Wrapf(err, "error writing the mixin to %s", destPath)