Skip to content

Commit

Permalink
Upgrade AlecAivazais/survey to v2.3.5
Browse files Browse the repository at this point in the history
I was having trouble debugging some tests I was working on refactoring, and eventually realized this was due to AlecAivazis/survey#408, which was fixed in survey v2.3.3.

This also ends up upgrading hinshun/vt10x, getting rid of the `NewVT10xTerminal` function we'd been calling in a few places, so I band-aided that by adding an equivalent function in `test/helper/helpers.go`.

Signed-off-by: Andrew Bayer <[email protected]>
  • Loading branch information
abayer committed Jun 28, 2022
1 parent 9a7f6a9 commit b595de4
Show file tree
Hide file tree
Showing 122 changed files with 1,284 additions and 1,041 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/tektoncd/cli
go 1.17

require (
github.com/AlecAivazis/survey/v2 v2.3.2
github.com/Netflix/go-expect v0.0.0-20200312175327-da48e75238e2
github.com/AlecAivazis/survey/v2 v2.3.5
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2
github.com/armon/go-metrics v0.4.0
github.com/armon/go-radix v1.0.0
github.com/blang/semver v3.5.1+incompatible
Expand Down Expand Up @@ -38,7 +38,7 @@ require (
github.com/hashicorp/hcl v1.0.0
github.com/hashicorp/vault/sdk v0.5.2
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87
github.com/hinshun/vt10x v0.0.0-20180809195222-d55458df857c
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec
github.com/jonboulle/clockwork v0.3.0
github.com/ktr0731/go-fuzzyfinder v0.6.0
github.com/mitchellh/copystructure v1.2.0
Expand Down Expand Up @@ -81,6 +81,7 @@ require (
)

require (
github.com/creack/pty v1.1.17
github.com/letsencrypt/boulder v0.0.0-20220331220046-b23ab962616e
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399
)
Expand Down Expand Up @@ -231,7 +232,6 @@ require (
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kelseyhightower/envconfig v1.4.0 // indirect
github.com/klauspost/compress v1.15.1 // indirect
github.com/kr/pty v1.1.8 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/lucasb-eyer/go-colorful v1.0.3 // indirect
Expand Down
15 changes: 9 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ git.apache.org/thrift.git v0.12.0/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqbl
github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8/go.mod h1:CzsSbkDixRphAF5hS6wbMKq0eI6ccJRb7/A0M6JBnwg=
github.com/AdaLogics/go-fuzz-headers v0.0.0-20211102141018-f7be0cbad29c/go.mod h1:WpB7kf89yJUETZxQnP1kgYPNwlT2jjdDYUCoxVggM3g=
github.com/AlecAivazis/survey/v2 v2.2.12/go.mod h1:6d4saEvBsfSHXeN1a5OA5m2+HJ2LuVokllnC77pAIKI=
github.com/AlecAivazis/survey/v2 v2.3.2 h1:TqTB+aDDCLYhf9/bD2TwSO8u8jDSmMUd2SUVO4gCnU8=
github.com/AlecAivazis/survey/v2 v2.3.2/go.mod h1:TH2kPCDU3Kqq7pLbnCWwZXDBjnhZtmsCle5EiYDJ2fg=
github.com/AlecAivazis/survey/v2 v2.3.5 h1:A8cYupsAZkjaUmhtTYv3sSqc7LO5mp1XDfqe5E/9wRQ=
github.com/AlecAivazis/survey/v2 v2.3.5/go.mod h1:4AuI9b7RjAR+G7v9+C4YSlX/YL3K3cWNXgWXOhllqvI=
github.com/Antonboom/errname v0.1.5/go.mod h1:DugbBstvPFQbv/5uLcRRzfrNqKE9tVdVCqWCLp6Cifo=
github.com/Antonboom/nilnil v0.1.0/go.mod h1:PhHLvRPSghY5Y7mX4TW+BHZQYo1A8flE5H20D3IPZBo=
github.com/Azure/azure-amqp-common-go/v2 v2.1.0/go.mod h1:R8rea+gJRuJR6QxTir/XuEd+YuKoUiazDC/N96FiDEU=
Expand Down Expand Up @@ -280,8 +280,9 @@ github.com/Microsoft/hcsshim/test v0.0.0-20210227013316-43a75bb4edd3/go.mod h1:m
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc=
github.com/Netflix/go-expect v0.0.0-20200312175327-da48e75238e2 h1:y2avNRjCeJT8b7svzjhKZjsvW5Jki/iAqTBEPJURaUg=
github.com/Netflix/go-expect v0.0.0-20200312175327-da48e75238e2/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q=
github.com/OpenPeeDeeP/depguard v1.0.1/go.mod h1:xsIw86fROiiwelg+jB2uM9PiKihMMmUx/1V+TNhjQvM=
Expand Down Expand Up @@ -781,8 +782,9 @@ github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.16 h1:vfetlOf3A+9YKggibynnX9mnFjuSVvkRj+IWpcTSLEQ=
github.com/creack/pty v1.1.16/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/cyberphone/json-canonicalization v0.0.0-20210303052042-6bc126869bf4/go.mod h1:uzvlm1mxhHkdfqitSA92i7Se+S9ksOn3a3qmv/kyOCw=
github.com/cyberphone/json-canonicalization v0.0.0-20210823021906-dc406ceaf94b h1:lMzA7yYThpwx7iYNpTeiQnRH6h5JSfSYMJdz+pxZOW8=
github.com/cyberphone/json-canonicalization v0.0.0-20210823021906-dc406ceaf94b/go.mod h1:uzvlm1mxhHkdfqitSA92i7Se+S9ksOn3a3qmv/kyOCw=
Expand Down Expand Up @@ -1657,8 +1659,8 @@ github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 h1:xixZ2bWeofWV68J
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A=
github.com/hinshun/vt10x v0.0.0-20180809195222-d55458df857c h1:kp3AxgXgDOmIJFR7bIwqFhwJ2qWar8tEQSE5XXhCfVk=
github.com/hinshun/vt10x v0.0.0-20180809195222-d55458df857c/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A=
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog=
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
github.com/honeycombio/beeline-go v1.1.1 h1:sU8r4ae34uEL3/CguSl8Mr+Asz9DL1nfH9Wwk85Pc7U=
github.com/honeycombio/beeline-go v1.1.1/go.mod h1:kN0cfUGBMfA87DyCYbiiLoSzWsnw3bluZvNEWtatHxk=
github.com/honeycombio/libhoney-go v1.15.2 h1:5NGcjOxZZma13dmzNcl3OtGbF1hECA0XHJNHEb2t2ck=
Expand Down Expand Up @@ -3325,6 +3327,7 @@ golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 h1:nonptSpoQ4vQjyraW20DXPAglgQfVnM9ZC6MmNLMR60=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
Expand Down
8 changes: 5 additions & 3 deletions pkg/cmd/pipelineresource/resource_testUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/terminal"
goexpect "github.com/Netflix/go-expect"
"github.com/hinshun/vt10x"
"github.com/tektoncd/cli/test/helper"
"gotest.tools/v3/assert"
)

Expand Down Expand Up @@ -53,9 +53,11 @@ func (pt *promptTest) runTest(t *testing.T, procedure func(*goexpect.Console) er

// Multiplex output to a buffer as well for the raw bytes.
buf := new(bytes.Buffer)
c, state, err := vt10x.NewVT10XConsole(goexpect.WithStdout(buf))
c, state, err := helper.NewVT10XConsole(goexpect.WithStdout(buf))
assert.NilError(t, err)
defer c.Close()
defer func() {
_ = c.Close()
}()

donec := make(chan struct{})
go func() {
Expand Down
4 changes: 2 additions & 2 deletions test/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

"github.com/Netflix/go-expect"
goexpect "github.com/Netflix/go-expect"
"github.com/hinshun/vt10x"
"github.com/tektoncd/cli/test/helper"
"gotest.tools/v3/assert"
"gotest.tools/v3/icmd"
)
Expand Down Expand Up @@ -113,7 +113,7 @@ func (e TknRunner) RunInteractiveTests(t *testing.T, ops *Prompt) *expect.Consol

// Multiplex output to a buffer as well for the raw bytes.
buf := new(bytes.Buffer)
c, state, err := vt10x.NewVT10XConsole(goexpect.WithStdout(buf))
c, state, err := helper.NewVT10XConsole(goexpect.WithStdout(buf))
assert.NilError(t, err)
defer c.Close()

Expand Down
21 changes: 21 additions & 0 deletions test/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import (
"testing"
"text/template"

"github.com/Netflix/go-expect"
"github.com/creack/pty"
"github.com/google/go-cmp/cmp"
"github.com/hinshun/vt10x"
gotestcmp "gotest.tools/assert/cmp"
)

Expand Down Expand Up @@ -92,3 +95,21 @@ func ContainsAll(target string, substrings ...string) gotestcmp.Comparison {
return gotestcmp.ResultSuccess
}
}

// NewVT10XConsole returns a new expect.Console that multiplexes the
// Stdin/Stdout to a VT10X terminal, allowing Console to interact with an
// application sending ANSI escape sequences.
func NewVT10XConsole(opts ...expect.ConsoleOpt) (*expect.Console, vt10x.Terminal, error) {
ptm, pts, err := pty.Open()
if err != nil {
return nil, nil, err
}

term := vt10x.New(vt10x.WithWriter(pts))
c, err := expect.NewConsole(append(opts, expect.WithStdin(ptm), expect.WithStdout(term), expect.WithCloser(ptm, pts))...)
if err != nil {
return nil, nil, err
}

return c, term, nil
}
4 changes: 2 additions & 2 deletions test/prompt/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/terminal"
goexpect "github.com/Netflix/go-expect"
"github.com/hinshun/vt10x"
"github.com/tektoncd/cli/test/helper"
"gotest.tools/v3/assert"
)

Expand All @@ -36,7 +36,7 @@ type Prompt struct {
func (pt *Prompt) RunTest(t *testing.T, procedure func(*goexpect.Console) error, test func(terminal.Stdio) error) {
// Multiplex output to a buffer as well for the raw bytes.
buf := new(bytes.Buffer)
c, state, err := vt10x.NewVT10XConsole(goexpect.WithStdout(buf))
c, state, err := helper.NewVT10XConsole(goexpect.WithStdout(buf))
assert.NilError(t, err)
defer c.Close()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
`go-plugin` is a Go (golang) plugin system over RPC. It is the plugin system
that has been in use by HashiCorp tooling for over 4 years. While initially
created for [Packer](https://www.packer.io), it is additionally in use by
[Terraform](https://www.terraform.io), [Nomad](https://www.nomadproject.io), and
[Vault](https://www.vaultproject.io).
[Terraform](https://www.terraform.io), [Nomad](https://www.nomadproject.io),
[Vault](https://www.vaultproject.io), and
[Boundary](https://www.boundaryproject.io).

While the plugin system is over RPC, it is currently only designed to work
over a local [reliable] network. Plugins over a real network are not supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,8 @@ func (c *Client) Start() (addr net.Addr, err error) {

c.config.TLSConfig = &tls.Config{
Certificates: []tls.Certificate{cert},
ClientAuth: tls.RequireAndVerifyClientCert,
MinVersion: tls.VersionTLS12,
ServerName: "localhost",
}
}
Expand Down Expand Up @@ -629,17 +631,19 @@ func (c *Client) Start() (addr net.Addr, err error) {
// Wait for the command to end.
err := cmd.Wait()

debugMsgArgs := []interface{}{
msgArgs := []interface{}{
"path", path,
"pid", pid,
}
if err != nil {
debugMsgArgs = append(debugMsgArgs,
msgArgs = append(msgArgs,
[]interface{}{"error", err.Error()}...)
c.logger.Error("plugin process exited", msgArgs...)
} else {
// Log and make sure to flush the logs right away
c.logger.Info("plugin process exited", msgArgs...)
}

// Log and make sure to flush the logs write away
c.logger.Debug("plugin process exited", debugMsgArgs...)
os.Stderr.Sync()

// Set that we exited, which takes a lock
Expand Down Expand Up @@ -774,7 +778,7 @@ func (c *Client) Start() (addr net.Addr, err error) {
}

// loadServerCert is used by AutoMTLS to read an x.509 cert returned by the
// server, and load it as the RootCA for the client TLSConfig.
// server, and load it as the RootCA and ClientCA for the client TLSConfig.
func (c *Client) loadServerCert(cert string) error {
certPool := x509.NewCertPool()

Expand All @@ -791,6 +795,7 @@ func (c *Client) loadServerCert(cert string) error {
certPool.AddCert(x509Cert)

c.config.TLSConfig.RootCAs = certPool
c.config.TLSConfig.ClientCAs = certPool
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ func (s *RPCServer) Serve(lis net.Listener) {
for {
conn, err := lis.Accept()
if err != nil {
log.Printf("[ERR] plugin: plugin server: %s", err)
severity := "ERR"
if errors.Is(err, net.ErrClosed) {
severity = "DEBUG"
}
log.Printf("[%s] plugin: plugin server: %s", severity, err)
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,13 @@ func Serve(opts *ServeConfig) {

certPEM, keyPEM, err := generateCert()
if err != nil {
logger.Error("failed to generate client certificate", "error", err)
logger.Error("failed to generate server certificate", "error", err)
panic(err)
}

cert, err := tls.X509KeyPair(certPEM, keyPEM)
if err != nil {
logger.Error("failed to parse client certificate", "error", err)
logger.Error("failed to parse server certificate", "error", err)
panic(err)
}

Expand All @@ -319,6 +319,8 @@ func Serve(opts *ServeConfig) {
ClientAuth: tls.RequireAndVerifyClientCert,
ClientCAs: clientCertPool,
MinVersion: tls.VersionTLS12,
RootCAs: clientCertPool,
ServerName: "localhost",
}

// We send back the raw leaf cert data for the client rather than the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//go:build !darwin
// +build !darwin

package rootcerts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//go:build darwin || nacl || netbsd || plan9 || windows
// +build darwin nacl netbsd plan9 windows

package mlock
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//go:build dragonfly || freebsd || linux || openbsd || solaris
// +build dragonfly freebsd linux openbsd solaris

package mlock
Expand Down
Loading

0 comments on commit b595de4

Please sign in to comment.