From 7f23457969a00655002ca09ffc6393ea18a60436 Mon Sep 17 00:00:00 2001 From: Andrew Lavery Date: Tue, 26 Feb 2019 16:02:47 -0800 Subject: [PATCH] use mitchellh/cli for prompt --- pkg/specs/replicatedapp/resolver.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pkg/specs/replicatedapp/resolver.go b/pkg/specs/replicatedapp/resolver.go index 3e9a00482..4bdf2f3ca 100644 --- a/pkg/specs/replicatedapp/resolver.go +++ b/pkg/specs/replicatedapp/resolver.go @@ -9,18 +9,19 @@ import ( "path/filepath" "strings" - "github.com/replicatedhq/ship/pkg/specs/apptype" - "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" + "github.com/mitchellh/cli" "github.com/pkg/errors" + "github.com/spf13/afero" + "github.com/spf13/viper" + yaml "gopkg.in/yaml.v2" + "github.com/replicatedhq/ship/pkg/api" "github.com/replicatedhq/ship/pkg/constants" "github.com/replicatedhq/ship/pkg/helpers/flags" + "github.com/replicatedhq/ship/pkg/specs/apptype" "github.com/replicatedhq/ship/pkg/state" - "github.com/spf13/afero" - "github.com/spf13/viper" - yaml "gopkg.in/yaml.v2" ) type shaSummer func([]byte) string @@ -29,6 +30,7 @@ type resolver struct { Client *GraphQLClient FS afero.Afero StateManager state.Manager + UI cli.Ui ShaSummer shaSummer Runbook string SetChannelName string @@ -45,11 +47,13 @@ func NewAppResolver( fs afero.Afero, graphql *GraphQLClient, stateManager state.Manager, + ui cli.Ui, ) Resolver { return &resolver{ Logger: logger, Client: graphql, FS: fs, + UI: ui, Runbook: flags.GetCurrentOrDeprecatedString(v, "runbook", "studio-file"), SetChannelName: flags.GetCurrentOrDeprecatedString(v, "set-channel-name", "studio-channel-name"), SetChannelIcon: flags.GetCurrentOrDeprecatedString(v, "set-channel-icon", "studio-channel-icon"), @@ -169,9 +173,13 @@ func (r *resolver) resolveCloudRelease(selector *Selector) (*ShipRelease, error) if err != nil { if selector.InstallationID == "" { debug.Log("event", "spec-resolve", "from", selector, "error", err) - fmt.Printf("Please enter your license to continue: ") + var input string - fmt.Scanln(&input) + input, err = r.UI.Ask("Please enter your license to continue: ") + if err != nil { + return nil, errors.Wrapf(err, "enter license from CLI") + } + selector.InstallationID = input err = r.updateUpstream(*selector)