From c1c3add698bd65c35aea700cc1e488a57f584b1e Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Wed, 14 Nov 2018 11:28:16 +0000 Subject: [PATCH 1/5] Bump to gotest.tools v2.2.0 I would like to use the regex matcher Signed-off-by: Ian Campbell (cherry picked from commit 986196e3e34bd80c6ed61d2f291214fcb1795940) Signed-off-by: Sebastiaan van Stijn --- vendor.conf | 2 +- vendor/gotest.tools/LICENSE | 209 +----------------- vendor/gotest.tools/README.md | 2 +- vendor/gotest.tools/assert/cmp/compare.go | 48 +++- vendor/gotest.tools/assert/result.go | 1 - vendor/gotest.tools/env/env.go | 3 + vendor/gotest.tools/fs/file.go | 14 +- vendor/gotest.tools/fs/manifest.go | 9 +- vendor/gotest.tools/fs/ops.go | 28 ++- vendor/gotest.tools/fs/path.go | 9 + vendor/gotest.tools/fs/report.go | 18 +- vendor/gotest.tools/golden/golden.go | 2 +- vendor/gotest.tools/icmd/command.go | 9 +- vendor/gotest.tools/icmd/ops.go | 34 +++ .../gotest.tools/internal/difflib/difflib.go | 25 ++- vendor/gotest.tools/internal/source/defers.go | 53 +++++ vendor/gotest.tools/internal/source/source.go | 203 ++++++++--------- 17 files changed, 338 insertions(+), 331 deletions(-) create mode 100644 vendor/gotest.tools/internal/source/defers.go diff --git a/vendor.conf b/vendor.conf index 5b5f04a675..98f107955a 100755 --- a/vendor.conf +++ b/vendor.conf @@ -91,7 +91,7 @@ google.golang.org/genproto 02b4e95473316948020af0b7a4f0f22c73929b0e google.golang.org/grpc v1.12.0 gopkg.in/inf.v0 d2d2541c53f18d2a059457998ce2876cc8e67cbf # v0.9.1 gopkg.in/yaml.v2 5420a8b6744d3b0345ab293f6fcba19c978f1183 # v2.2.1 -gotest.tools v2.1.0 +gotest.tools v2.2.0 k8s.io/api kubernetes-1.11.2 k8s.io/apimachinery kubernetes-1.11.2 k8s.io/client-go kubernetes-1.11.2 diff --git a/vendor/gotest.tools/LICENSE b/vendor/gotest.tools/LICENSE index d645695673..aeaa2fac3d 100644 --- a/vendor/gotest.tools/LICENSE +++ b/vendor/gotest.tools/LICENSE @@ -1,202 +1,13 @@ +Copyright 2018 gotest.tools authors - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + http://www.apache.org/licenses/LICENSE-2.0 - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vendor/gotest.tools/README.md b/vendor/gotest.tools/README.md index f5df204315..26a2026de2 100644 --- a/vendor/gotest.tools/README.md +++ b/vendor/gotest.tools/README.md @@ -3,7 +3,7 @@ A collection of packages to augment `testing` and support common patterns. [![GoDoc](https://godoc.org/gotest.tools?status.svg)](https://godoc.org/gotest.tools) -[![CircleCI](https://circleci.com/gh/gotestyourself/gotestyourself/tree/master.svg?style=shield)](https://circleci.com/gh/gotestyourself/gotestyourself/tree/master) +[![CircleCI](https://circleci.com/gh/gotestyourself/gotest.tools/tree/master.svg?style=shield)](https://circleci.com/gh/gotestyourself/gotest.tools/tree/master) [![Go Reportcard](https://goreportcard.com/badge/gotest.tools)](https://goreportcard.com/report/gotest.tools) diff --git a/vendor/gotest.tools/assert/cmp/compare.go b/vendor/gotest.tools/assert/cmp/compare.go index ae03749e20..cf48d887ac 100644 --- a/vendor/gotest.tools/assert/cmp/compare.go +++ b/vendor/gotest.tools/assert/cmp/compare.go @@ -4,6 +4,7 @@ package cmp // import "gotest.tools/assert/cmp" import ( "fmt" "reflect" + "regexp" "strings" "github.com/google/go-cmp/cmp" @@ -58,6 +59,39 @@ func toResult(success bool, msg string) Result { return ResultFailure(msg) } +// RegexOrPattern may be either a *regexp.Regexp or a string that is a valid +// regexp pattern. +type RegexOrPattern interface{} + +// Regexp succeeds if value v matches regular expression re. +// +// Example: +// assert.Assert(t, cmp.Regexp("^[0-9a-f]{32}$", str)) +// r := regexp.MustCompile("^[0-9a-f]{32}$") +// assert.Assert(t, cmp.Regexp(r, str)) +func Regexp(re RegexOrPattern, v string) Comparison { + match := func(re *regexp.Regexp) Result { + return toResult( + re.MatchString(v), + fmt.Sprintf("value %q does not match regexp %q", v, re.String())) + } + + return func() Result { + switch regex := re.(type) { + case *regexp.Regexp: + return match(regex) + case string: + re, err := regexp.Compile(regex) + if err != nil { + return ResultFailure(err.Error()) + } + return match(re) + default: + return ResultFailure(fmt.Sprintf("invalid type %T for regex pattern", regex)) + } + } +} + // Equal succeeds if x == y. See assert.Equal for full documentation. func Equal(x, y interface{}) Comparison { return func() Result { @@ -186,7 +220,7 @@ func Error(err error, message string) Comparison { return ResultFailure("expected an error, got nil") case err.Error() != message: return ResultFailure(fmt.Sprintf( - "expected error %q, got %+v", message, err)) + "expected error %q, got %s", message, formatErrorMessage(err))) } return ResultSuccess } @@ -201,12 +235,22 @@ func ErrorContains(err error, substring string) Comparison { return ResultFailure("expected an error, got nil") case !strings.Contains(err.Error(), substring): return ResultFailure(fmt.Sprintf( - "expected error to contain %q, got %+v", substring, err)) + "expected error to contain %q, got %s", substring, formatErrorMessage(err))) } return ResultSuccess } } +func formatErrorMessage(err error) string { + if _, ok := err.(interface { + Cause() error + }); ok { + return fmt.Sprintf("%q\n%+v", err, err) + } + // This error was not wrapped with github.com/pkg/errors + return fmt.Sprintf("%q", err) +} + // Nil succeeds if obj is a nil interface, pointer, or function. // // Use NilError() for comparing errors. Use Len(obj, 0) for comparing slices, diff --git a/vendor/gotest.tools/assert/result.go b/vendor/gotest.tools/assert/result.go index 3900264d0b..949d939619 100644 --- a/vendor/gotest.tools/assert/result.go +++ b/vendor/gotest.tools/assert/result.go @@ -70,7 +70,6 @@ func filterPrintableExpr(args []ast.Expr) []ast.Expr { result[i] = starExpr.X continue } - result[i] = nil } return result } diff --git a/vendor/gotest.tools/env/env.go b/vendor/gotest.tools/env/env.go index ed0f189916..609d90e996 100644 --- a/vendor/gotest.tools/env/env.go +++ b/vendor/gotest.tools/env/env.go @@ -79,6 +79,9 @@ func ToMap(env []string) map[string]string { } func getParts(raw string) (string, string) { + if raw == "" { + return "", "" + } // Environment variables on windows can begin with = // http://blogs.msdn.com/b/oldnewthing/archive/2010/05/06/10008132.aspx parts := strings.SplitN(raw[1:], "=", 2) diff --git a/vendor/gotest.tools/fs/file.go b/vendor/gotest.tools/fs/file.go index 8bf0188d2f..8322c8f444 100644 --- a/vendor/gotest.tools/fs/file.go +++ b/vendor/gotest.tools/fs/file.go @@ -7,6 +7,8 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" + "strings" "gotest.tools/assert" "gotest.tools/x/subtest" @@ -40,7 +42,7 @@ func NewFile(t assert.TestingT, prefix string, ops ...PathOp) *File { if ht, ok := t.(helperT); ok { ht.Helper() } - tempfile, err := ioutil.TempFile("", prefix+"-") + tempfile, err := ioutil.TempFile("", cleanPrefix(prefix)+"-") assert.NilError(t, err) file := &File{path: tempfile.Name()} assert.NilError(t, tempfile.Close()) @@ -54,6 +56,14 @@ func NewFile(t assert.TestingT, prefix string, ops ...PathOp) *File { return file } +func cleanPrefix(prefix string) string { + // windows requires both / and \ are replaced + if runtime.GOOS == "windows" { + prefix = strings.Replace(prefix, string(os.PathSeparator), "-", -1) + } + return strings.Replace(prefix, "/", "-", -1) +} + // Path returns the full path to the file func (f *File) Path() string { return f.path @@ -76,7 +86,7 @@ func NewDir(t assert.TestingT, prefix string, ops ...PathOp) *Dir { if ht, ok := t.(helperT); ok { ht.Helper() } - path, err := ioutil.TempDir("", prefix+"-") + path, err := ioutil.TempDir("", cleanPrefix(prefix)+"-") assert.NilError(t, err) dir := &Dir{path: path} diff --git a/vendor/gotest.tools/fs/manifest.go b/vendor/gotest.tools/fs/manifest.go index 00976ef19c..a98a70aaf4 100644 --- a/vendor/gotest.tools/fs/manifest.go +++ b/vendor/gotest.tools/fs/manifest.go @@ -24,7 +24,8 @@ type resource struct { type file struct { resource - content io.ReadCloser + content io.ReadCloser + ignoreCariageReturn bool } func (f *file) Type() string { @@ -113,6 +114,9 @@ func getTypedResource(path string, info os.FileInfo) (dirEntry, error) { func newSymlink(path string, info os.FileInfo) (*symlink, error) { target, err := os.Readlink(path) + if err != nil { + return nil, err + } return &symlink{ resource: newResourceFromInfo(info), target: target, @@ -122,6 +126,9 @@ func newSymlink(path string, info os.FileInfo) (*symlink, error) { func newFile(path string, info os.FileInfo) (*file, error) { // TODO: defer file opening to reduce number of open FDs? readCloser, err := os.Open(path) + if err != nil { + return nil, err + } return &file{ resource: newResourceFromInfo(info), content: readCloser, diff --git a/vendor/gotest.tools/fs/ops.go b/vendor/gotest.tools/fs/ops.go index ec9d11c110..a8d087c832 100644 --- a/vendor/gotest.tools/fs/ops.go +++ b/vendor/gotest.tools/fs/ops.go @@ -172,23 +172,35 @@ func copyDirectory(source, dest string) error { for _, entry := range entries { sourcePath := filepath.Join(source, entry.Name()) destPath := filepath.Join(dest, entry.Name()) - if entry.IsDir() { + switch { + case entry.IsDir(): if err := os.Mkdir(destPath, 0755); err != nil { return err } if err := copyDirectory(sourcePath, destPath); err != nil { return err } - continue - } - // TODO: handle symlinks - if err := copyFile(sourcePath, destPath); err != nil { - return err + case entry.Mode()&os.ModeSymlink != 0: + if err := copySymLink(sourcePath, destPath); err != nil { + return err + } + default: + if err := copyFile(sourcePath, destPath); err != nil { + return err + } } } return nil } +func copySymLink(source, dest string) error { + link, err := os.Readlink(source) + if err != nil { + return err + } + return os.Symlink(link, dest) +} + func copyFile(source, dest string) error { content, err := ioutil.ReadFile(source) if err != nil { @@ -219,7 +231,7 @@ func WithSymlink(path, target string) PathOp { func WithHardlink(path, target string) PathOp { return func(root Path) error { if _, ok := root.(manifestDirectory); ok { - return errors.New("WithHardlink yet implemented for manifests") + return errors.New("WithHardlink not implemented for manifests") } return os.Link(filepath.Join(root.Path(), target), filepath.Join(root.Path(), path)) } @@ -230,7 +242,7 @@ func WithHardlink(path, target string) PathOp { func WithTimestamps(atime, mtime time.Time) PathOp { return func(root Path) error { if _, ok := root.(manifestDirectory); ok { - return errors.New("WithTimestamp yet implemented for manifests") + return errors.New("WithTimestamp not implemented for manifests") } return os.Chtimes(root.Path(), atime, mtime) } diff --git a/vendor/gotest.tools/fs/path.go b/vendor/gotest.tools/fs/path.go index baf777f0df..8ffa0a0f82 100644 --- a/vendor/gotest.tools/fs/path.go +++ b/vendor/gotest.tools/fs/path.go @@ -127,6 +127,15 @@ func MatchAnyFileContent(path Path) error { return nil } +// MatchContentIgnoreCarriageReturn is a PathOp that ignores cariage return +// discrepancies. +func MatchContentIgnoreCarriageReturn(path Path) error { + if m, ok := path.(*filePath); ok { + m.file.ignoreCariageReturn = true + } + return nil +} + const anyFile = "*" // MatchExtraFiles is a PathOp that updates a Manifest to allow a directory diff --git a/vendor/gotest.tools/fs/report.go b/vendor/gotest.tools/fs/report.go index 4de85a6ef7..b85bb09a75 100644 --- a/vendor/gotest.tools/fs/report.go +++ b/vendor/gotest.tools/fs/report.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" "sort" "strings" @@ -67,6 +68,11 @@ func eqResource(x, y resource) []problem { return p } +func removeCarriageReturn(in []byte) []byte { + return bytes.Replace(in, []byte("\r\n"), []byte("\n"), -1) +} + +// nolint: gocyclo func eqFile(x, y *file) []problem { p := eqResource(x.resource, y.resource) @@ -95,6 +101,10 @@ func eqFile(x, y *file) []problem { if xErr != nil || yErr != nil { return p } + if x.ignoreCariageReturn || y.ignoreCariageReturn { + xContent = removeCarriageReturn(xContent) + yContent = removeCarriageReturn(yContent) + } if !bytes.Equal(xContent, yContent) { p = append(p, diffContent(xContent, yContent)) @@ -126,7 +136,13 @@ func indent(s, prefix string) string { func eqSymlink(x, y *symlink) []problem { p := eqResource(x.resource, y.resource) - if x.target != y.target { + xTarget := x.target + yTarget := y.target + if runtime.GOOS == "windows" { + xTarget = strings.ToLower(xTarget) + yTarget = strings.ToLower(yTarget) + } + if xTarget != yTarget { p = append(p, notEqual("target", x.target, y.target)) } return p diff --git a/vendor/gotest.tools/golden/golden.go b/vendor/gotest.tools/golden/golden.go index 1804b65931..7264529900 100644 --- a/vendor/gotest.tools/golden/golden.go +++ b/vendor/gotest.tools/golden/golden.go @@ -98,7 +98,7 @@ func String(actual string, filename string) cmp.Comparison { // AssertBytes compares the actual result to the expected result in the golden // file. If the `-test.update-golden` flag is set then the actual content is // written to the golden file. -// Returns whether the assertion was successful (true) or not (false) +// Returns whether the assertion was successful (true) or not (false). // This is equivalent to assert.Check(t, Bytes(actual, filename)) func AssertBytes( t assert.TestingT, diff --git a/vendor/gotest.tools/icmd/command.go b/vendor/gotest.tools/icmd/command.go index 901895991a..e931ccb928 100644 --- a/vendor/gotest.tools/icmd/command.go +++ b/vendor/gotest.tools/icmd/command.go @@ -132,18 +132,21 @@ func (r *Result) String() string { if r.Timeout { timeout = " (timeout)" } + var errString string + if r.Error != nil { + errString = "\nError: " + r.Error.Error() + } return fmt.Sprintf(` Command: %s -ExitCode: %d%s -Error: %v +ExitCode: %d%s%s Stdout: %v Stderr: %v `, strings.Join(r.Cmd.Args, " "), r.ExitCode, timeout, - r.Error, + errString, r.Stdout(), r.Stderr()) } diff --git a/vendor/gotest.tools/icmd/ops.go b/vendor/gotest.tools/icmd/ops.go index 02b1d84023..18176eead3 100644 --- a/vendor/gotest.tools/icmd/ops.go +++ b/vendor/gotest.tools/icmd/ops.go @@ -1,4 +1,38 @@ package icmd +import ( + "io" + "time" +) + // CmdOp is an operation which modified a Cmd structure used to execute commands type CmdOp func(*Cmd) + +// WithTimeout sets the timeout duration of the command +func WithTimeout(timeout time.Duration) CmdOp { + return func(c *Cmd) { + c.Timeout = timeout + } +} + +// WithEnv sets the environment variable of the command. +// Each arguments are in the form of KEY=VALUE +func WithEnv(env ...string) CmdOp { + return func(c *Cmd) { + c.Env = env + } +} + +// Dir sets the working directory of the command +func Dir(path string) CmdOp { + return func(c *Cmd) { + c.Dir = path + } +} + +// WithStdin sets the standard input of the command to the specified reader +func WithStdin(r io.Reader) CmdOp { + return func(c *Cmd) { + c.Stdin = r + } +} diff --git a/vendor/gotest.tools/internal/difflib/difflib.go b/vendor/gotest.tools/internal/difflib/difflib.go index 5efa99c1d4..b6f486b9c9 100644 --- a/vendor/gotest.tools/internal/difflib/difflib.go +++ b/vendor/gotest.tools/internal/difflib/difflib.go @@ -1,4 +1,4 @@ -/* Package difflib is a partial port of Python difflib module. +/*Package difflib is a partial port of Python difflib module. Original source: https://github.com/pmezard/go-difflib @@ -20,12 +20,14 @@ func max(a, b int) int { return b } +// Match stores line numbers of size of match type Match struct { A int B int Size int } +// OpCode identifies the type of diff type OpCode struct { Tag byte I1 int @@ -73,19 +75,20 @@ type SequenceMatcher struct { opCodes []OpCode } +// NewMatcher returns a new SequenceMatcher func NewMatcher(a, b []string) *SequenceMatcher { m := SequenceMatcher{autoJunk: true} m.SetSeqs(a, b) return &m } -// Set two sequences to be compared. +// SetSeqs sets two sequences to be compared. func (m *SequenceMatcher) SetSeqs(a, b []string) { m.SetSeq1(a) m.SetSeq2(b) } -// Set the first sequence to be compared. The second sequence to be compared is +// SetSeq1 sets the first sequence to be compared. The second sequence to be compared is // not changed. // // SequenceMatcher computes and caches detailed information about the second @@ -103,7 +106,7 @@ func (m *SequenceMatcher) SetSeq1(a []string) { m.opCodes = nil } -// Set the second sequence to be compared. The first sequence to be compared is +// SetSeq2 sets the second sequence to be compared. The first sequence to be compared is // not changed. func (m *SequenceMatcher) SetSeq2(b []string) { if &b == &m.b { @@ -129,12 +132,12 @@ func (m *SequenceMatcher) chainB() { m.bJunk = map[string]struct{}{} if m.IsJunk != nil { junk := m.bJunk - for s, _ := range b2j { + for s := range b2j { if m.IsJunk(s) { junk[s] = struct{}{} } } - for s, _ := range junk { + for s := range junk { delete(b2j, s) } } @@ -149,7 +152,7 @@ func (m *SequenceMatcher) chainB() { popular[s] = struct{}{} } } - for s, _ := range popular { + for s := range popular { delete(b2j, s) } } @@ -259,7 +262,7 @@ func (m *SequenceMatcher) findLongestMatch(alo, ahi, blo, bhi int) Match { return Match{A: besti, B: bestj, Size: bestsize} } -// Return list of triples describing matching subsequences. +// GetMatchingBlocks returns a list of triples describing matching subsequences. // // Each triple is of the form (i, j, n), and means that // a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in @@ -323,7 +326,7 @@ func (m *SequenceMatcher) GetMatchingBlocks() []Match { return m.matchingBlocks } -// Return list of 5-tuples describing how to turn a into b. +// GetOpCodes returns a list of 5-tuples describing how to turn a into b. // // Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple // has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the @@ -374,7 +377,7 @@ func (m *SequenceMatcher) GetOpCodes() []OpCode { return m.opCodes } -// Isolate change clusters by eliminating ranges with no changes. +// GetGroupedOpCodes isolates change clusters by eliminating ranges with no changes. // // Return a generator of groups with up to n lines of context. // Each group is in the same format as returned by GetOpCodes(). @@ -384,7 +387,7 @@ func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode { } codes := m.GetOpCodes() if len(codes) == 0 { - codes = []OpCode{OpCode{'e', 0, 1, 0, 1}} + codes = []OpCode{{'e', 0, 1, 0, 1}} } // Fixup leading and trailing groups if they show no changes. if codes[0].Tag == 'e' { diff --git a/vendor/gotest.tools/internal/source/defers.go b/vendor/gotest.tools/internal/source/defers.go new file mode 100644 index 0000000000..66cfafbb64 --- /dev/null +++ b/vendor/gotest.tools/internal/source/defers.go @@ -0,0 +1,53 @@ +package source + +import ( + "go/ast" + "go/token" + + "github.com/pkg/errors" +) + +func scanToDeferLine(fileset *token.FileSet, node ast.Node, lineNum int) ast.Node { + var matchedNode ast.Node + ast.Inspect(node, func(node ast.Node) bool { + switch { + case node == nil || matchedNode != nil: + return false + case fileset.Position(node.End()).Line == lineNum: + if funcLit, ok := node.(*ast.FuncLit); ok { + matchedNode = funcLit + return false + } + } + return true + }) + debug("defer line node: %s", debugFormatNode{matchedNode}) + return matchedNode +} + +func guessDefer(node ast.Node) (ast.Node, error) { + defers := collectDefers(node) + switch len(defers) { + case 0: + return nil, errors.New("failed to expression in defer") + case 1: + return defers[0].Call, nil + default: + return nil, errors.Errorf( + "ambiguous call expression: multiple (%d) defers in call block", + len(defers)) + } +} + +func collectDefers(node ast.Node) []*ast.DeferStmt { + var defers []*ast.DeferStmt + ast.Inspect(node, func(node ast.Node) bool { + if d, ok := node.(*ast.DeferStmt); ok { + defers = append(defers, d) + debug("defer: %s", debugFormatNode{d}) + return false + } + return true + }) + return defers +} diff --git a/vendor/gotest.tools/internal/source/source.go b/vendor/gotest.tools/internal/source/source.go index a05933cc33..8a5d0e8d35 100644 --- a/vendor/gotest.tools/internal/source/source.go +++ b/vendor/gotest.tools/internal/source/source.go @@ -24,106 +24,12 @@ func FormattedCallExprArg(stackIndex int, argPos int) (string, error) { if err != nil { return "", err } + if argPos >= len(args) { + return "", errors.New("failed to find expression") + } return FormatNode(args[argPos]) } -func getNodeAtLine(filename string, lineNum int) (ast.Node, error) { - fileset := token.NewFileSet() - astFile, err := parser.ParseFile(fileset, filename, nil, parser.AllErrors) - if err != nil { - return nil, errors.Wrapf(err, "failed to parse source file: %s", filename) - } - - node := scanToLine(fileset, astFile, lineNum) - if node == nil { - return nil, errors.Errorf( - "failed to find an expression on line %d in %s", lineNum, filename) - } - return node, nil -} - -func scanToLine(fileset *token.FileSet, node ast.Node, lineNum int) ast.Node { - v := &scanToLineVisitor{lineNum: lineNum, fileset: fileset} - ast.Walk(v, node) - return v.matchedNode -} - -type scanToLineVisitor struct { - lineNum int - matchedNode ast.Node - fileset *token.FileSet -} - -func (v *scanToLineVisitor) Visit(node ast.Node) ast.Visitor { - if node == nil || v.matchedNode != nil { - return nil - } - if v.nodePosition(node).Line == v.lineNum { - v.matchedNode = node - return nil - } - return v -} - -// In golang 1.9 the line number changed from being the line where the statement -// ended to the line where the statement began. -func (v *scanToLineVisitor) nodePosition(node ast.Node) token.Position { - if goVersionBefore19 { - return v.fileset.Position(node.End()) - } - return v.fileset.Position(node.Pos()) -} - -var goVersionBefore19 = isGOVersionBefore19() - -func isGOVersionBefore19() bool { - version := runtime.Version() - // not a release version - if !strings.HasPrefix(version, "go") { - return false - } - version = strings.TrimPrefix(version, "go") - parts := strings.Split(version, ".") - if len(parts) < 2 { - return false - } - minor, err := strconv.ParseInt(parts[1], 10, 32) - return err == nil && parts[0] == "1" && minor < 9 -} - -func getCallExprArgs(node ast.Node) ([]ast.Expr, error) { - visitor := &callExprVisitor{} - ast.Walk(visitor, node) - if visitor.expr == nil { - return nil, errors.New("failed to find call expression") - } - return visitor.expr.Args, nil -} - -type callExprVisitor struct { - expr *ast.CallExpr -} - -func (v *callExprVisitor) Visit(node ast.Node) ast.Visitor { - if v.expr != nil || node == nil { - return nil - } - debug("visit (%T): %s", node, debugFormatNode{node}) - - if callExpr, ok := node.(*ast.CallExpr); ok { - v.expr = callExpr - return nil - } - return v -} - -// FormatNode using go/format.Node and return the result as a string -func FormatNode(node ast.Node) (string, error) { - buf := new(bytes.Buffer) - err := format.Node(buf, token.NewFileSet(), node) - return buf.String(), err -} - // CallExprArgs returns the ast.Expr slice for the args of an ast.CallExpr at // the index in the call stack. func CallExprArgs(stackIndex int) ([]ast.Expr, error) { @@ -137,12 +43,109 @@ func CallExprArgs(stackIndex int) ([]ast.Expr, error) { if err != nil { return nil, err } - debug("found node (%T): %s", node, debugFormatNode{node}) + debug("found node: %s", debugFormatNode{node}) return getCallExprArgs(node) } -var debugEnabled = os.Getenv("GOTESTYOURSELF_DEBUG") != "" +func getNodeAtLine(filename string, lineNum int) (ast.Node, error) { + fileset := token.NewFileSet() + astFile, err := parser.ParseFile(fileset, filename, nil, parser.AllErrors) + if err != nil { + return nil, errors.Wrapf(err, "failed to parse source file: %s", filename) + } + + if node := scanToLine(fileset, astFile, lineNum); node != nil { + return node, nil + } + if node := scanToDeferLine(fileset, astFile, lineNum); node != nil { + node, err := guessDefer(node) + if err != nil || node != nil { + return node, err + } + } + return nil, errors.Errorf( + "failed to find an expression on line %d in %s", lineNum, filename) +} + +func scanToLine(fileset *token.FileSet, node ast.Node, lineNum int) ast.Node { + var matchedNode ast.Node + ast.Inspect(node, func(node ast.Node) bool { + switch { + case node == nil || matchedNode != nil: + return false + case nodePosition(fileset, node).Line == lineNum: + matchedNode = node + return false + } + return true + }) + return matchedNode +} + +// In golang 1.9 the line number changed from being the line where the statement +// ended to the line where the statement began. +func nodePosition(fileset *token.FileSet, node ast.Node) token.Position { + if goVersionBefore19 { + return fileset.Position(node.End()) + } + return fileset.Position(node.Pos()) +} + +var goVersionBefore19 = func() bool { + version := runtime.Version() + // not a release version + if !strings.HasPrefix(version, "go") { + return false + } + version = strings.TrimPrefix(version, "go") + parts := strings.Split(version, ".") + if len(parts) < 2 { + return false + } + minor, err := strconv.ParseInt(parts[1], 10, 32) + return err == nil && parts[0] == "1" && minor < 9 +}() + +func getCallExprArgs(node ast.Node) ([]ast.Expr, error) { + visitor := &callExprVisitor{} + ast.Walk(visitor, node) + if visitor.expr == nil { + return nil, errors.New("failed to find call expression") + } + debug("callExpr: %s", debugFormatNode{visitor.expr}) + return visitor.expr.Args, nil +} + +type callExprVisitor struct { + expr *ast.CallExpr +} + +func (v *callExprVisitor) Visit(node ast.Node) ast.Visitor { + if v.expr != nil || node == nil { + return nil + } + debug("visit: %s", debugFormatNode{node}) + + switch typed := node.(type) { + case *ast.CallExpr: + v.expr = typed + return nil + case *ast.DeferStmt: + ast.Walk(v, typed.Call.Fun) + return nil + } + return v +} + +// FormatNode using go/format.Node and return the result as a string +func FormatNode(node ast.Node) (string, error) { + buf := new(bytes.Buffer) + err := format.Node(buf, token.NewFileSet(), node) + return buf.String(), err +} + +var debugEnabled = os.Getenv("GOTESTTOOLS_DEBUG") != "" func debug(format string, args ...interface{}) { if debugEnabled { @@ -159,5 +162,5 @@ func (n debugFormatNode) String() string { if err != nil { return fmt.Sprintf("failed to format %s: %s", n.Node, err) } - return out + return fmt.Sprintf("(%T) %s", n.Node, out) } From 1764ffafca6986e2de93eb3b627757a3a11bdecf Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 20 Jun 2019 16:30:39 +0200 Subject: [PATCH 2/5] Reformat vendor.conf and pin all deps by git-sha To make it better readable, and to encourage pinning by sha, but "align" to a tagged release. similar to 6026ce4a8bf0f8ff4ec89c1165d57858a0088eb7 (#1822) Signed-off-by: Sebastiaan van Stijn --- vendor.conf | 197 ++++++++++++++++++++++++++-------------------------- 1 file changed, 97 insertions(+), 100 deletions(-) diff --git a/vendor.conf b/vendor.conf index 98f107955a..4a3693536d 100755 --- a/vendor.conf +++ b/vendor.conf @@ -1,100 +1,97 @@ -github.com/agl/ed25519 5312a61534124124185d41f09206b9fef1d88403 -github.com/asaskevich/govalidator f9ffefc3facfbe0caee3fea233cbb6e8208f4541 -github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109 -github.com/beorn7/perks 3a771d992973f24aa725d07868b467d1ddfceafb -github.com/containerd/console c12b1e7919c14469339a5d38f2f8ed9b64a9de23 -github.com/containerd/containerd bb0f83ab6eec47c3316bb763d5c20a82c7750c31 -github.com/containerd/continuity d8fb8589b0e8e85b8c8bbaa8840226d0dfeb7371 -github.com/containerd/fifo 3d5202a -github.com/containerd/typeurl f694355 -github.com/coreos/etcd v3.3.9 -github.com/cpuguy83/go-md2man v1.0.8 -github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76 # v1.1.0 -github.com/dgrijalva/jwt-go a2c85815a77d0f951e33ba4db5ae93629a1530af -github.com/docker/distribution 83389a148052d74ac602f5f1d62f86ff2f3c4aa5 -github.com/docker/docker 200b524eff60a9c95a22bc2518042ac2ff617d07 https://github.com/docker/engine # 18.09 branch -github.com/docker/docker-credential-helpers 5241b46610f2491efdf9d1c85f1ddf5b02f6d962 -# the docker/go package contains a customized version of canonical/json -# and is used by Notary. The package is periodically rebased on current Go versions. -github.com/docker/go d30aec9fd63c35133f8f79c3412ad91a3b08be06 -github.com/docker/go-connections 7395e3f8aa162843a74ed6d48e79627d9792ac55 # v0.4.0 -github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 -github.com/docker/go-metrics d466d4f6fd960e01820085bd7e1a24426ee7ef18 -github.com/docker/go-units 47565b4f722fb6ceae66b95f853feed578a4a51c # v0.3.3 -github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a -github.com/docker/licensing 9781369abdb5281cdc07a2a446c6df01347ec793 -github.com/docker/swarmkit cfa742c8abe6f8e922f6e4e920153c408e7d9c3b -github.com/flynn-archive/go-shlex 3f9db97f856818214da2e1057f8ad84803971cff -github.com/ghodss/yaml 0ca9ea5df5451ffdf184b4428c902747c2c11cd7 # v1.0.0 -github.com/gogo/googleapis b23578765ee54ff6bceff57f397d833bf4ca6869 -github.com/gogo/protobuf v1.1.1 -github.com/golang/glog 23def4e6c14b4da8ac2ed8007337bc5eb5007998 -github.com/golang/protobuf v1.1.0 -github.com/google/btree e89373fe6b4a7413d7acd6da1725b83ef713e6e4 -github.com/google/go-cmp v0.2.0 -github.com/google/gofuzz 24818f796faf91cd76ec7bddd72458fbced7a6c1 -github.com/google/shlex 6f45313302b9c56850fc17f99e40caebce98c716 -github.com/google/uuid v1.1.1 -github.com/googleapis/gnostic 7c663266750e7d82587642f65e60bc4083f1f84e # v0.2.0 -github.com/gorilla/context v1.1.1 -github.com/gorilla/mux v1.6.2 -github.com/gregjones/httpcache 9cad4c3443a7200dd6400aef47183728de563a38 -github.com/grpc-ecosystem/grpc-gateway 1a03ca3bad1e1ebadaedd3abb76bc58d4ac8143b -github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746 -github.com/hashicorp/golang-lru 0fb14efe8c47ae851c0034ed7a448854d3d34cf3 -github.com/hashicorp/go-version 23480c0 -github.com/imdario/mergo v0.3.6 -github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 # v1.0 -github.com/json-iterator/go ab8a2e0c74be9d3be70b3184d9acc634935ded82 # 1.1.4 -github.com/mattn/go-shellwords v1.0.3 -github.com/matttproud/golang_protobuf_extensions v1.0.1 -github.com/Microsoft/hcsshim 44c060121b68e8bdc40b411beba551f3b4ee9e55 -github.com/Microsoft/go-winio v0.4.10 -github.com/miekg/pkcs11 6120d95c0e9576ccf4a78ba40855809dca31a9ed -github.com/mitchellh/mapstructure f15292f7a699fcc1a38a80977f80a046874ba8ac -github.com/moby/buildkit 05766c5c21a1e528eeb1c3522b2f05493fe9ac47 -github.com/modern-go/concurrent bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94 # 1.0.3 -github.com/modern-go/reflect2 4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd # 1.0.1 -github.com/morikuni/aec 39771216ff4c63d11f5e604076f9c45e8be1067b -github.com/Nvveen/Gotty a8b993ba6abdb0e0c12b0125c603323a71c7790c https://github.com/ijc25/Gotty -github.com/opencontainers/go-digest v1.0.0-rc1 -github.com/opencontainers/image-spec v1.0.1 -github.com/opencontainers/runc 20aff4f0488c6d4b8df4d85b4f63f1f704c11abd -github.com/opencontainers/runtime-spec v1.0.1 -github.com/opentracing/opentracing-go 1361b9cd60be79c4c3a7fa9841b3c132e40066a7 -github.com/peterbourgon/diskv 5f041e8faa004a95c88a202771f4cc3e991971e6 # v2.0.1 -github.com/pkg/errors 839d9e913e063e28dfd0e6c7b7512793e0a48be9 -github.com/prometheus/client_golang 52437c81da6b127a9925d17eb3a382a2e5fd395e -github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6 -github.com/prometheus/common ebdfc6da46522d58825777cf1f90490a5b1ef1d8 -github.com/prometheus/procfs abf152e5f3e97f2fafac028d2cc06c1feb87ffa5 -github.com/russross/blackfriday 1d6b8e9301e720b08a8938b8c25c018285885438 -github.com/shurcooL/sanitized_anchor_name 10ef21a441db47d8b13ebcc5fd2310f636973c77 -github.com/sirupsen/logrus v1.0.6 -github.com/spf13/cobra v0.0.3 -# temporary fork with https://github.com/spf13/pflag/pull/170 applied, which isn't merged yet upstream -github.com/spf13/pflag 4cb166e4f25ac4e8016a3595bbf7ea2e9aa85a2c https://github.com/thaJeztah/pflag.git -github.com/syndtr/gocapability 2c00daeb6c3b45114c80ac44119e7b8801fdd852 -github.com/theupdateframework/notary v0.6.1 -github.com/tonistiigi/fsutil 2862f6bc5ac9b97124e552a5c108230b38a1b0ca -github.com/tonistiigi/units 6950e57a87eaf136bbe44ef2ec8e75b9e3569de2 -github.com/xeipuuv/gojsonpointer 4e3ac2762d5f479393488629ee9370b50873b3a6 -github.com/xeipuuv/gojsonreference bd5ef7bd5415a7ac448318e64f11a24cd21e594b -github.com/xeipuuv/gojsonschema 93e72a773fade158921402d6a24c819b48aba29d -golang.org/x/crypto 0709b304e793a5edb4a2c0145f281ecdc20838a4 -golang.org/x/net a680a1efc54dd51c040b3b5ce4939ea3cf2ea0d1 -golang.org/x/sync 1d60e4601c6fd243af51cc01ddf169918a5407ca -golang.org/x/sys 1b2967e3c290b7c545b3db0deeda16e9be4f98a2 -golang.org/x/text f21a4dfb5e38f5895301dc265a8def02365cc3d0 # v0.3.0 -golang.org/x/time fbb02b2291d28baffd63558aa44b4b56f178d650 -google.golang.org/genproto 02b4e95473316948020af0b7a4f0f22c73929b0e -google.golang.org/grpc v1.12.0 -gopkg.in/inf.v0 d2d2541c53f18d2a059457998ce2876cc8e67cbf # v0.9.1 -gopkg.in/yaml.v2 5420a8b6744d3b0345ab293f6fcba19c978f1183 # v2.2.1 -gotest.tools v2.2.0 -k8s.io/api kubernetes-1.11.2 -k8s.io/apimachinery kubernetes-1.11.2 -k8s.io/client-go kubernetes-1.11.2 -k8s.io/kube-openapi d8ea2fe547a448256204cfc68dfee7b26c720acb -k8s.io/kubernetes v1.11.2 -vbom.ml/util 256737ac55c46798123f754ab7d2c784e2c71783 +github.com/agl/ed25519 5312a61534124124185d41f09206b9fef1d88403 +github.com/asaskevich/govalidator f9ffefc3facfbe0caee3fea233cbb6e8208f4541 +github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109 +github.com/beorn7/perks 3a771d992973f24aa725d07868b467d1ddfceafb +github.com/containerd/console c12b1e7919c14469339a5d38f2f8ed9b64a9de23 +github.com/containerd/containerd bb0f83ab6eec47c3316bb763d5c20a82c7750c31 +github.com/containerd/continuity d8fb8589b0e8e85b8c8bbaa8840226d0dfeb7371 +github.com/containerd/fifo 3d5202aec260678c48179c56f40e6f38a095738c +github.com/containerd/typeurl f6943554a7e7e88b3c14aad190bf05932da84788 +github.com/coreos/etcd fca8add78a9d926166eb739b8e4a124434025ba3 # v3.3.9 +github.com/cpuguy83/go-md2man 20f5889cbdc3c73dbd2862796665e7c465ade7d1 # v1.0.8 +github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76 # v1.1.0 +github.com/dgrijalva/jwt-go a2c85815a77d0f951e33ba4db5ae93629a1530af +github.com/docker/distribution 83389a148052d74ac602f5f1d62f86ff2f3c4aa5 +github.com/docker/docker 200b524eff60a9c95a22bc2518042ac2ff617d07 https://github.com/docker/engine # 18.09 branch +github.com/docker/docker-credential-helpers 5241b46610f2491efdf9d1c85f1ddf5b02f6d962 +github.com/docker/go d30aec9fd63c35133f8f79c3412ad91a3b08be06 # Contains a customized version of canonical/json and is used by Notary. The package is periodically rebased on current Go versions. +github.com/docker/go-connections 7395e3f8aa162843a74ed6d48e79627d9792ac55 # v0.4.0 +github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 +github.com/docker/go-metrics d466d4f6fd960e01820085bd7e1a24426ee7ef18 +github.com/docker/go-units 47565b4f722fb6ceae66b95f853feed578a4a51c # v0.3.3 +github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a +github.com/docker/licensing 9781369abdb5281cdc07a2a446c6df01347ec793 +github.com/docker/swarmkit cfa742c8abe6f8e922f6e4e920153c408e7d9c3b +github.com/flynn-archive/go-shlex 3f9db97f856818214da2e1057f8ad84803971cff +github.com/ghodss/yaml 0ca9ea5df5451ffdf184b4428c902747c2c11cd7 # v1.0.0 +github.com/gogo/googleapis b23578765ee54ff6bceff57f397d833bf4ca6869 +github.com/gogo/protobuf 636bf0302bc95575d69441b25a2603156ffdddf1 # v1.1.1 +github.com/golang/glog 23def4e6c14b4da8ac2ed8007337bc5eb5007998 +github.com/golang/protobuf b4deda0973fb4c70b50d226b1af49f3da59f5265 # v1.1.0 +github.com/google/btree e89373fe6b4a7413d7acd6da1725b83ef713e6e4 +github.com/google/go-cmp 3af367b6b30c263d47e8895973edcca9a49cf029 # v0.2.0 +github.com/google/gofuzz 24818f796faf91cd76ec7bddd72458fbced7a6c1 +github.com/google/shlex 6f45313302b9c56850fc17f99e40caebce98c716 +github.com/google/uuid 0cd6bf5da1e1c83f8b45653022c74f71af0538a4 # v1.1.1 +github.com/googleapis/gnostic 7c663266750e7d82587642f65e60bc4083f1f84e # v0.2.0 +github.com/gorilla/context 08b5f424b9271eedf6f9f0ce86cb9396ed337a42 # v1.1.1 +github.com/gorilla/mux e3702bed27f0d39777b0b37b664b6280e8ef8fbf # v1.6.2 +github.com/gregjones/httpcache 9cad4c3443a7200dd6400aef47183728de563a38 +github.com/grpc-ecosystem/grpc-gateway 1a03ca3bad1e1ebadaedd3abb76bc58d4ac8143b +github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746 +github.com/hashicorp/golang-lru 0fb14efe8c47ae851c0034ed7a448854d3d34cf3 +github.com/hashicorp/go-version 23480c0665776210b5fbbac6eaaee40e3e6a96b7 +github.com/imdario/mergo 9f23e2d6bd2a77f959b2bf6acdbefd708a83a4a4 # v0.3.6 +github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 # v1.0.0 +github.com/json-iterator/go ab8a2e0c74be9d3be70b3184d9acc634935ded82 # 1.1.4 +github.com/mattn/go-shellwords 02e3cf038dcea8290e44424da473dd12be796a8a # v1.0.3 +github.com/matttproud/golang_protobuf_extensions c12348ce28de40eed0136aa2b644d0ee0650e56c # v1.0.1 +github.com/Microsoft/hcsshim 44c060121b68e8bdc40b411beba551f3b4ee9e55 +github.com/Microsoft/go-winio 78a084671df137c2acfcacaa730d7e7dc285ac39 # v0.4.10 +github.com/miekg/pkcs11 6120d95c0e9576ccf4a78ba40855809dca31a9ed +github.com/mitchellh/mapstructure f15292f7a699fcc1a38a80977f80a046874ba8ac +github.com/moby/buildkit 05766c5c21a1e528eeb1c3522b2f05493fe9ac47 +github.com/modern-go/concurrent bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94 # 1.0.3 +github.com/modern-go/reflect2 4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd # 1.0.1 +github.com/morikuni/aec 39771216ff4c63d11f5e604076f9c45e8be1067b +github.com/Nvveen/Gotty a8b993ba6abdb0e0c12b0125c603323a71c7790c https://github.com/ijc25/Gotty +github.com/opencontainers/go-digest 279bed98673dd5bef374d3b6e4b09e2af76183bf # v1.0.0-rc1 +github.com/opencontainers/image-spec d60099175f88c47cd379c4738d158884749ed235 # v1.0.1 +github.com/opencontainers/runc 20aff4f0488c6d4b8df4d85b4f63f1f704c11abd +github.com/opencontainers/runtime-spec 4e3b9264a330d094b0386c3703c5f379119711e8 # v1.0.1 +github.com/opentracing/opentracing-go 1361b9cd60be79c4c3a7fa9841b3c132e40066a7 +github.com/peterbourgon/diskv 5f041e8faa004a95c88a202771f4cc3e991971e6 # v2.0.1 +github.com/pkg/errors 839d9e913e063e28dfd0e6c7b7512793e0a48be9 +github.com/prometheus/client_golang 52437c81da6b127a9925d17eb3a382a2e5fd395e +github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6 +github.com/prometheus/common ebdfc6da46522d58825777cf1f90490a5b1ef1d8 +github.com/prometheus/procfs abf152e5f3e97f2fafac028d2cc06c1feb87ffa5 +github.com/russross/blackfriday 1d6b8e9301e720b08a8938b8c25c018285885438 +github.com/shurcooL/sanitized_anchor_name 10ef21a441db47d8b13ebcc5fd2310f636973c77 +github.com/sirupsen/logrus 3e01752db0189b9157070a0e1668a620f9a85da2 # v1.0.6 +github.com/spf13/cobra ef82de70bb3f60c65fb8eebacbb2d122ef517385 # v0.0.3 +github.com/spf13/pflag 4cb166e4f25ac4e8016a3595bbf7ea2e9aa85a2c https://github.com/thaJeztah/pflag.git # temporary fork with https://github.com/spf13/pflag/pull/170 applied, which isn't merged yet upstream +github.com/syndtr/gocapability 2c00daeb6c3b45114c80ac44119e7b8801fdd852 +github.com/theupdateframework/notary d6e1431feb32348e0650bf7551ac5cffd01d857b # v0.6.1 +github.com/tonistiigi/fsutil 2862f6bc5ac9b97124e552a5c108230b38a1b0ca +github.com/tonistiigi/units 6950e57a87eaf136bbe44ef2ec8e75b9e3569de2 +github.com/xeipuuv/gojsonpointer 4e3ac2762d5f479393488629ee9370b50873b3a6 +github.com/xeipuuv/gojsonreference bd5ef7bd5415a7ac448318e64f11a24cd21e594b +github.com/xeipuuv/gojsonschema 93e72a773fade158921402d6a24c819b48aba29d +golang.org/x/crypto 0709b304e793a5edb4a2c0145f281ecdc20838a4 +golang.org/x/net a680a1efc54dd51c040b3b5ce4939ea3cf2ea0d1 +golang.org/x/sync 1d60e4601c6fd243af51cc01ddf169918a5407ca +golang.org/x/sys 1b2967e3c290b7c545b3db0deeda16e9be4f98a2 +golang.org/x/text f21a4dfb5e38f5895301dc265a8def02365cc3d0 # v0.3.0 +golang.org/x/time fbb02b2291d28baffd63558aa44b4b56f178d650 +google.golang.org/genproto 02b4e95473316948020af0b7a4f0f22c73929b0e +google.golang.org/grpc 41344da2231b913fa3d983840a57a6b1b7b631a1 # v1.12.0 +gopkg.in/inf.v0 d2d2541c53f18d2a059457998ce2876cc8e67cbf # v0.9.1 +gopkg.in/yaml.v2 5420a8b6744d3b0345ab293f6fcba19c978f1183 # v2.2.1 +gotest.tools 7c797b5133e5460410dbb22ba779bf35e6975dea # v2.2.0 +k8s.io/api 2d6f90ab1293a1fb871cf149423ebb72aa7423aa # kubernetes-1.11.2 +k8s.io/apimachinery 103fd098999dc9c0c88536f5c9ad2e5da39373ae # kubernetes-1.11.2 +k8s.io/client-go 1f13a808da65775f22cbf47862c4e5898d8f4ca1 # kubernetes-1.11.2 +k8s.io/kube-openapi d8ea2fe547a448256204cfc68dfee7b26c720acb +k8s.io/kubernetes bb9ffb1654d4a729bb4cec18ff088eacc153c239 # v1.11.2 +vbom.ml/util 256737ac55c46798123f754ab7d2c784e2c71783 From 773a91f9e95b669e1e48b4d19ff5369c7f0dad2c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 20 Jun 2019 16:44:18 +0200 Subject: [PATCH 3/5] Sort vendor.conf alphabetically Signed-off-by: Sebastiaan van Stijn --- vendor.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor.conf b/vendor.conf index 4a3693536d..5e9cdeffdc 100755 --- a/vendor.conf +++ b/vendor.conf @@ -39,15 +39,15 @@ github.com/gorilla/mux e3702bed27f0d39777b0b37b664b github.com/gregjones/httpcache 9cad4c3443a7200dd6400aef47183728de563a38 github.com/grpc-ecosystem/grpc-gateway 1a03ca3bad1e1ebadaedd3abb76bc58d4ac8143b github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746 -github.com/hashicorp/golang-lru 0fb14efe8c47ae851c0034ed7a448854d3d34cf3 github.com/hashicorp/go-version 23480c0665776210b5fbbac6eaaee40e3e6a96b7 +github.com/hashicorp/golang-lru 0fb14efe8c47ae851c0034ed7a448854d3d34cf3 github.com/imdario/mergo 9f23e2d6bd2a77f959b2bf6acdbefd708a83a4a4 # v0.3.6 github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 # v1.0.0 github.com/json-iterator/go ab8a2e0c74be9d3be70b3184d9acc634935ded82 # 1.1.4 github.com/mattn/go-shellwords 02e3cf038dcea8290e44424da473dd12be796a8a # v1.0.3 github.com/matttproud/golang_protobuf_extensions c12348ce28de40eed0136aa2b644d0ee0650e56c # v1.0.1 -github.com/Microsoft/hcsshim 44c060121b68e8bdc40b411beba551f3b4ee9e55 github.com/Microsoft/go-winio 78a084671df137c2acfcacaa730d7e7dc285ac39 # v0.4.10 +github.com/Microsoft/hcsshim 44c060121b68e8bdc40b411beba551f3b4ee9e55 github.com/miekg/pkcs11 6120d95c0e9576ccf4a78ba40855809dca31a9ed github.com/mitchellh/mapstructure f15292f7a699fcc1a38a80977f80a046874ba8ac github.com/moby/buildkit 05766c5c21a1e528eeb1c3522b2f05493fe9ac47 From 32c4d8c40fae3cd229eaf6ed08139c45d0692625 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 13 Apr 2019 01:47:37 +0200 Subject: [PATCH 4/5] bump gotest.tools v2.3.0 Signed-off-by: Sebastiaan van Stijn (cherry picked from commit c8d685457b3adf36fe52147b9a5629b32fe7637d) Signed-off-by: Sebastiaan van Stijn --- vendor.conf | 2 +- vendor/gotest.tools/README.md | 4 ++ vendor/gotest.tools/assert/cmp/result.go | 20 +++++--- vendor/gotest.tools/fs/file.go | 10 +--- vendor/gotest.tools/fs/manifest.go | 9 ++-- vendor/gotest.tools/fs/ops.go | 9 ++++ vendor/gotest.tools/fs/path.go | 43 +++++++++++++++- vendor/gotest.tools/fs/report.go | 62 +++++++++++++++++++++--- vendor/gotest.tools/poll/check.go | 39 +++++++++++++++ vendor/gotest.tools/poll/poll.go | 2 +- vendor/gotest.tools/skip/skip.go | 28 +++++++++-- 11 files changed, 193 insertions(+), 35 deletions(-) create mode 100644 vendor/gotest.tools/poll/check.go diff --git a/vendor.conf b/vendor.conf index 5e9cdeffdc..6158134b41 100755 --- a/vendor.conf +++ b/vendor.conf @@ -88,7 +88,7 @@ google.golang.org/genproto 02b4e95473316948020af0b7a4f0 google.golang.org/grpc 41344da2231b913fa3d983840a57a6b1b7b631a1 # v1.12.0 gopkg.in/inf.v0 d2d2541c53f18d2a059457998ce2876cc8e67cbf # v0.9.1 gopkg.in/yaml.v2 5420a8b6744d3b0345ab293f6fcba19c978f1183 # v2.2.1 -gotest.tools 7c797b5133e5460410dbb22ba779bf35e6975dea # v2.2.0 +gotest.tools 1083505acf35a0bd8a696b26837e1fb3187a7a83 # v2.3.0 k8s.io/api 2d6f90ab1293a1fb871cf149423ebb72aa7423aa # kubernetes-1.11.2 k8s.io/apimachinery 103fd098999dc9c0c88536f5c9ad2e5da39373ae # kubernetes-1.11.2 k8s.io/client-go 1f13a808da65775f22cbf47862c4e5898d8f4ca1 # kubernetes-1.11.2 diff --git a/vendor/gotest.tools/README.md b/vendor/gotest.tools/README.md index 26a2026de2..3155723dd7 100644 --- a/vendor/gotest.tools/README.md +++ b/vendor/gotest.tools/README.md @@ -29,3 +29,7 @@ A collection of packages to augment `testing` and support common patterns. * [gotest.tools/gotestsum](https://github.com/gotestyourself/gotestsum) - go test runner with custom output * [maxbrunsfeld/counterfeiter](https://github.com/maxbrunsfeld/counterfeiter) - generate fakes for interfaces * [jonboulle/clockwork](https://github.com/jonboulle/clockwork) - a fake clock for testing code that uses `time` + +## Contributing + +See [CONTRIBUTING.md](CONTRIBUTING.md). diff --git a/vendor/gotest.tools/assert/cmp/result.go b/vendor/gotest.tools/assert/cmp/result.go index 7c3c37dd72..204edda4bc 100644 --- a/vendor/gotest.tools/assert/cmp/result.go +++ b/vendor/gotest.tools/assert/cmp/result.go @@ -9,31 +9,37 @@ import ( "gotest.tools/internal/source" ) -// Result of a Comparison. +// A Result of a Comparison. type Result interface { Success() bool } -type result struct { +// StringResult is an implementation of Result that reports the error message +// string verbatim and does not provide any templating or formatting of the +// message. +type StringResult struct { success bool message string } -func (r result) Success() bool { +// Success returns true if the comparison was successful. +func (r StringResult) Success() bool { return r.success } -func (r result) FailureMessage() string { +// FailureMessage returns the message used to provide additional information +// about the failure. +func (r StringResult) FailureMessage() string { return r.message } // ResultSuccess is a constant which is returned by a ComparisonWithResult to // indicate success. -var ResultSuccess = result{success: true} +var ResultSuccess = StringResult{success: true} // ResultFailure returns a failed Result with a failure message. -func ResultFailure(message string) Result { - return result{message: message} +func ResultFailure(message string) StringResult { + return StringResult{message: message} } // ResultFromError returns ResultSuccess if err is nil. Otherwise ResultFailure diff --git a/vendor/gotest.tools/fs/file.go b/vendor/gotest.tools/fs/file.go index 8322c8f444..7d0cab363b 100644 --- a/vendor/gotest.tools/fs/file.go +++ b/vendor/gotest.tools/fs/file.go @@ -46,10 +46,7 @@ func NewFile(t assert.TestingT, prefix string, ops ...PathOp) *File { assert.NilError(t, err) file := &File{path: tempfile.Name()} assert.NilError(t, tempfile.Close()) - - for _, op := range ops { - assert.NilError(t, op(file)) - } + assert.NilError(t, applyPathOps(file, ops)) if tc, ok := t.(subtest.TestContext); ok { tc.AddCleanup(file.Remove) } @@ -89,10 +86,7 @@ func NewDir(t assert.TestingT, prefix string, ops ...PathOp) *Dir { path, err := ioutil.TempDir("", cleanPrefix(prefix)+"-") assert.NilError(t, err) dir := &Dir{path: path} - - for _, op := range ops { - assert.NilError(t, op(dir)) - } + assert.NilError(t, applyPathOps(dir, ops)) if tc, ok := t.(subtest.TestContext); ok { tc.AddCleanup(dir.Remove) } diff --git a/vendor/gotest.tools/fs/manifest.go b/vendor/gotest.tools/fs/manifest.go index a98a70aaf4..e5e693e6c5 100644 --- a/vendor/gotest.tools/fs/manifest.go +++ b/vendor/gotest.tools/fs/manifest.go @@ -26,6 +26,7 @@ type file struct { resource content io.ReadCloser ignoreCariageReturn bool + compareContentFunc func(b []byte) CompareResult } func (f *file) Type() string { @@ -43,7 +44,8 @@ func (f *symlink) Type() string { type directory struct { resource - items map[string]dirEntry + items map[string]dirEntry + filepathGlobs map[string]*filePath } func (f *directory) Type() string { @@ -95,8 +97,9 @@ func newDirectory(path string, info os.FileInfo) (*directory, error) { } return &directory{ - resource: newResourceFromInfo(info), - items: items, + resource: newResourceFromInfo(info), + items: items, + filepathGlobs: make(map[string]*filePath), }, nil } diff --git a/vendor/gotest.tools/fs/ops.go b/vendor/gotest.tools/fs/ops.go index a8d087c832..c3c33587b6 100644 --- a/vendor/gotest.tools/fs/ops.go +++ b/vendor/gotest.tools/fs/ops.go @@ -10,6 +10,7 @@ import ( "time" "github.com/pkg/errors" + "gotest.tools/assert" ) const defaultFileMode = 0644 @@ -144,6 +145,14 @@ func WithDir(name string, ops ...PathOp) PathOp { } } +// Apply the PathOps to the File +func Apply(t assert.TestingT, path Path, ops ...PathOp) { + if ht, ok := t.(helperT); ok { + ht.Helper() + } + assert.NilError(t, applyPathOps(path, ops)) +} + func applyPathOps(path Path, ops []PathOp) error { for _, op := range ops { if err := op(path); err != nil { diff --git a/vendor/gotest.tools/fs/path.go b/vendor/gotest.tools/fs/path.go index 8ffa0a0f82..4bb38774bc 100644 --- a/vendor/gotest.tools/fs/path.go +++ b/vendor/gotest.tools/fs/path.go @@ -64,6 +64,13 @@ func (p *directoryPath) AddFile(path string, ops ...PathOp) error { return applyPathOps(exp, ops) } +func (p *directoryPath) AddGlobFiles(glob string, ops ...PathOp) error { + newFile := &file{resource: newResource(0)} + newFilePath := &filePath{file: newFile} + p.directory.filepathGlobs[glob] = newFilePath + return applyPathOps(newFilePath, ops) +} + func (p *directoryPath) AddDirectory(path string, ops ...PathOp) error { newDir := newDirectoryWithDefaults() p.directory.items[path] = newDir @@ -87,8 +94,9 @@ func Expected(t assert.TestingT, ops ...PathOp) Manifest { func newDirectoryWithDefaults() *directory { return &directory{ - resource: newResource(defaultRootDirMode), - items: make(map[string]dirEntry), + resource: newResource(defaultRootDirMode), + items: make(map[string]dirEntry), + filepathGlobs: make(map[string]*filePath), } } @@ -147,6 +155,37 @@ func MatchExtraFiles(path Path) error { return nil } +// CompareResult is the result of comparison. +// +// See gotest.tools/assert/cmp.StringResult for a convenient implementation of +// this interface. +type CompareResult interface { + Success() bool + FailureMessage() string +} + +// MatchFileContent is a PathOp that updates a Manifest to use the provided +// function to determine if a file's content matches the expectation. +func MatchFileContent(f func([]byte) CompareResult) PathOp { + return func(path Path) error { + if m, ok := path.(*filePath); ok { + m.file.compareContentFunc = f + } + return nil + } +} + +// MatchFilesWithGlob is a PathOp that updates a Manifest to match files using +// glob pattern, and check them using the ops. +func MatchFilesWithGlob(glob string, ops ...PathOp) PathOp { + return func(path Path) error { + if m, ok := path.(*directoryPath); ok { + m.AddGlobFiles(glob, ops...) + } + return nil + } +} + // anyFileMode is represented by uint32_max const anyFileMode os.FileMode = 4294967295 diff --git a/vendor/gotest.tools/fs/report.go b/vendor/gotest.tools/fs/report.go index b85bb09a75..adc5a5f1bc 100644 --- a/vendor/gotest.tools/fs/report.go +++ b/vendor/gotest.tools/fs/report.go @@ -101,6 +101,15 @@ func eqFile(x, y *file) []problem { if xErr != nil || yErr != nil { return p } + + if x.compareContentFunc != nil { + r := x.compareContentFunc(yContent) + if !r.Success() { + p = append(p, existenceProblem("content", r.FailureMessage())) + } + return p + } + if x.ignoreCariageReturn || y.ignoreCariageReturn { xContent = removeCarriageReturn(xContent) yContent = removeCarriageReturn(yContent) @@ -151,11 +160,13 @@ func eqSymlink(x, y *symlink) []problem { func eqDirectory(path string, x, y *directory) []failure { p := eqResource(x.resource, y.resource) var f []failure + matchedFiles := make(map[string]bool) for _, name := range sortedKeys(x.items) { if name == anyFile { continue } + matchedFiles[name] = true xEntry := x.items[name] yEntry, ok := y.items[name] if !ok { @@ -171,19 +182,30 @@ func eqDirectory(path string, x, y *directory) []failure { f = append(f, eqEntry(filepath.Join(path, name), xEntry, yEntry)...) } - if _, ok := x.items[anyFile]; !ok { + if len(x.filepathGlobs) != 0 { for _, name := range sortedKeys(y.items) { - if _, ok := x.items[name]; !ok { - yEntry := y.items[name] - p = append(p, existenceProblem(name, "unexpected %s", yEntry.Type())) - } + m := matchGlob(name, y.items[name], x.filepathGlobs) + matchedFiles[name] = m.match + f = append(f, m.failures...) } } - if len(p) > 0 { - f = append(f, failure{path: path, problems: p}) + if _, ok := x.items[anyFile]; ok { + return maybeAppendFailure(f, path, p) } - return f + for _, name := range sortedKeys(y.items) { + if !matchedFiles[name] { + p = append(p, existenceProblem(name, "unexpected %s", y.items[name].Type())) + } + } + return maybeAppendFailure(f, path, p) +} + +func maybeAppendFailure(failures []failure, path string, problems []problem) []failure { + if len(problems) > 0 { + return append(failures, failure{path: path, problems: problems}) + } + return failures } func sortedKeys(items map[string]dirEntry) []string { @@ -215,6 +237,30 @@ func eqEntry(path string, x, y dirEntry) []failure { return nil } +type globMatch struct { + match bool + failures []failure +} + +func matchGlob(name string, yEntry dirEntry, globs map[string]*filePath) globMatch { + m := globMatch{} + + for glob, expectedFile := range globs { + ok, err := filepath.Match(glob, name) + if err != nil { + p := errProblem("failed to match glob pattern", err) + f := failure{path: name, problems: []problem{p}} + m.failures = append(m.failures, f) + } + if ok { + m.match = true + m.failures = eqEntry(name, expectedFile.file, yEntry) + return m + } + } + return m +} + func formatFailures(failures []failure) string { sort.Slice(failures, func(i, j int) bool { return failures[i].path < failures[j].path diff --git a/vendor/gotest.tools/poll/check.go b/vendor/gotest.tools/poll/check.go new file mode 100644 index 0000000000..060b099890 --- /dev/null +++ b/vendor/gotest.tools/poll/check.go @@ -0,0 +1,39 @@ +package poll + +import ( + "net" + "os" +) + +// Check is a function which will be used as check for the WaitOn method. +type Check func(t LogT) Result + +// FileExists looks on filesystem and check that path exists. +func FileExists(path string) Check { + return func(t LogT) Result { + _, err := os.Stat(path) + if os.IsNotExist(err) { + t.Logf("waiting on file %s to exist", path) + return Continue("file %s does not exist", path) + } + if err != nil { + return Error(err) + } + + return Success() + } +} + +// Connection try to open a connection to the address on the +// named network. See net.Dial for a description of the network and +// address parameters. +func Connection(network, address string) Check { + return func(t LogT) Result { + _, err := net.Dial(network, address) + if err != nil { + t.Logf("waiting on socket %s://%s to be available...", network, address) + return Continue("socket %s://%s not available", network, address) + } + return Success() + } +} diff --git a/vendor/gotest.tools/poll/poll.go b/vendor/gotest.tools/poll/poll.go index 3e3dd7f58a..5e238dca42 100644 --- a/vendor/gotest.tools/poll/poll.go +++ b/vendor/gotest.tools/poll/poll.go @@ -104,7 +104,7 @@ func Error(err error) Result { // WaitOn a condition or until a timeout. Poll by calling check and exit when // check returns a done Result. To fail a test and exit polling with an error // return a error result. -func WaitOn(t TestingT, check func(t LogT) Result, pollOps ...SettingOp) { +func WaitOn(t TestingT, check Check, pollOps ...SettingOp) { if ht, ok := t.(helperT); ok { ht.Helper() } diff --git a/vendor/gotest.tools/skip/skip.go b/vendor/gotest.tools/skip/skip.go index 4bfc9a11c2..d27ca53c3d 100644 --- a/vendor/gotest.tools/skip/skip.go +++ b/vendor/gotest.tools/skip/skip.go @@ -19,17 +19,29 @@ type skipT interface { Log(args ...interface{}) } +// Result of skip function +type Result interface { + Skip() bool + Message() string +} + type helperT interface { Helper() } -// BoolOrCheckFunc can be a bool or func() bool, other types will panic +// BoolOrCheckFunc can be a bool, func() bool, or func() Result. Other types will panic type BoolOrCheckFunc interface{} -// If the condition expression evaluates to true, or the condition function returns -// true, skip the test. +// If the condition expression evaluates to true, skip the test. +// +// The condition argument may be one of three types: bool, func() bool, or +// func() SkipResult. +// When called with a bool, the test will be skip if the condition evaluates to true. +// When called with a func() bool, the test will be skip if the function returns true. +// When called with a func() Result, the test will be skip if the Skip method +// of the result returns true. // The skip message will contain the source code of the expression. -// Extra message text can be passed as a format string with args +// Extra message text can be passed as a format string with args. func If(t skipT, condition BoolOrCheckFunc, msgAndArgs ...interface{}) { if ht, ok := t.(helperT); ok { ht.Helper() @@ -41,12 +53,18 @@ func If(t skipT, condition BoolOrCheckFunc, msgAndArgs ...interface{}) { if check() { t.Skip(format.WithCustomMessage(getFunctionName(check), msgAndArgs...)) } + case func() Result: + result := check() + if result.Skip() { + msg := getFunctionName(check) + ": " + result.Message() + t.Skip(format.WithCustomMessage(msg, msgAndArgs...)) + } default: panic(fmt.Sprintf("invalid type for condition arg: %T", check)) } } -func getFunctionName(function func() bool) string { +func getFunctionName(function interface{}) string { funcPath := runtime.FuncForPC(reflect.ValueOf(function).Pointer()).Name() return strings.SplitN(path.Base(funcPath), ".", 2)[1] } From 7b3d0231637b730a95ff3a44e22673c8bd64bf9f Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 14 Apr 2019 16:21:12 +0200 Subject: [PATCH 5/5] vendor.conf: reserve space for downstream projects This helps merge conflicts in situations where downstream projects have additional dependencies. Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 8c5460a2cc92e47bc7d085f42d2b66dca0876b8b) Signed-off-by: Sebastiaan van Stijn --- vendor.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vendor.conf b/vendor.conf index 6158134b41..abec83309d 100755 --- a/vendor.conf +++ b/vendor.conf @@ -95,3 +95,5 @@ k8s.io/client-go 1f13a808da65775f22cbf47862c4 k8s.io/kube-openapi d8ea2fe547a448256204cfc68dfee7b26c720acb k8s.io/kubernetes bb9ffb1654d4a729bb4cec18ff088eacc153c239 # v1.11.2 vbom.ml/util 256737ac55c46798123f754ab7d2c784e2c71783 + +# DO NOT EDIT BELOW THIS LINE -------- reserved for downstream projects --------