From af38d82f3daab607d8aa520b985536834c2431cc Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 28 Sep 2018 12:29:43 -0700 Subject: [PATCH 1/3] pkg/asset: Switch from github.com -> gopkg.in for survey This is the recommended import URI [1]. And survey's internal imports use the gopkg.in form, so we're already vendoring it; this change will let us drop the redundant github.com copies. The explicit package name is not strictly necessary, but I like to set it when the final segment of the import URL does not match the package name declared within the imported package. [1]: https://github.com/AlecAivazis/survey/tree/v1.6.2#versioning --- pkg/asset/installconfig/platform.go | 2 +- pkg/asset/installconfig/ssh.go | 2 +- pkg/asset/installconfig/stock.go | 2 +- pkg/asset/userprovided.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/asset/installconfig/platform.go b/pkg/asset/installconfig/platform.go index 9901324c6b0..1a6a86de2d3 100644 --- a/pkg/asset/installconfig/platform.go +++ b/pkg/asset/installconfig/platform.go @@ -6,7 +6,7 @@ import ( "sort" "strings" - "github.com/AlecAivazis/survey" + survey "gopkg.in/AlecAivazis/survey.v1" "github.com/openshift/installer/pkg/asset" ) diff --git a/pkg/asset/installconfig/ssh.go b/pkg/asset/installconfig/ssh.go index cbbb2882a56..04a3c76d315 100644 --- a/pkg/asset/installconfig/ssh.go +++ b/pkg/asset/installconfig/ssh.go @@ -10,7 +10,7 @@ import ( "sort" "strings" - "github.com/AlecAivazis/survey" + survey "gopkg.in/AlecAivazis/survey.v1" "github.com/openshift/installer/pkg/asset" ) diff --git a/pkg/asset/installconfig/stock.go b/pkg/asset/installconfig/stock.go index 3339131dbff..31190666906 100644 --- a/pkg/asset/installconfig/stock.go +++ b/pkg/asset/installconfig/stock.go @@ -1,7 +1,7 @@ package installconfig import ( - "github.com/AlecAivazis/survey" + survey "gopkg.in/AlecAivazis/survey.v1" "github.com/openshift/installer/pkg/asset" "github.com/openshift/installer/pkg/types/config" diff --git a/pkg/asset/userprovided.go b/pkg/asset/userprovided.go index 95488bcb6d9..4d7426a2d12 100644 --- a/pkg/asset/userprovided.go +++ b/pkg/asset/userprovided.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "os" - "github.com/AlecAivazis/survey" + survey "gopkg.in/AlecAivazis/survey.v1" ) // UserProvided generates an asset that is supplied by a user. From 101007712953e576bd919800bb56b8a4d29e670a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 28 Sep 2018 13:04:33 -0700 Subject: [PATCH 2/3] vendor: Drop github.com/AlecAivazis/survey Generated with: $ glide remove github.com/AlecAivazis/survey $ glide get --strip-vendor gopkg.in/AlecAivazis/survey [INFO]Preparing to install 1 package. [INFO]Attempting to get package gopkg.in/AlecAivazis/survey.v1 [INFO]--> Gathering release information for gopkg.in/AlecAivazis/survey.v1 [INFO]The package gopkg.in/AlecAivazis/survey.v1 appears to have Semantic Version releases (http://semver.org). [INFO]The latest release is v1.6.2. You are currently not using a release. Would you like [INFO]to use this release? Yes (Y) or No (N) y [INFO]The package gopkg.in/AlecAivazis/survey.v1 appears to use semantic versions (http://semver.org). [INFO]Would you like to track the latest minor or patch releases (major.minor.patch)? [INFO]The choices are: [INFO] - Tracking minor version releases would use '>= 1.6.2, < 2.0.0' ('^1.6.2') [INFO] - Tracking patch version releases would use '>= 1.6.2, < 1.7.0' ('~1.6.2') [INFO] - Skip using ranges [INFO]For more information on Glide versions and ranges see https://glide.sh/docs/versions [INFO]Minor (M), Patch (P), or Skip Ranges (S)? m [INFO]--> Adding gopkg.in/AlecAivazis/survey.v1 to your configuration with the version ^1.6.2 ... $ glide-vc --use-lock-file --no-tests --only-code $ git checkout HEAD -- vendor/github.com/shurcooL/httpfs using: $ glide --version glide version 0.13.2-dev $ (cd $GOPATH/src/github.com/Masterminds/glide && git describe) v0.13.1-7-g3e13fd1 $ (cd $GOPATH/src/github.com/sgotti/glide-vc && git describe) v0.1.0-2-g6ddf6ee The httpfs works around our busted vfsutil vendor, see a8cce08b (vendor: Add shurcooL/httpfs/vfsutil, 2018-09-26, #340). The formatting change unwinds ff9e5479 (*: format all yaml files, 2018-09-27, #342), but it doesn't seem to be worth fighting Glide on this front. --- .bazelrc | 2 - glide.lock | 8 +- glide.yaml | 77 +++-- vendor/github.com/AlecAivazis/survey/LICENSE | 21 -- .../github.com/AlecAivazis/survey/confirm.go | 138 --------- .../github.com/AlecAivazis/survey/editor.go | 194 ------------- vendor/github.com/AlecAivazis/survey/input.go | 97 ------- .../AlecAivazis/survey/multiselect.go | 250 ---------------- .../github.com/AlecAivazis/survey/password.go | 86 ------ .../github.com/AlecAivazis/survey/select.go | 271 ------------------ .../github.com/AlecAivazis/survey/survey.go | 246 ---------------- .../AlecAivazis/survey/transform.go | 76 ----- .../github.com/AlecAivazis/survey/validate.go | 87 ------ .../github.com/aws/aws-sdk-go/aws/version.go | 2 +- .../aws/aws-sdk-go/service/ec2/api.go | 9 + 15 files changed, 51 insertions(+), 1513 deletions(-) delete mode 100644 .bazelrc delete mode 100644 vendor/github.com/AlecAivazis/survey/LICENSE delete mode 100644 vendor/github.com/AlecAivazis/survey/confirm.go delete mode 100644 vendor/github.com/AlecAivazis/survey/editor.go delete mode 100644 vendor/github.com/AlecAivazis/survey/input.go delete mode 100644 vendor/github.com/AlecAivazis/survey/multiselect.go delete mode 100644 vendor/github.com/AlecAivazis/survey/password.go delete mode 100644 vendor/github.com/AlecAivazis/survey/select.go delete mode 100644 vendor/github.com/AlecAivazis/survey/survey.go delete mode 100644 vendor/github.com/AlecAivazis/survey/transform.go delete mode 100644 vendor/github.com/AlecAivazis/survey/validate.go diff --git a/.bazelrc b/.bazelrc deleted file mode 100644 index 3ff8578938e..00000000000 --- a/.bazelrc +++ /dev/null @@ -1,2 +0,0 @@ -startup --output_base .build -build --color=yes --features=pure --workspace_status_command "${PWD}/buildvars.sh" diff --git a/glide.lock b/glide.lock index a14280591b2..1c0f655bc75 100644 --- a/glide.lock +++ b/glide.lock @@ -1,10 +1,8 @@ -hash: 89c59afb258e5da417740d181008c08a7e0ac024c537b04b879cee13fe419fa3 -updated: 2018-09-26T15:23:10.801068675-07:00 +hash: 5d4bcc984f1d19ed41a63a22ee4fd3d93f4c823708aa70f634958a9fc40d4a70 +updated: 2018-09-28T12:36:19.583316383-07:00 imports: - name: github.com/ajeddeloh/go-json version: 73d058cf8437a1989030afe571eeab9f90eebbbd -- name: github.com/AlecAivazis/survey - version: f30c5d1830c892f533140f29a1de89141dc217f5 - name: github.com/alecthomas/template version: a0175ee3bccc567396460bf5acd36800cb10c49c subpackages: @@ -16,7 +14,7 @@ imports: subpackages: - cidr - name: github.com/aws/aws-sdk-go - version: 85d9dfd77e6d694e83c3ac054141cb5e81eecc7f + version: a8ff9e4804fc89c994b731b1c057640ab2aecff3 subpackages: - aws - aws/awserr diff --git a/glide.yaml b/glide.yaml index 70b92f18a7d..58f4733f77c 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,43 +1,42 @@ ---- package: github.com/openshift/installer excludeDirs: - - tests +- tests import: - - package: github.com/ghodss/yaml - version: 73d445a93680fa1a78ae23a5839bad48f32ba1ee - - package: github.com/sirupsen/logrus - version: 081307d9bc1364753142d5962fc1d795c742baaf - - package: gopkg.in/yaml.v2 - version: 53feefa2559fb8dfa8d81baad31be332c97d6c77 - - package: gopkg.in/alecthomas/kingpin.v2 - version: 947dcec5ba9c011838740e680966fd7087a71d0d - - package: github.com/coreos/tectonic-config - version: 0d649ebfd3552dfa5c6cc2cf053e17ba924b7024 - - package: k8s.io/apimachinery - version: kubernetes-1.9.0 - - package: golang.org/x/crypto - version: df8d4716b3472e4a531c33cedbe537dae921a1a9 - - package: github.com/coreos/ignition - version: v0.26.0 - - package: github.com/vincent-petithory/dataurl - version: 9a301d65acbb728fcc3ace14f45f511a4cfeea9c - - package: sigs.k8s.io/cluster-api - version: 0.0.0-alpha.2 - subpackages: - - pkg/client/clientset_generated/clientset - - package: github.com/AlecAivazis/survey - version: 1.6.2 - - package: github.com/aws/aws-sdk-go - version: ^1.15.39 - - package: github.com/libvirt/libvirt-go - version: ^v4.7.0 - - package: github.com/openshift/hive - version: 296cb990171c6da62e134f3590c120bd16ef4d43 - subpackages: - - contrib/pkg/aws_tag_deprovision +- package: github.com/ghodss/yaml + version: 73d445a93680fa1a78ae23a5839bad48f32ba1ee +- package: github.com/sirupsen/logrus + version: 081307d9bc1364753142d5962fc1d795c742baaf +- package: gopkg.in/yaml.v2 + version: 53feefa2559fb8dfa8d81baad31be332c97d6c77 +- package: gopkg.in/alecthomas/kingpin.v2 + version: 947dcec5ba9c011838740e680966fd7087a71d0d +- package: github.com/coreos/tectonic-config + version: 0d649ebfd3552dfa5c6cc2cf053e17ba924b7024 +- package: k8s.io/apimachinery + version: kubernetes-1.9.0 +- package: golang.org/x/crypto + version: df8d4716b3472e4a531c33cedbe537dae921a1a9 +- package: github.com/coreos/ignition + version: v0.26.0 +- package: github.com/vincent-petithory/dataurl + version: 9a301d65acbb728fcc3ace14f45f511a4cfeea9c +- package: sigs.k8s.io/cluster-api + version: 0.0.0-alpha.2 + subpackages: + - pkg/client/clientset_generated/clientset +- package: github.com/aws/aws-sdk-go + version: ^1.15.39 +- package: github.com/libvirt/libvirt-go + version: ^v4.7.0 +- package: github.com/openshift/hive + version: 296cb990171c6da62e134f3590c120bd16ef4d43 + subpackages: + - contrib/pkg/aws_tag_deprovision +- package: gopkg.in/AlecAivazis/survey.v1 + version: ^1.6.2 testImport: - - package: github.com/stretchr/testify - version: ^1.2.2 - subpackages: - - assert - - package: github.com/shurcooL/vfsgen +- package: github.com/stretchr/testify + version: ^1.2.2 + subpackages: + - assert +- package: github.com/shurcooL/vfsgen diff --git a/vendor/github.com/AlecAivazis/survey/LICENSE b/vendor/github.com/AlecAivazis/survey/LICENSE deleted file mode 100644 index 07a709ae28f..00000000000 --- a/vendor/github.com/AlecAivazis/survey/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Alec Aivazis - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/AlecAivazis/survey/confirm.go b/vendor/github.com/AlecAivazis/survey/confirm.go deleted file mode 100644 index 5672c52d36e..00000000000 --- a/vendor/github.com/AlecAivazis/survey/confirm.go +++ /dev/null @@ -1,138 +0,0 @@ -package survey - -import ( - "fmt" - "regexp" - - "gopkg.in/AlecAivazis/survey.v1/core" -) - -// Confirm is a regular text input that accept yes/no answers. Response type is a bool. -type Confirm struct { - core.Renderer - Message string - Default bool - Help string -} - -// data available to the templates when processing -type ConfirmTemplateData struct { - Confirm - Answer string - ShowHelp bool -} - -// Templates with Color formatting. See Documentation: https://github.com/mgutz/ansi#style-format -var ConfirmQuestionTemplate = ` -{{- if .ShowHelp }}{{- color "cyan"}}{{ HelpIcon }} {{ .Help }}{{color "reset"}}{{"\n"}}{{end}} -{{- color "green+hb"}}{{ QuestionIcon }} {{color "reset"}} -{{- color "default+hb"}}{{ .Message }} {{color "reset"}} -{{- if .Answer}} - {{- color "cyan"}}{{.Answer}}{{color "reset"}}{{"\n"}} -{{- else }} - {{- if and .Help (not .ShowHelp)}}{{color "cyan"}}[{{ HelpInputRune }} for help]{{color "reset"}} {{end}} - {{- color "white"}}{{if .Default}}(Y/n) {{else}}(y/N) {{end}}{{color "reset"}} -{{- end}}` - -// the regex for answers -var ( - yesRx = regexp.MustCompile("^(?i:y(?:es)?)$") - noRx = regexp.MustCompile("^(?i:n(?:o)?)$") -) - -func yesNo(t bool) string { - if t { - return "Yes" - } - return "No" -} - -func (c *Confirm) getBool(showHelp bool) (bool, error) { - cursor := c.NewCursor() - rr := c.NewRuneReader() - rr.SetTermMode() - defer rr.RestoreTermMode() - - // start waiting for input - for { - line, err := rr.ReadLine(0) - if err != nil { - return false, err - } - // move back up a line to compensate for the \n echoed from terminal - cursor.PreviousLine(1) - val := string(line) - - // get the answer that matches the - var answer bool - switch { - case yesRx.Match([]byte(val)): - answer = true - case noRx.Match([]byte(val)): - answer = false - case val == "": - answer = c.Default - case val == string(core.HelpInputRune) && c.Help != "": - err := c.Render( - ConfirmQuestionTemplate, - ConfirmTemplateData{Confirm: *c, ShowHelp: true}, - ) - if err != nil { - // use the default value and bubble up - return c.Default, err - } - showHelp = true - continue - default: - // we didnt get a valid answer, so print error and prompt again - if err := c.Error(fmt.Errorf("%q is not a valid answer, please try again.", val)); err != nil { - return c.Default, err - } - err := c.Render( - ConfirmQuestionTemplate, - ConfirmTemplateData{Confirm: *c, ShowHelp: showHelp}, - ) - if err != nil { - // use the default value and bubble up - return c.Default, err - } - continue - } - return answer, nil - } - // should not get here - return c.Default, nil -} - -/* -Prompt prompts the user with a simple text field and expects a reply followed -by a carriage return. - - likesPie := false - prompt := &survey.Confirm{ Message: "What is your name?" } - survey.AskOne(prompt, &likesPie, nil) -*/ -func (c *Confirm) Prompt() (interface{}, error) { - // render the question template - err := c.Render( - ConfirmQuestionTemplate, - ConfirmTemplateData{Confirm: *c}, - ) - if err != nil { - return "", err - } - - // get input and return - return c.getBool(false) -} - -// Cleanup overwrite the line with the finalized formatted version -func (c *Confirm) Cleanup(val interface{}) error { - // if the value was previously true - ans := yesNo(val.(bool)) - // render the template - return c.Render( - ConfirmQuestionTemplate, - ConfirmTemplateData{Confirm: *c, Answer: ans}, - ) -} diff --git a/vendor/github.com/AlecAivazis/survey/editor.go b/vendor/github.com/AlecAivazis/survey/editor.go deleted file mode 100644 index d69cd95e41b..00000000000 --- a/vendor/github.com/AlecAivazis/survey/editor.go +++ /dev/null @@ -1,194 +0,0 @@ -package survey - -import ( - "bytes" - "io/ioutil" - "os" - "os/exec" - "runtime" - - shellquote "github.com/kballard/go-shellquote" - "gopkg.in/AlecAivazis/survey.v1/core" - "gopkg.in/AlecAivazis/survey.v1/terminal" -) - -/* -Editor launches an instance of the users preferred editor on a temporary file. -The editor to use is determined by reading the $VISUAL or $EDITOR environment -variables. If neither of those are present, notepad (on Windows) or vim -(others) is used. -The launch of the editor is triggered by the enter key. Since the response may -be long, it will not be echoed as Input does, instead, it print . -Response type is a string. - - message := "" - prompt := &survey.Editor{ Message: "What is your commit message?" } - survey.AskOne(prompt, &message, nil) -*/ -type Editor struct { - core.Renderer - Message string - Default string - Help string - Editor string - HideDefault bool - AppendDefault bool -} - -// data available to the templates when processing -type EditorTemplateData struct { - Editor - Answer string - ShowAnswer bool - ShowHelp bool -} - -// Templates with Color formatting. See Documentation: https://github.com/mgutz/ansi#style-format -var EditorQuestionTemplate = ` -{{- if .ShowHelp }}{{- color "cyan"}}{{ HelpIcon }} {{ .Help }}{{color "reset"}}{{"\n"}}{{end}} -{{- color "green+hb"}}{{ QuestionIcon }} {{color "reset"}} -{{- color "default+hb"}}{{ .Message }} {{color "reset"}} -{{- if .ShowAnswer}} - {{- color "cyan"}}{{.Answer}}{{color "reset"}}{{"\n"}} -{{- else }} - {{- if and .Help (not .ShowHelp)}}{{color "cyan"}}[{{ HelpInputRune }} for help]{{color "reset"}} {{end}} - {{- if and .Default (not .HideDefault)}}{{color "white"}}({{.Default}}) {{color "reset"}}{{end}} - {{- color "cyan"}}[Enter to launch editor] {{color "reset"}} -{{- end}}` - -var ( - bom = []byte{0xef, 0xbb, 0xbf} - editor = "vim" -) - -func init() { - if runtime.GOOS == "windows" { - editor = "notepad" - } - if v := os.Getenv("VISUAL"); v != "" { - editor = v - } else if e := os.Getenv("EDITOR"); e != "" { - editor = e - } -} - -func (e *Editor) Prompt() (interface{}, error) { - // render the template - err := e.Render( - EditorQuestionTemplate, - EditorTemplateData{Editor: *e}, - ) - if err != nil { - return "", err - } - - // start reading runes from the standard in - rr := e.NewRuneReader() - rr.SetTermMode() - defer rr.RestoreTermMode() - - cursor := e.NewCursor() - cursor.Hide() - defer cursor.Show() - - for { - r, _, err := rr.ReadRune() - if err != nil { - return "", err - } - if r == '\r' || r == '\n' { - break - } - if r == terminal.KeyInterrupt { - return "", terminal.InterruptErr - } - if r == terminal.KeyEndTransmission { - break - } - if r == core.HelpInputRune && e.Help != "" { - err = e.Render( - EditorQuestionTemplate, - EditorTemplateData{Editor: *e, ShowHelp: true}, - ) - if err != nil { - return "", err - } - } - continue - } - - // prepare the temp file - f, err := ioutil.TempFile("", "survey") - if err != nil { - return "", err - } - defer os.Remove(f.Name()) - - // write utf8 BOM header - // The reason why we do this is because notepad.exe on Windows determines the - // encoding of an "empty" text file by the locale, for example, GBK in China, - // while golang string only handles utf8 well. However, a text file with utf8 - // BOM header is not considered "empty" on Windows, and the encoding will then - // be determined utf8 by notepad.exe, instead of GBK or other encodings. - if _, err := f.Write(bom); err != nil { - return "", err - } - - // write default value - if e.Default != "" && e.AppendDefault { - if _, err := f.WriteString(e.Default); err != nil { - return "", err - } - } - - // close the fd to prevent the editor unable to save file - if err := f.Close(); err != nil { - return "", err - } - - // check is input editor exist - if e.Editor != "" { - editor = e.Editor - } - - stdio := e.Stdio() - - args, err := shellquote.Split(editor) - if err != nil { - return "", err - } - args = append(args, f.Name()) - - // open the editor - cmd := exec.Command(args[0], args[1:]...) - cmd.Stdin = stdio.In - cmd.Stdout = stdio.Out - cmd.Stderr = stdio.Err - cursor.Show() - if err := cmd.Run(); err != nil { - return "", err - } - - // raw is a BOM-unstripped UTF8 byte slice - raw, err := ioutil.ReadFile(f.Name()) - if err != nil { - return "", err - } - - // strip BOM header - text := string(bytes.TrimPrefix(raw, bom)) - - // check length, return default value on empty - if len(text) == 0 && !e.AppendDefault { - return e.Default, nil - } - - return text, nil -} - -func (e *Editor) Cleanup(val interface{}) error { - return e.Render( - EditorQuestionTemplate, - EditorTemplateData{Editor: *e, Answer: "", ShowAnswer: true}, - ) -} diff --git a/vendor/github.com/AlecAivazis/survey/input.go b/vendor/github.com/AlecAivazis/survey/input.go deleted file mode 100644 index 08724d58151..00000000000 --- a/vendor/github.com/AlecAivazis/survey/input.go +++ /dev/null @@ -1,97 +0,0 @@ -package survey - -import ( - "gopkg.in/AlecAivazis/survey.v1/core" -) - -/* -Input is a regular text input that prints each character the user types on the screen -and accepts the input with the enter key. Response type is a string. - - name := "" - prompt := &survey.Input{ Message: "What is your name?" } - survey.AskOne(prompt, &name, nil) -*/ -type Input struct { - core.Renderer - Message string - Default string - Help string -} - -// data available to the templates when processing -type InputTemplateData struct { - Input - Answer string - ShowAnswer bool - ShowHelp bool -} - -// Templates with Color formatting. See Documentation: https://github.com/mgutz/ansi#style-format -var InputQuestionTemplate = ` -{{- if .ShowHelp }}{{- color "cyan"}}{{ HelpIcon }} {{ .Help }}{{color "reset"}}{{"\n"}}{{end}} -{{- color "green+hb"}}{{ QuestionIcon }} {{color "reset"}} -{{- color "default+hb"}}{{ .Message }} {{color "reset"}} -{{- if .ShowAnswer}} - {{- color "cyan"}}{{.Answer}}{{color "reset"}}{{"\n"}} -{{- else }} - {{- if and .Help (not .ShowHelp)}}{{color "cyan"}}[{{ HelpInputRune }} for help]{{color "reset"}} {{end}} - {{- if .Default}}{{color "white"}}({{.Default}}) {{color "reset"}}{{end}} -{{- end}}` - -func (i *Input) Prompt() (interface{}, error) { - // render the template - err := i.Render( - InputQuestionTemplate, - InputTemplateData{Input: *i}, - ) - if err != nil { - return "", err - } - - // start reading runes from the standard in - rr := i.NewRuneReader() - rr.SetTermMode() - defer rr.RestoreTermMode() - - cursor := i.NewCursor() - - line := []rune{} - // get the next line - for { - line, err = rr.ReadLine(0) - if err != nil { - return string(line), err - } - // terminal will echo the \n so we need to jump back up one row - cursor.PreviousLine(1) - - if string(line) == string(core.HelpInputRune) && i.Help != "" { - err = i.Render( - InputQuestionTemplate, - InputTemplateData{Input: *i, ShowHelp: true}, - ) - if err != nil { - return "", err - } - continue - } - break - } - - // if the line is empty - if line == nil || len(line) == 0 { - // use the default value - return i.Default, err - } - - // we're done - return string(line), err -} - -func (i *Input) Cleanup(val interface{}) error { - return i.Render( - InputQuestionTemplate, - InputTemplateData{Input: *i, Answer: val.(string), ShowAnswer: true}, - ) -} diff --git a/vendor/github.com/AlecAivazis/survey/multiselect.go b/vendor/github.com/AlecAivazis/survey/multiselect.go deleted file mode 100644 index e3768bc5015..00000000000 --- a/vendor/github.com/AlecAivazis/survey/multiselect.go +++ /dev/null @@ -1,250 +0,0 @@ -package survey - -import ( - "errors" - "strings" - - "gopkg.in/AlecAivazis/survey.v1/core" - "gopkg.in/AlecAivazis/survey.v1/terminal" -) - -/* -MultiSelect is a prompt that presents a list of various options to the user -for them to select using the arrow keys and enter. Response type is a slice of strings. - - days := []string{} - prompt := &survey.MultiSelect{ - Message: "What days do you prefer:", - Options: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, - } - survey.AskOne(prompt, &days, nil) -*/ -type MultiSelect struct { - core.Renderer - Message string - Options []string - Default []string - Help string - PageSize int - VimMode bool - FilterMessage string - filter string - selectedIndex int - checked map[string]bool - showingHelp bool -} - -// data available to the templates when processing -type MultiSelectTemplateData struct { - MultiSelect - Answer string - ShowAnswer bool - Checked map[string]bool - SelectedIndex int - ShowHelp bool - PageEntries []string -} - -var MultiSelectQuestionTemplate = ` -{{- if .ShowHelp }}{{- color "cyan"}}{{ HelpIcon }} {{ .Help }}{{color "reset"}}{{"\n"}}{{end}} -{{- color "green+hb"}}{{ QuestionIcon }} {{color "reset"}} -{{- color "default+hb"}}{{ .Message }}{{ .FilterMessage }}{{color "reset"}} -{{- if .ShowAnswer}}{{color "cyan"}} {{.Answer}}{{color "reset"}}{{"\n"}} -{{- else }} - {{- " "}}{{- color "cyan"}}[Use arrows to move, type to filter{{- if and .Help (not .ShowHelp)}}, {{ HelpInputRune }} for more help{{end}}]{{color "reset"}} - {{- "\n"}} - {{- range $ix, $option := .PageEntries}} - {{- if eq $ix $.SelectedIndex}}{{color "cyan"}}{{ SelectFocusIcon }}{{color "reset"}}{{else}} {{end}} - {{- if index $.Checked $option}}{{color "green"}} {{ MarkedOptionIcon }} {{else}}{{color "default+hb"}} {{ UnmarkedOptionIcon }} {{end}} - {{- color "reset"}} - {{- " "}}{{$option}}{{"\n"}} - {{- end}} -{{- end}}` - -// OnChange is called on every keypress. -func (m *MultiSelect) OnChange(line []rune, pos int, key rune) (newLine []rune, newPos int, ok bool) { - options := m.filterOptions() - oldFilter := m.filter - - if key == terminal.KeyArrowUp || (m.VimMode && key == 'k') { - // if we are at the top of the list - if m.selectedIndex == 0 { - // go to the bottom - m.selectedIndex = len(options) - 1 - } else { - // decrement the selected index - m.selectedIndex-- - } - } else if key == terminal.KeyArrowDown || (m.VimMode && key == 'j') { - // if we are at the bottom of the list - if m.selectedIndex == len(options)-1 { - // start at the top - m.selectedIndex = 0 - } else { - // increment the selected index - m.selectedIndex++ - } - // if the user pressed down and there is room to move - } else if key == terminal.KeySpace { - if m.selectedIndex < len(options) { - if old, ok := m.checked[options[m.selectedIndex]]; !ok { - // otherwise just invert the current value - m.checked[options[m.selectedIndex]] = true - } else { - // otherwise just invert the current value - m.checked[options[m.selectedIndex]] = !old - } - } - // only show the help message if we have one to show - } else if key == core.HelpInputRune && m.Help != "" { - m.showingHelp = true - } else if key == terminal.KeyEscape { - m.VimMode = !m.VimMode - } else if key == terminal.KeyDeleteWord || key == terminal.KeyDeleteLine { - m.filter = "" - } else if key == terminal.KeyDelete || key == terminal.KeyBackspace { - if m.filter != "" { - m.filter = m.filter[0 : len(m.filter)-1] - } - } else if key >= terminal.KeySpace { - m.filter += string(key) - m.VimMode = false - } - - m.FilterMessage = "" - if m.filter != "" { - m.FilterMessage = " " + m.filter - } - if oldFilter != m.filter { - // filter changed - options = m.filterOptions() - if len(options) > 0 && len(options) <= m.selectedIndex { - m.selectedIndex = len(options) - 1 - } - } - // paginate the options - - // TODO if we have started filtering and were looking at the end of a list - // and we have modified the filter then we should move the page back! - opts, idx := paginate(m.PageSize, options, m.selectedIndex) - - // render the options - m.Render( - MultiSelectQuestionTemplate, - MultiSelectTemplateData{ - MultiSelect: *m, - SelectedIndex: idx, - Checked: m.checked, - ShowHelp: m.showingHelp, - PageEntries: opts, - }, - ) - - // if we are not pressing ent - return line, 0, true -} - -func (m *MultiSelect) filterOptions() []string { - filter := strings.ToLower(m.filter) - if filter == "" { - return m.Options - } - answer := []string{} - for _, o := range m.Options { - if strings.Contains(strings.ToLower(o), filter) { - answer = append(answer, o) - } - } - return answer -} - -func (m *MultiSelect) Prompt() (interface{}, error) { - // compute the default state - m.checked = make(map[string]bool) - // if there is a default - if len(m.Default) > 0 { - for _, dflt := range m.Default { - for _, opt := range m.Options { - // if the option correponds to the default - if opt == dflt { - // we found our initial value - m.checked[opt] = true - // stop looking - break - } - } - } - } - - // if there are no options to render - if len(m.Options) == 0 { - // we failed - return "", errors.New("please provide options to select from") - } - - // paginate the options - opts, idx := paginate(m.PageSize, m.Options, m.selectedIndex) - - cursor := m.NewCursor() - cursor.Hide() // hide the cursor - defer cursor.Show() // show the cursor when we're done - - // ask the question - err := m.Render( - MultiSelectQuestionTemplate, - MultiSelectTemplateData{ - MultiSelect: *m, - SelectedIndex: idx, - Checked: m.checked, - PageEntries: opts, - }, - ) - if err != nil { - return "", err - } - - rr := m.NewRuneReader() - rr.SetTermMode() - defer rr.RestoreTermMode() - - // start waiting for input - for { - r, _, _ := rr.ReadRune() - if r == '\r' || r == '\n' { - break - } - if r == terminal.KeyInterrupt { - return "", terminal.InterruptErr - } - if r == terminal.KeyEndTransmission { - break - } - m.OnChange(nil, 0, r) - } - m.filter = "" - m.FilterMessage = "" - - answers := []string{} - for _, option := range m.Options { - if val, ok := m.checked[option]; ok && val { - answers = append(answers, option) - } - } - - return answers, nil -} - -// Cleanup removes the options section, and renders the ask like a normal question. -func (m *MultiSelect) Cleanup(val interface{}) error { - // execute the output summary template with the answer - return m.Render( - MultiSelectQuestionTemplate, - MultiSelectTemplateData{ - MultiSelect: *m, - SelectedIndex: m.selectedIndex, - Checked: m.checked, - Answer: strings.Join(val.([]string), ", "), - ShowAnswer: true, - }, - ) -} diff --git a/vendor/github.com/AlecAivazis/survey/password.go b/vendor/github.com/AlecAivazis/survey/password.go deleted file mode 100644 index 86c39a52e71..00000000000 --- a/vendor/github.com/AlecAivazis/survey/password.go +++ /dev/null @@ -1,86 +0,0 @@ -package survey - -import ( - "fmt" - - "gopkg.in/AlecAivazis/survey.v1/core" - "gopkg.in/AlecAivazis/survey.v1/terminal" -) - -/* -Password is like a normal Input but the text shows up as *'s and there is no default. Response -type is a string. - - password := "" - prompt := &survey.Password{ Message: "Please type your password" } - survey.AskOne(prompt, &password, nil) -*/ -type Password struct { - core.Renderer - Message string - Help string -} - -type PasswordTemplateData struct { - Password - ShowHelp bool -} - -// Templates with Color formatting. See Documentation: https://github.com/mgutz/ansi#style-format -var PasswordQuestionTemplate = ` -{{- if .ShowHelp }}{{- color "cyan"}}{{ HelpIcon }} {{ .Help }}{{color "reset"}}{{"\n"}}{{end}} -{{- color "green+hb"}}{{ QuestionIcon }} {{color "reset"}} -{{- color "default+hb"}}{{ .Message }} {{color "reset"}} -{{- if and .Help (not .ShowHelp)}}{{color "cyan"}}[{{ HelpInputRune }} for help]{{color "reset"}} {{end}}` - -func (p *Password) Prompt() (line interface{}, err error) { - // render the question template - out, err := core.RunTemplate( - PasswordQuestionTemplate, - PasswordTemplateData{Password: *p}, - ) - fmt.Fprint(terminal.NewAnsiStdout(p.Stdio().Out), out) - if err != nil { - return "", err - } - - rr := p.NewRuneReader() - rr.SetTermMode() - defer rr.RestoreTermMode() - - // no help msg? Just return any response - if p.Help == "" { - line, err := rr.ReadLine('*') - return string(line), err - } - - cursor := p.NewCursor() - - // process answers looking for help prompt answer - for { - line, err := rr.ReadLine('*') - if err != nil { - return string(line), err - } - - if string(line) == string(core.HelpInputRune) { - // terminal will echo the \n so we need to jump back up one row - cursor.PreviousLine(1) - - err = p.Render( - PasswordQuestionTemplate, - PasswordTemplateData{Password: *p, ShowHelp: true}, - ) - if err != nil { - return "", err - } - continue - } - return string(line), err - } -} - -// Cleanup hides the string with a fixed number of characters. -func (prompt *Password) Cleanup(val interface{}) error { - return nil -} diff --git a/vendor/github.com/AlecAivazis/survey/select.go b/vendor/github.com/AlecAivazis/survey/select.go deleted file mode 100644 index a30c994ec4f..00000000000 --- a/vendor/github.com/AlecAivazis/survey/select.go +++ /dev/null @@ -1,271 +0,0 @@ -package survey - -import ( - "errors" - "strings" - - "gopkg.in/AlecAivazis/survey.v1/core" - "gopkg.in/AlecAivazis/survey.v1/terminal" -) - -/* -Select is a prompt that presents a list of various options to the user -for them to select using the arrow keys and enter. Response type is a string. - - color := "" - prompt := &survey.Select{ - Message: "Choose a color:", - Options: []string{"red", "blue", "green"}, - } - survey.AskOne(prompt, &color, nil) -*/ -type Select struct { - core.Renderer - Message string - Options []string - Default string - Help string - PageSize int - VimMode bool - FilterMessage string - filter string - selectedIndex int - useDefault bool - showingHelp bool -} - -// the data available to the templates when processing -type SelectTemplateData struct { - Select - PageEntries []string - SelectedIndex int - Answer string - ShowAnswer bool - ShowHelp bool -} - -var SelectQuestionTemplate = ` -{{- if .ShowHelp }}{{- color "cyan"}}{{ HelpIcon }} {{ .Help }}{{color "reset"}}{{"\n"}}{{end}} -{{- color "green+hb"}}{{ QuestionIcon }} {{color "reset"}} -{{- color "default+hb"}}{{ .Message }}{{ .FilterMessage }}{{color "reset"}} -{{- if .ShowAnswer}}{{color "cyan"}} {{.Answer}}{{color "reset"}}{{"\n"}} -{{- else}} - {{- " "}}{{- color "cyan"}}[Use arrows to move, type to filter{{- if and .Help (not .ShowHelp)}}, {{ HelpInputRune }} for more help{{end}}]{{color "reset"}} - {{- "\n"}} - {{- range $ix, $choice := .PageEntries}} - {{- if eq $ix $.SelectedIndex}}{{color "cyan+b"}}{{ SelectFocusIcon }} {{else}}{{color "default+hb"}} {{end}} - {{- $choice}} - {{- color "reset"}}{{"\n"}} - {{- end}} -{{- end}}` - -// OnChange is called on every keypress. -func (s *Select) OnChange(line []rune, pos int, key rune) (newLine []rune, newPos int, ok bool) { - options := s.filterOptions() - oldFilter := s.filter - - // if the user pressed the enter key - if key == terminal.KeyEnter { - if s.selectedIndex < len(options) { - return []rune(options[s.selectedIndex]), 0, true - } - // if the user pressed the up arrow or 'k' to emulate vim - } else if key == terminal.KeyArrowUp || (s.VimMode && key == 'k') { - s.useDefault = false - - // if we are at the top of the list - if s.selectedIndex == 0 { - // start from the button - s.selectedIndex = len(options) - 1 - } else { - // otherwise we are not at the top of the list so decrement the selected index - s.selectedIndex-- - } - // if the user pressed down or 'j' to emulate vim - } else if key == terminal.KeyArrowDown || (s.VimMode && key == 'j') { - s.useDefault = false - // if we are at the bottom of the list - if s.selectedIndex == len(options)-1 { - // start from the top - s.selectedIndex = 0 - } else { - // increment the selected index - s.selectedIndex++ - } - // only show the help message if we have one - } else if key == core.HelpInputRune && s.Help != "" { - s.showingHelp = true - // if the user wants to toggle vim mode on/off - } else if key == terminal.KeyEscape { - s.VimMode = !s.VimMode - // if the user hits any of the keys that clear the filter - } else if key == terminal.KeyDeleteWord || key == terminal.KeyDeleteLine { - s.filter = "" - // if the user is deleting a character in the filter - } else if key == terminal.KeyDelete || key == terminal.KeyBackspace { - // if there is content in the filter to delete - if s.filter != "" { - // subtract a line from the current filter - s.filter = s.filter[0 : len(s.filter)-1] - // we removed the last value in the filter - } - } else if key >= terminal.KeySpace { - s.filter += string(key) - // make sure vim mode is disabled - s.VimMode = false - // make sure that we use the current value in the filtered list - s.useDefault = false - } - - s.FilterMessage = "" - if s.filter != "" { - s.FilterMessage = " " + s.filter - } - if oldFilter != s.filter { - // filter changed - options = s.filterOptions() - if len(options) > 0 && len(options) <= s.selectedIndex { - s.selectedIndex = len(options) - 1 - } - } - - // figure out the options and index to render - - // TODO if we have started filtering and were looking at the end of a list - // and we have modified the filter then we should move the page back! - opts, idx := paginate(s.PageSize, options, s.selectedIndex) - - // render the options - s.Render( - SelectQuestionTemplate, - SelectTemplateData{ - Select: *s, - SelectedIndex: idx, - ShowHelp: s.showingHelp, - PageEntries: opts, - }, - ) - - // if we are not pressing ent - if len(options) <= s.selectedIndex { - return []rune{}, 0, false - } - return []rune(options[s.selectedIndex]), 0, true -} - -func (s *Select) filterOptions() []string { - filter := strings.ToLower(s.filter) - if filter == "" { - return s.Options - } - answer := []string{} - for _, o := range s.Options { - if strings.Contains(strings.ToLower(o), filter) { - answer = append(answer, o) - } - } - return answer -} - -func (s *Select) Prompt() (interface{}, error) { - // if there are no options to render - if len(s.Options) == 0 { - // we failed - return "", errors.New("please provide options to select from") - } - - // start off with the first option selected - sel := 0 - // if there is a default - if s.Default != "" { - // find the choice - for i, opt := range s.Options { - // if the option correponds to the default - if opt == s.Default { - // we found our initial value - sel = i - // stop looking - break - } - } - } - // save the selected index - s.selectedIndex = sel - - // figure out the options and index to render - opts, idx := paginate(s.PageSize, s.Options, sel) - - // ask the question - err := s.Render( - SelectQuestionTemplate, - SelectTemplateData{ - Select: *s, - PageEntries: opts, - SelectedIndex: idx, - }, - ) - if err != nil { - return "", err - } - - // by default, use the default value - s.useDefault = true - - rr := s.NewRuneReader() - rr.SetTermMode() - defer rr.RestoreTermMode() - - cursor := s.NewCursor() - cursor.Hide() // hide the cursor - defer cursor.Show() // show the cursor when we're done - - // start waiting for input - for { - r, _, err := rr.ReadRune() - if err != nil { - return "", err - } - if r == '\r' || r == '\n' { - break - } - if r == terminal.KeyInterrupt { - return "", terminal.InterruptErr - } - if r == terminal.KeyEndTransmission { - break - } - s.OnChange(nil, 0, r) - } - options := s.filterOptions() - s.filter = "" - s.FilterMessage = "" - - var val string - // if we are supposed to use the default value - if s.useDefault || s.selectedIndex >= len(options) { - // if there is a default value - if s.Default != "" { - // use the default value - val = s.Default - } else if len(options) > 0 { - // there is no default value so use the first - val = options[0] - } - // otherwise the selected index points to the value - } else if s.selectedIndex < len(options) { - // the - val = options[s.selectedIndex] - } - return val, err -} - -func (s *Select) Cleanup(val interface{}) error { - return s.Render( - SelectQuestionTemplate, - SelectTemplateData{ - Select: *s, - Answer: val.(string), - ShowAnswer: true, - }, - ) -} diff --git a/vendor/github.com/AlecAivazis/survey/survey.go b/vendor/github.com/AlecAivazis/survey/survey.go deleted file mode 100644 index 73f0bf5e6d6..00000000000 --- a/vendor/github.com/AlecAivazis/survey/survey.go +++ /dev/null @@ -1,246 +0,0 @@ -package survey - -import ( - "errors" - "io" - "os" - - "gopkg.in/AlecAivazis/survey.v1/core" - "gopkg.in/AlecAivazis/survey.v1/terminal" -) - -// PageSize is the default maximum number of items to show in select/multiselect prompts -var PageSize = 7 - -// DefaultAskOptions is the default options on ask, using the OS stdio. -var DefaultAskOptions = AskOptions{ - Stdio: terminal.Stdio{ - In: os.Stdin, - Out: os.Stdout, - Err: os.Stderr, - }, -} - -// Validator is a function passed to a Question after a user has provided a response. -// If the function returns an error, then the user will be prompted again for another -// response. -type Validator func(ans interface{}) error - -// Transformer is a function passed to a Question after a user has provided a response. -// The function can be used to implement a custom logic that will result to return -// a different representation of the given answer. -// -// Look `TransformString`, `ToLower` `Title` and `ComposeTransformers` for more. -type Transformer func(ans interface{}) (newAns interface{}) - -// Question is the core data structure for a survey questionnaire. -type Question struct { - Name string - Prompt Prompt - Validate Validator - Transform Transformer -} - -// Prompt is the primary interface for the objects that can take user input -// and return a response. -type Prompt interface { - Prompt() (interface{}, error) - Cleanup(interface{}) error - Error(error) error -} - -// AskOpt allows setting optional ask options. -type AskOpt func(options *AskOptions) error - -// AskOptions provides additional options on ask. -type AskOptions struct { - Stdio terminal.Stdio -} - -// WithStdio specifies the standard input, output and error files survey -// interacts with. By default, these are os.Stdin, os.Stdout, and os.Stderr. -func WithStdio(in terminal.FileReader, out terminal.FileWriter, err io.Writer) AskOpt { - return func(options *AskOptions) error { - options.Stdio.In = in - options.Stdio.Out = out - options.Stdio.Err = err - return nil - } -} - -type wantsStdio interface { - WithStdio(terminal.Stdio) -} - -/* -AskOne performs the prompt for a single prompt and asks for validation if required. -Response types should be something that can be casted from the response type designated -in the documentation. For example: - - name := "" - prompt := &survey.Input{ - Message: "name", - } - - survey.AskOne(prompt, &name, nil) - -*/ -func AskOne(p Prompt, response interface{}, v Validator, opts ...AskOpt) error { - err := Ask([]*Question{{Prompt: p, Validate: v}}, response, opts...) - if err != nil { - return err - } - - return nil -} - -/* -Ask performs the prompt loop, asking for validation when appropriate. The response -type can be one of two options. If a struct is passed, the answer will be written to -the field whose name matches the Name field on the corresponding question. Field types -should be something that can be casted from the response type designated in the -documentation. Note, a survey tag can also be used to identify a Otherwise, a -map[string]interface{} can be passed, responses will be written to the key with the -matching name. For example: - - qs := []*survey.Question{ - { - Name: "name", - Prompt: &survey.Input{Message: "What is your name?"}, - Validate: survey.Required, - Transform: survey.Title, - }, - } - - answers := struct{ Name string }{} - - - err := survey.Ask(qs, &answers) -*/ -func Ask(qs []*Question, response interface{}, opts ...AskOpt) error { - - options := DefaultAskOptions - for _, opt := range opts { - if err := opt(&options); err != nil { - return err - } - } - - // if we weren't passed a place to record the answers - if response == nil { - // we can't go any further - return errors.New("cannot call Ask() with a nil reference to record the answers") - } - - // go over every question - for _, q := range qs { - // If Prompt implements controllable stdio, pass in specified stdio. - if p, ok := q.Prompt.(wantsStdio); ok { - p.WithStdio(options.Stdio) - } - - // grab the user input and save it - ans, err := q.Prompt.Prompt() - // if there was a problem - if err != nil { - return err - } - - // if there is a validate handler for this question - if q.Validate != nil { - // wait for a valid response - for invalid := q.Validate(ans); invalid != nil; invalid = q.Validate(ans) { - err := q.Prompt.Error(invalid) - // if there was a problem - if err != nil { - return err - } - - // ask for more input - ans, err = q.Prompt.Prompt() - // if there was a problem - if err != nil { - return err - } - } - } - - if q.Transform != nil { - // check if we have a transformer available, if so - // then try to acquire the new representation of the - // answer, if the resulting answer is not nil. - if newAns := q.Transform(ans); newAns != nil { - ans = newAns - } - } - - // tell the prompt to cleanup with the validated value - q.Prompt.Cleanup(ans) - - // if something went wrong - if err != nil { - // stop listening - return err - } - - // add it to the map - err = core.WriteAnswer(response, q.Name, ans) - // if something went wrong - if err != nil { - return err - } - - } - - // return the response - return nil -} - -// paginate returns a single page of choices given the page size, the total list of -// possible choices, and the current selected index in the total list. -func paginate(page int, choices []string, sel int) ([]string, int) { - // the number of elements to show in a single page - var pageSize int - // if the select has a specific page size - if page != 0 { - // use the specified one - pageSize = page - // otherwise the select does not have a page size - } else { - // use the package default - pageSize = PageSize - } - - var start, end, cursor int - - if len(choices) < pageSize { - // if we dont have enough options to fill a page - start = 0 - end = len(choices) - cursor = sel - - } else if sel < pageSize/2 { - // if we are in the first half page - start = 0 - end = pageSize - cursor = sel - - } else if len(choices)-sel-1 < pageSize/2 { - // if we are in the last half page - start = len(choices) - pageSize - end = len(choices) - cursor = sel - start - - } else { - // somewhere in the middle - above := pageSize / 2 - below := pageSize - above - - cursor = pageSize / 2 - start = sel - above - end = sel + below - } - - // return the subset we care about and the index - return choices[start:end], cursor -} diff --git a/vendor/github.com/AlecAivazis/survey/transform.go b/vendor/github.com/AlecAivazis/survey/transform.go deleted file mode 100644 index ccc75e08431..00000000000 --- a/vendor/github.com/AlecAivazis/survey/transform.go +++ /dev/null @@ -1,76 +0,0 @@ -package survey - -import ( - "reflect" - "strings" -) - -// TransformString returns a `Transformer` based on the "f" -// function which accepts a string representation of the answer -// and returns a new one, transformed, answer. -// Take for example the functions inside the std `strings` package, -// they can be converted to a compatible `Transformer` by using this function, -// i.e: `TransformString(strings.Title)`, `TransformString(strings.ToUpper)`. -// -// Note that `TransformString` is just a helper, `Transformer` can be used -// to transform any type of answer. -func TransformString(f func(s string) string) Transformer { - return func(ans interface{}) interface{} { - // if the answer value passed in is the zero value of the appropriate type - if isZero(reflect.ValueOf(ans)) { - // skip this `Transformer` by returning a nil value. - // The original answer will be not affected, - // see survey.go#L125. - return nil - } - - // "ans" is never nil here, so we don't have to check that - // see survey.go#L97 for more. - // Make sure that the the answer's value was a typeof string. - s, ok := ans.(string) - if !ok { - return nil - } - - return f(s) - } -} - -// ToLower is a `Transformer`. -// It receives an answer value -// and returns a copy of the "ans" -// with all Unicode letters mapped to their lower case. -// -// Note that if "ans" is not a string then it will -// return a nil value, meaning that the above answer -// will not be affected by this call at all. -func ToLower(ans interface{}) interface{} { - transformer := TransformString(strings.ToLower) - return transformer(ans) -} - -// Title is a `Transformer`. -// It receives an answer value -// and returns a copy of the "ans" -// with all Unicode letters that begin words -// mapped to their title case. -// -// Note that if "ans" is not a string then it will -// return a nil value, meaning that the above answer -// will not be affected by this call at all. -func Title(ans interface{}) interface{} { - transformer := TransformString(strings.Title) - return transformer(ans) -} - -// ComposeTransformers is a variadic function used to create one transformer from many. -func ComposeTransformers(transformers ...Transformer) Transformer { - // return a transformer that calls each one sequentially - return func(ans interface{}) interface{} { - // execute each transformer - for _, t := range transformers { - ans = t(ans) - } - return ans - } -} diff --git a/vendor/github.com/AlecAivazis/survey/validate.go b/vendor/github.com/AlecAivazis/survey/validate.go deleted file mode 100644 index 208eac91a46..00000000000 --- a/vendor/github.com/AlecAivazis/survey/validate.go +++ /dev/null @@ -1,87 +0,0 @@ -package survey - -import ( - "errors" - "fmt" - "reflect" -) - -// Required does not allow an empty value -func Required(val interface{}) error { - // the reflect value of the result - value := reflect.ValueOf(val) - - // if the value passed in is the zero value of the appropriate type - if isZero(value) && value.Kind() != reflect.Bool { - return errors.New("Value is required") - } - return nil -} - -// MaxLength requires that the string is no longer than the specified value -func MaxLength(length int) Validator { - // return a validator that checks the length of the string - return func(val interface{}) error { - if str, ok := val.(string); ok { - // if the string is longer than the given value - if len(str) > length { - // yell loudly - return fmt.Errorf("value is too long. Max length is %v", length) - } - } else { - // otherwise we cannot convert the value into a string and cannot enforce length - return fmt.Errorf("cannot enforce length on response of type %v", reflect.TypeOf(val).Name()) - } - - // the input is fine - return nil - } -} - -// MinLength requires that the string is longer or equal in length to the specified value -func MinLength(length int) Validator { - // return a validator that checks the length of the string - return func(val interface{}) error { - if str, ok := val.(string); ok { - // if the string is shorter than the given value - if len(str) < length { - // yell loudly - return fmt.Errorf("value is too short. Min length is %v", length) - } - } else { - // otherwise we cannot convert the value into a string and cannot enforce length - return fmt.Errorf("cannot enforce length on response of type %v", reflect.TypeOf(val).Name()) - } - - // the input is fine - return nil - } -} - -// ComposeValidators is a variadic function used to create one validator from many. -func ComposeValidators(validators ...Validator) Validator { - // return a validator that calls each one sequentially - return func(val interface{}) error { - // execute each validator - for _, validator := range validators { - // if the answer's value is not valid - if err := validator(val); err != nil { - // return the error - return err - } - } - // we passed all validators, the answer is valid - return nil - } -} - -// isZero returns true if the passed value is the zero object -func isZero(v reflect.Value) bool { - switch v.Kind() { - case reflect.Slice, reflect.Map: - return v.Len() == 0 - } - - // compare the types directly with more general coverage - return reflect.DeepEqual(v.Interface(), reflect.Zero(v.Type()).Interface()) -} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/version.go b/vendor/github.com/aws/aws-sdk-go/aws/version.go index be84dd516e4..484d730ad63 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/version.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/version.go @@ -5,4 +5,4 @@ package aws const SDKName = "aws-sdk-go" // SDKVersion is the version of this SDK -const SDKVersion = "1.15.43" +const SDKVersion = "1.15.45" diff --git a/vendor/github.com/aws/aws-sdk-go/service/ec2/api.go b/vendor/github.com/aws/aws-sdk-go/service/ec2/api.go index 5d4ffc3d48c..5e18932db67 100644 --- a/vendor/github.com/aws/aws-sdk-go/service/ec2/api.go +++ b/vendor/github.com/aws/aws-sdk-go/service/ec2/api.go @@ -71161,6 +71161,15 @@ const ( // InstanceTypeZ1d12xlarge is a InstanceType enum value InstanceTypeZ1d12xlarge = "z1d.12xlarge" + + // InstanceTypeU6tb1Metal is a InstanceType enum value + InstanceTypeU6tb1Metal = "u-6tb1.metal" + + // InstanceTypeU9tb1Metal is a InstanceType enum value + InstanceTypeU9tb1Metal = "u-9tb1.metal" + + // InstanceTypeU12tb1Metal is a InstanceType enum value + InstanceTypeU12tb1Metal = "u-12tb1.metal" ) const ( From 8ff1cee1ce799d1e8ae149a93aa615d31427059b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 28 Sep 2018 13:50:16 -0700 Subject: [PATCH 3/3] hack/yaml-lint: No-op this script Temporarily make the script a no-op while we work out whether we want to keep this. It's currently complaining about the YAML output from Glide in the previous commit [1]: ./glide.yaml 1:1 warning missing document start "---" (document-start) 3:1 error wrong indentation: expected 2 but found 0 (indentation) 5:1 error wrong indentation: expected 2 but found 0 (indentation) 38:1 error wrong indentation: expected 2 but found 0 (indentation) Dropping the script entirely would break CI [2]. Alex is ok dropping yamllint entirely, but I'm half-interested in keeping it around in case we decide to move any static YAML assets (e.g. pkg/asset/manifests/content/tectonic/rbac/role-user.go) over into data/data. [1]: https://storage.googleapis.com/origin-ci-test/pr-logs/pull/openshift_installer/370/pull-ci-openshift-installer-yaml-lint/636/build-log.txt [2]: https://github.com/openshift/release/blob/d7ea5b36da63140fbb99c293aadde3bb279a24f9/ci-operator/jobs/openshift/installer/openshift-installer-master-presubmits.yaml#L354 --- CONTRIBUTING.md | 1 - hack/yaml-lint.sh | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e9e9029e5a5..e5a3b0f0642 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,7 +42,6 @@ For contributors who want to work up pull requests, the workflow is roughly: hack/shellcheck.sh hack/tf-fmt.sh -list -check hack/tf-lint.sh - hack/yaml-lint.sh ``` 7. Submit a pull request to the original repository. 8. The [repo](OWNERS) [owners](OWNERS_ALIASES) will respond to your issue promptly, following [the ususal Prow workflow][prow-review]. diff --git a/hack/yaml-lint.sh b/hack/yaml-lint.sh index 8b24d6158e4..5441a7dbebf 100755 --- a/hack/yaml-lint.sh +++ b/hack/yaml-lint.sh @@ -1,4 +1,5 @@ #!/bin/sh +exit 0 # temporarily disable while we work out whether to drop this if [ "$IS_CONTAINER" != "" ]; then yamllint --config-data "{extends: default, rules: {line-length: {level: warning, max: 120}}}" . else