From 4f8edd559132914b0d97084233b1b458758a3b28 Mon Sep 17 00:00:00 2001 From: Amshuman K R Date: Tue, 13 Jul 2021 14:20:33 +0530 Subject: [PATCH] Cleanup vendoring --- .../gardener/pkg/utils/test/matchers/deep.go | 81 ----------- .../pkg/utils/test/matchers/fields.go | 38 ------ .../utils/test/matchers/kubernetes_errors.go | 47 ------- .../pkg/utils/test/matchers/matchers.go | 126 ----------------- .../onsi/ginkgo/extensions/table/table.go | 110 --------------- .../ginkgo/extensions/table/table_entry.go | 129 ------------------ vendor/modules.txt | 2 - 7 files changed, 533 deletions(-) delete mode 100644 vendor/github.com/gardener/gardener/pkg/utils/test/matchers/deep.go delete mode 100644 vendor/github.com/gardener/gardener/pkg/utils/test/matchers/fields.go delete mode 100644 vendor/github.com/gardener/gardener/pkg/utils/test/matchers/kubernetes_errors.go delete mode 100644 vendor/github.com/gardener/gardener/pkg/utils/test/matchers/matchers.go delete mode 100644 vendor/github.com/onsi/ginkgo/extensions/table/table.go delete mode 100644 vendor/github.com/onsi/ginkgo/extensions/table/table_entry.go diff --git a/vendor/github.com/gardener/gardener/pkg/utils/test/matchers/deep.go b/vendor/github.com/gardener/gardener/pkg/utils/test/matchers/deep.go deleted file mode 100644 index ab350879e..000000000 --- a/vendor/github.com/gardener/gardener/pkg/utils/test/matchers/deep.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file -// -// 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. - -package matchers - -import ( - "fmt" - - "github.com/onsi/gomega/format" - gomegatypes "github.com/onsi/gomega/types" - "k8s.io/apimachinery/pkg/api/equality" - "sigs.k8s.io/yaml" -) - -const ( - deepMatcherNilError = `refusing to compare to . -Be explicit and use BeNil() instead. -This is to avoid mistakes where both sides of an assertion are erroneously uninitialized` -) - -type deepMatcher struct { - name string - expected interface{} - compareFn func(a1, a2 interface{}) bool -} - -func newDeepDerivativeMatcher(expected interface{}) gomegatypes.GomegaMatcher { - return &deepMatcher{ - name: "deep derivative equal", - expected: expected, - compareFn: equality.Semantic.DeepDerivative, - } -} - -func newDeepEqualMatcher(expected interface{}) gomegatypes.GomegaMatcher { - return &deepMatcher{ - name: "deep equal", - expected: expected, - compareFn: equality.Semantic.DeepEqual, - } -} - -func (m *deepMatcher) Match(actual interface{}) (success bool, err error) { - if actual == nil && m.expected == nil { - return false, fmt.Errorf(deepMatcherNilError) - } - - return m.compareFn(m.expected, actual), nil -} - -func (m *deepMatcher) FailureMessage(actual interface{}) (message string) { - return m.failureMessage(actual, "to") -} - -func (m *deepMatcher) NegatedFailureMessage(actual interface{}) (message string) { - return m.failureMessage(actual, "not to") -} - -func (m *deepMatcher) failureMessage(actual interface{}, messagePrefix string) (message string) { - var ( - actualYAML, actualErr = yaml.Marshal(actual) - expectedYAML, expectedErr = yaml.Marshal(m.expected) - ) - - if actualErr == nil && expectedErr == nil { - return format.MessageWithDiff(string(actualYAML), messagePrefix+" "+m.name, string(expectedYAML)) - } - - return format.Message(actual, messagePrefix+" "+m.name, m.expected) -} diff --git a/vendor/github.com/gardener/gardener/pkg/utils/test/matchers/fields.go b/vendor/github.com/gardener/gardener/pkg/utils/test/matchers/fields.go deleted file mode 100644 index 810b1d07e..000000000 --- a/vendor/github.com/gardener/gardener/pkg/utils/test/matchers/fields.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file -// -// 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. - -package matchers - -import ( - "github.com/onsi/gomega" - "github.com/onsi/gomega/gstruct" - "github.com/onsi/gomega/types" -) - -// HaveFields succeeds if actual is a pointer and has a specific fields. -// Ignores extra elements or fields. -func HaveFields(fields gstruct.Fields) types.GomegaMatcher { - return gstruct.PointTo(gstruct.MatchFields(gstruct.IgnoreExtras, fields)) -} - -// ConsistOfFields succeeds if actual matches all selected fields. -// Actual must be an array, slice or map. For maps, ConsistOfFields matches against the map's values. -// Actual's elements must be pointers. -func ConsistOfFields(fields ...gstruct.Fields) types.GomegaMatcher { - var m []interface{} - for _, f := range fields { - m = append(m, HaveFields(f)) - } - return gomega.ConsistOf(m...) -} diff --git a/vendor/github.com/gardener/gardener/pkg/utils/test/matchers/kubernetes_errors.go b/vendor/github.com/gardener/gardener/pkg/utils/test/matchers/kubernetes_errors.go deleted file mode 100644 index 75619519f..000000000 --- a/vendor/github.com/gardener/gardener/pkg/utils/test/matchers/kubernetes_errors.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file -// -// 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. - -package matchers - -import ( - "fmt" - - "github.com/onsi/gomega/format" -) - -type kubernetesErrors struct { - checkFunc func(error) bool - message string -} - -func (k *kubernetesErrors) Match(actual interface{}) (success bool, err error) { - // is purely nil? - if actual == nil { - return false, nil - } - - actualErr, actualOk := actual.(error) - if !actualOk { - return false, fmt.Errorf("expected an error-type. got:\n%s", format.Object(actual, 1)) - } - - return k.checkFunc(actualErr), nil -} - -func (k *kubernetesErrors) FailureMessage(actual interface{}) (message string) { - return format.Message(actual, fmt.Sprintf("to be %s error", k.message)) -} -func (k *kubernetesErrors) NegatedFailureMessage(actual interface{}) (message string) { - return format.Message(actual, fmt.Sprintf("to not be %s error", k.message)) -} diff --git a/vendor/github.com/gardener/gardener/pkg/utils/test/matchers/matchers.go b/vendor/github.com/gardener/gardener/pkg/utils/test/matchers/matchers.go deleted file mode 100644 index 6012056bb..000000000 --- a/vendor/github.com/gardener/gardener/pkg/utils/test/matchers/matchers.go +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file -// -// 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. - -package matchers - -import ( - "errors" - - kcache "github.com/gardener/gardener/pkg/client/kubernetes/cache" - "github.com/onsi/gomega/format" - "github.com/onsi/gomega/types" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/api/meta" - "k8s.io/apimachinery/pkg/runtime" -) - -// DeepEqual returns a Gomega matcher which checks whether the expected object is deeply equal with the object it is -// being compared against. -func DeepEqual(expected interface{}) types.GomegaMatcher { - // if CharactersAroundMismatchToInclude is too small, then format.MessageWithDiff will be unable to output our - // mismatch message - if format.CharactersAroundMismatchToInclude < 50 { - format.CharactersAroundMismatchToInclude = 50 - } - - return newDeepEqualMatcher(expected) -} - -// DeepDerivativeEqual is similar to DeepEqual except that unset fields in actual are -// ignored (not compared). This allows us to focus on the fields that matter to -// the semantic comparison. -func DeepDerivativeEqual(expected interface{}) types.GomegaMatcher { - // if CharactersAroundMismatchToInclude is too small, then format.MessageWithDiff will be unable to output our - // mismatch message - if format.CharactersAroundMismatchToInclude < 50 { - format.CharactersAroundMismatchToInclude = 50 - } - - return newDeepDerivativeMatcher(expected) -} - -// BeNotFoundError checks if error is NotFound. -func BeNotFoundError() types.GomegaMatcher { - return &kubernetesErrors{ - checkFunc: apierrors.IsNotFound, - message: "NotFound", - } -} - -// BeAlreadyExistsError checks if error is AlreadyExists. -func BeAlreadyExistsError() types.GomegaMatcher { - return &kubernetesErrors{ - checkFunc: apierrors.IsAlreadyExists, - message: "AlreadyExists", - } -} - -// BeForbiddenError checks if error is Forbidden. -func BeForbiddenError() types.GomegaMatcher { - return &kubernetesErrors{ - checkFunc: apierrors.IsForbidden, - message: "Forbidden", - } -} - -// BeBadRequestError checks if error is BadRequest. -func BeBadRequestError() types.GomegaMatcher { - return &kubernetesErrors{ - checkFunc: apierrors.IsBadRequest, - message: "BadRequest", - } -} - -// BeNoMatchError checks if error is a NoMatchError. -func BeNoMatchError() types.GomegaMatcher { - return &kubernetesErrors{ - checkFunc: meta.IsNoMatchError, - message: "NoMatch", - } -} - -// BeMissingKindError checks if error is a MissingKindError. -func BeMissingKindError() types.GomegaMatcher { - return &kubernetesErrors{ - checkFunc: runtime.IsMissingKind, - message: "Object 'Kind' is missing", - } -} - -// BeInternalServerError checks if error is a InternalServerError. -func BeInternalServerError() types.GomegaMatcher { - return &kubernetesErrors{ - checkFunc: apierrors.IsInternalError, - message: "", - } -} - -// BeInvalidError checks if error is an InvalidError. -func BeInvalidError() types.GomegaMatcher { - return &kubernetesErrors{ - checkFunc: apierrors.IsInvalid, - message: "Invalid", - } -} - -// BeCacheError checks if error is a CacheError. -func BeCacheError() types.GomegaMatcher { - return &kubernetesErrors{ - checkFunc: func(err error) bool { - cacheErr := &kcache.CacheError{} - return errors.As(err, &cacheErr) - }, - message: "", - } -} diff --git a/vendor/github.com/onsi/ginkgo/extensions/table/table.go b/vendor/github.com/onsi/ginkgo/extensions/table/table.go deleted file mode 100644 index 4b0027807..000000000 --- a/vendor/github.com/onsi/ginkgo/extensions/table/table.go +++ /dev/null @@ -1,110 +0,0 @@ -/* - -Table provides a simple DSL for Ginkgo-native Table-Driven Tests - -The godoc documentation describes Table's API. More comprehensive documentation (with examples!) is available at http://onsi.github.io/ginkgo#table-driven-tests - -*/ - -package table - -import ( - "fmt" - "reflect" - - "github.com/onsi/ginkgo/internal/codelocation" - "github.com/onsi/ginkgo/internal/global" - "github.com/onsi/ginkgo/types" -) - -/* -DescribeTable describes a table-driven test. - -For example: - - DescribeTable("a simple table", - func(x int, y int, expected bool) { - Ω(x > y).Should(Equal(expected)) - }, - Entry("x > y", 1, 0, true), - Entry("x == y", 0, 0, false), - Entry("x < y", 0, 1, false), - ) - -The first argument to `DescribeTable` is a string description. -The second argument is a function that will be run for each table entry. Your assertions go here - the function is equivalent to a Ginkgo It. -The subsequent arguments must be of type `TableEntry`. We recommend using the `Entry` convenience constructors. - -The `Entry` constructor takes a string description followed by an arbitrary set of parameters. These parameters are passed into your function. - -Under the hood, `DescribeTable` simply generates a new Ginkgo `Describe`. Each `Entry` is turned into an `It` within the `Describe`. - -It's important to understand that the `Describe`s and `It`s are generated at evaluation time (i.e. when Ginkgo constructs the tree of tests and before the tests run). - -Individual Entries can be focused (with FEntry) or marked pending (with PEntry or XEntry). In addition, the entire table can be focused or marked pending with FDescribeTable and PDescribeTable/XDescribeTable. - -A description function can be passed to Entry in place of the description. The function is then fed with the entry parameters to generate the description of the It corresponding to that particular Entry. - -For example: - - describe := func(desc string) func(int, int, bool) string { - return func(x, y int, expected bool) string { - return fmt.Sprintf("%s x=%d y=%d expected:%t", desc, x, y, expected) - } - } - - DescribeTable("a simple table", - func(x int, y int, expected bool) { - Ω(x > y).Should(Equal(expected)) - }, - Entry(describe("x > y"), 1, 0, true), - Entry(describe("x == y"), 0, 0, false), - Entry(describe("x < y"), 0, 1, false), - ) -*/ -func DescribeTable(description string, itBody interface{}, entries ...TableEntry) bool { - describeTable(description, itBody, entries, types.FlagTypeNone) - return true -} - -/* -You can focus a table with `FDescribeTable`. This is equivalent to `FDescribe`. -*/ -func FDescribeTable(description string, itBody interface{}, entries ...TableEntry) bool { - describeTable(description, itBody, entries, types.FlagTypeFocused) - return true -} - -/* -You can mark a table as pending with `PDescribeTable`. This is equivalent to `PDescribe`. -*/ -func PDescribeTable(description string, itBody interface{}, entries ...TableEntry) bool { - describeTable(description, itBody, entries, types.FlagTypePending) - return true -} - -/* -You can mark a table as pending with `XDescribeTable`. This is equivalent to `XDescribe`. -*/ -func XDescribeTable(description string, itBody interface{}, entries ...TableEntry) bool { - describeTable(description, itBody, entries, types.FlagTypePending) - return true -} - -func describeTable(description string, itBody interface{}, entries []TableEntry, flag types.FlagType) { - itBodyValue := reflect.ValueOf(itBody) - if itBodyValue.Kind() != reflect.Func { - panic(fmt.Sprintf("DescribeTable expects a function, got %#v", itBody)) - } - - global.Suite.PushContainerNode( - description, - func() { - for _, entry := range entries { - entry.generateIt(itBodyValue) - } - }, - flag, - codelocation.New(2), - ) -} diff --git a/vendor/github.com/onsi/ginkgo/extensions/table/table_entry.go b/vendor/github.com/onsi/ginkgo/extensions/table/table_entry.go deleted file mode 100644 index 4d9c237ad..000000000 --- a/vendor/github.com/onsi/ginkgo/extensions/table/table_entry.go +++ /dev/null @@ -1,129 +0,0 @@ -package table - -import ( - "fmt" - "reflect" - - "github.com/onsi/ginkgo/internal/codelocation" - "github.com/onsi/ginkgo/internal/global" - "github.com/onsi/ginkgo/types" -) - -/* -TableEntry represents an entry in a table test. You generally use the `Entry` constructor. -*/ -type TableEntry struct { - Description interface{} - Parameters []interface{} - Pending bool - Focused bool - codeLocation types.CodeLocation -} - -func (t TableEntry) generateIt(itBody reflect.Value) { - var description string - descriptionValue := reflect.ValueOf(t.Description) - switch descriptionValue.Kind() { - case reflect.String: - description = descriptionValue.String() - case reflect.Func: - values := castParameters(descriptionValue, t.Parameters) - res := descriptionValue.Call(values) - if len(res) != 1 { - panic(fmt.Sprintf("The describe function should return only a value, returned %d", len(res))) - } - if res[0].Kind() != reflect.String { - panic(fmt.Sprintf("The describe function should return a string, returned %#v", res[0])) - } - description = res[0].String() - default: - panic(fmt.Sprintf("Description can either be a string or a function, got %#v", descriptionValue)) - } - - if t.Pending { - global.Suite.PushItNode(description, func() {}, types.FlagTypePending, t.codeLocation, 0) - return - } - - values := castParameters(itBody, t.Parameters) - body := func() { - itBody.Call(values) - } - - if t.Focused { - global.Suite.PushItNode(description, body, types.FlagTypeFocused, t.codeLocation, global.DefaultTimeout) - } else { - global.Suite.PushItNode(description, body, types.FlagTypeNone, t.codeLocation, global.DefaultTimeout) - } -} - -func castParameters(function reflect.Value, parameters []interface{}) []reflect.Value { - res := make([]reflect.Value, len(parameters)) - funcType := function.Type() - for i, param := range parameters { - if param == nil { - inType := funcType.In(i) - res[i] = reflect.Zero(inType) - } else { - res[i] = reflect.ValueOf(param) - } - } - return res -} - -/* -Entry constructs a TableEntry. - -The first argument is a required description (this becomes the content of the generated Ginkgo `It`). -Subsequent parameters are saved off and sent to the callback passed in to `DescribeTable`. - -Each Entry ends up generating an individual Ginkgo It. -*/ -func Entry(description interface{}, parameters ...interface{}) TableEntry { - return TableEntry{ - Description: description, - Parameters: parameters, - Pending: false, - Focused: false, - codeLocation: codelocation.New(1), - } -} - -/* -You can focus a particular entry with FEntry. This is equivalent to FIt. -*/ -func FEntry(description interface{}, parameters ...interface{}) TableEntry { - return TableEntry{ - Description: description, - Parameters: parameters, - Pending: false, - Focused: true, - codeLocation: codelocation.New(1), - } -} - -/* -You can mark a particular entry as pending with PEntry. This is equivalent to PIt. -*/ -func PEntry(description interface{}, parameters ...interface{}) TableEntry { - return TableEntry{ - Description: description, - Parameters: parameters, - Pending: true, - Focused: false, - codeLocation: codelocation.New(1), - } -} - -/* -You can mark a particular entry as pending with XEntry. This is equivalent to XIt. -*/ -func XEntry(description interface{}, parameters ...interface{}) TableEntry { - return TableEntry{ - Description: description, - Parameters: parameters, - Pending: true, - Focused: false, - codeLocation: codelocation.New(1), - } -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 6c23862f2..c6e8f69d2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -102,7 +102,6 @@ github.com/gardener/gardener/pkg/utils/kubernetes github.com/gardener/gardener/pkg/utils/kubernetes/health github.com/gardener/gardener/pkg/utils/retry github.com/gardener/gardener/pkg/utils/test -github.com/gardener/gardener/pkg/utils/test/matchers github.com/gardener/gardener/pkg/utils/version # github.com/gardener/gardener-resource-manager v0.18.0 github.com/gardener/gardener-resource-manager/pkg/apis/resources @@ -238,7 +237,6 @@ github.com/nxadm/tail/winfile ## explicit github.com/onsi/ginkgo github.com/onsi/ginkgo/config -github.com/onsi/ginkgo/extensions/table github.com/onsi/ginkgo/ginkgo github.com/onsi/ginkgo/ginkgo/convert github.com/onsi/ginkgo/ginkgo/interrupthandler