diff --git a/go.mod b/go.mod index 7f9d97fee72c..85ca23482614 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/go-logr/logr v0.2.1 github.com/google/uuid v1.1.2 github.com/kevinburke/go-bindata v3.21.0+incompatible - github.com/krishicks/yaml-patch v0.0.10 github.com/onsi/ginkgo v1.14.1 github.com/onsi/gomega v1.10.2 github.com/openshift/api v0.0.0-20201019163320-c6a5ec25f267 diff --git a/go.sum b/go.sum index 11ba4e4a5c53..74bbcfdaffa0 100644 --- a/go.sum +++ b/go.sum @@ -349,8 +349,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/krishicks/yaml-patch v0.0.10 h1:H4FcHpnNwVmw8u0MjPRjWyIXtco6zM2F78t+57oNM3E= -github.com/krishicks/yaml-patch v0.0.10/go.mod h1:Sm5TchwZS6sm7RJoyg87tzxm2ZcKzdRE4Q7TjNhPrME= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= github.com/lucas-clemente/aes12 v0.0.0-20171027163421-cd47fb39b79f/go.mod h1:JpH9J1c9oX6otFSgdUHwUBUizmKlrMjxWnIAjff4m04= diff --git a/hypershift-operator/controllers/controlplane.go b/hypershift-operator/controllers/controlplane.go index e84e5bf1eddd..af7b701f2dae 100644 --- a/hypershift-operator/controllers/controlplane.go +++ b/hypershift-operator/controllers/controlplane.go @@ -23,6 +23,7 @@ import ( "golang.org/x/crypto/bcrypt" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" @@ -326,7 +327,7 @@ func deleteManifests(ctx context.Context, c client.Client, log logr.Logger, name } obj.SetNamespace(namespace) err := c.Delete(ctx, obj) - if err != nil { + if err != nil && !apierrors.IsNotFound(err) && !meta.IsNoMatchError(err) { applyErrors = append(applyErrors, fmt.Errorf("failed to delete manifest %s: %w", manifestName, err)) } else { log.Info("deleted manifest", "manifest", manifestName) diff --git a/vendor/github.com/krishicks/yaml-patch/LICENSE b/vendor/github.com/krishicks/yaml-patch/LICENSE deleted file mode 100644 index 8dada3edaf50..000000000000 --- a/vendor/github.com/krishicks/yaml-patch/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 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. diff --git a/vendor/github.com/krishicks/yaml-patch/Makefile b/vendor/github.com/krishicks/yaml-patch/Makefile deleted file mode 100644 index 9df1fad95b0e..000000000000 --- a/vendor/github.com/krishicks/yaml-patch/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -CGO_ENABLED=0 - -all: windows linux darwin - -linux: - GOOS=linux GOARCH=amd64 go build -o yaml_patch_linux cmd/yaml-patch/*.go - -windows: - GOOS=windows GOARCH=amd64 go build -o yaml_patch.exe cmd/yaml-patch/*.go - -darwin: - GOOS=darwin GOARCH=amd64 go build -o yaml_patch_darwin cmd/yaml-patch/*.go - -clean: - rm yaml_patch_linux - rm yaml_patch.exe - rm yaml_patch_darwin diff --git a/vendor/github.com/krishicks/yaml-patch/README.md b/vendor/github.com/krishicks/yaml-patch/README.md deleted file mode 100644 index a782e6397c94..000000000000 --- a/vendor/github.com/krishicks/yaml-patch/README.md +++ /dev/null @@ -1,86 +0,0 @@ -# yaml-patch - -`yaml-patch` is a version of Evan Phoenix's -[json-patch](https://github.com/evanphx/json-patch), which is an implementation -of [JavaScript Object Notation (JSON) Patch](https://tools.ietf.org/html/rfc6902), -but for YAML. - - -## Installing - -`go get github.com/krishicks/yaml-patch` - -If you want to use the CLI: - -`go get github.com/krishicks/yaml-patch/cmd/yaml-patch` - -## API - -Given the following RFC6902-ish YAML document, `ops`: - -``` ---- -- op: add - path: /baz/waldo - value: fred -``` - -And the following YAML that is to be modified, `src`: - -``` ---- -foo: bar -baz: - quux: grault -``` - -Decode the ops file into a patch: - -``` -patch, err := yamlpatch.DecodePatch(ops) -// handle err -``` - -Then apply that patch to the document: - -``` -dst, err := patch.Apply(src) -// handle err - -// do something with dst -``` - -### Example - -``` -doc := []byte(`--- -foo: bar -baz: - quux: grault -`) - -ops := []byte(`--- -- op: add - path: /baz/waldo - value: fred -`) - -patch, err := yamlpatch.DecodePatch(ops) -if err != nil { - log.Fatalf("decoding patch failed: %s", err) -} - -bs, err := patch.Apply(doc) -if err != nil { - log.Fatalf("applying patch failed: %s", err) -} - -fmt.Println(string(bs)) -``` - -``` -baz: - quux: grault - waldo: fred -foo: bar -``` diff --git a/vendor/github.com/krishicks/yaml-patch/container.go b/vendor/github.com/krishicks/yaml-patch/container.go deleted file mode 100644 index bdc22f143de4..000000000000 --- a/vendor/github.com/krishicks/yaml-patch/container.go +++ /dev/null @@ -1,167 +0,0 @@ -package yamlpatch - -import ( - "fmt" - "strconv" - "strings" -) - -// Container is the interface for performing operations on Nodes -type Container interface { - Get(key string) (*Node, error) - Set(key string, val *Node) error - Add(key string, val *Node) error - Remove(key string) error -} - -type nodeMap map[interface{}]*Node - -func (n *nodeMap) Set(key string, val *Node) error { - (*n)[key] = val - return nil -} - -func (n *nodeMap) Add(key string, val *Node) error { - (*n)[key] = val - return nil -} - -func (n *nodeMap) Get(key string) (*Node, error) { - return (*n)[key], nil -} - -func (n *nodeMap) Remove(key string) error { - _, ok := (*n)[key] - if !ok { - return fmt.Errorf("Unable to remove nonexistent key: %s", key) - } - - delete(*n, key) - return nil -} - -type nodeSlice []*Node - -func (n *nodeSlice) Set(index string, val *Node) error { - i, err := strconv.Atoi(index) - if err != nil { - return err - } - - sz := len(*n) - if i+1 > sz { - sz = i + 1 - } - - ary := make([]*Node, sz) - - cur := *n - - copy(ary, cur) - - if i >= len(ary) { - return fmt.Errorf("Unable to access invalid index: %d", i) - } - - ary[i] = val - - *n = ary - return nil -} - -func (n *nodeSlice) Add(index string, val *Node) error { - if index == "-" { - *n = append(*n, val) - return nil - } - - i, err := strconv.Atoi(index) - if err != nil { - return err - } - - ary := make([]*Node, len(*n)+1) - - cur := *n - - copy(ary[0:i], cur[0:i]) - ary[i] = val - copy(ary[i+1:], cur[i:]) - - *n = ary - return nil -} - -func (n *nodeSlice) Get(index string) (*Node, error) { - i, err := strconv.Atoi(index) - if err != nil { - return nil, err - } - - if i >= 0 && i <= len(*n)-1 { - return (*n)[i], nil - } - - return nil, fmt.Errorf("Unable to access invalid index: %d", i) -} - -func (n *nodeSlice) Remove(index string) error { - i, err := strconv.Atoi(index) - if err != nil { - return err - } - - cur := *n - - if i >= len(cur) { - return fmt.Errorf("Unable to remove invalid index: %d", i) - } - - ary := make([]*Node, len(cur)-1) - - copy(ary[0:i], cur[0:i]) - copy(ary[i:], cur[i+1:]) - - *n = ary - return nil - -} - -func findContainer(c Container, path *OpPath) (Container, string, error) { - parts, key, err := path.Decompose() - if err != nil { - return nil, "", err - } - - foundContainer := c - - for _, part := range parts { - node, err := foundContainer.Get(decodePatchKey(part)) - if err != nil { - return nil, "", err - } - - if node == nil { - return nil, "", fmt.Errorf("path does not exist: %s", path) - } - - foundContainer = node.Container() - } - - return foundContainer, decodePatchKey(key), nil -} - -// From http://tools.ietf.org/html/rfc6901#section-4 : -// -// Evaluation of each reference token begins by decoding any escaped -// character sequence. This is performed by first transforming any -// occurrence of the sequence '~1' to '/', and then transforming any -// occurrence of the sequence '~0' to '~'. - -var ( - rfc6901Decoder = strings.NewReplacer("~1", "/", "~0", "~") -) - -func decodePatchKey(k string) string { - return rfc6901Decoder.Replace(k) -} diff --git a/vendor/github.com/krishicks/yaml-patch/node.go b/vendor/github.com/krishicks/yaml-patch/node.go deleted file mode 100644 index 4837c8a983ec..000000000000 --- a/vendor/github.com/krishicks/yaml-patch/node.go +++ /dev/null @@ -1,83 +0,0 @@ -package yamlpatch - -import "reflect" - -// Node holds a YAML document that has not yet been processed into a NodeMap or -// NodeSlice -type Node struct { - raw *interface{} - container Container -} - -// NewNode returns a new Node. It expects a pointer to an interface{} -func NewNode(raw *interface{}) *Node { - return &Node{ - raw: raw, - } -} - -// MarshalYAML implements yaml.Marshaler, and returns the correct interface{} -// to be marshaled -func (n *Node) MarshalYAML() (interface{}, error) { - if n.container != nil { - return n.container, nil - } - - return *n.raw, nil -} - -// UnmarshalYAML implements yaml.Unmarshaler -func (n *Node) UnmarshalYAML(unmarshal func(interface{}) error) error { - var data interface{} - - err := unmarshal(&data) - if err != nil { - return err - } - - n.raw = &data - return nil -} - -// Empty returns whether the raw value is nil -func (n *Node) Empty() bool { - return *n.raw == nil -} - -// Container returns the node as a Container -func (n *Node) Container() Container { - if n.container != nil { - return n.container - } - - switch rt := (*n.raw).(type) { - case []interface{}: - c := make(nodeSlice, len(rt)) - n.container = &c - - for i := range rt { - c[i] = NewNode(&rt[i]) - } - case map[interface{}]interface{}: - c := make(nodeMap, len(rt)) - n.container = &c - - for k := range rt { - v := rt[k] - c[k] = NewNode(&v) - } - } - - return n.container -} - -// Equal compares the values of the raw interfaces that the YAML was -// unmarshaled into -func (n *Node) Equal(other *Node) bool { - return reflect.DeepEqual(*n.raw, *other.raw) -} - -// Value returns the raw value of the node -func (n *Node) Value() interface{} { - return *n.raw -} diff --git a/vendor/github.com/krishicks/yaml-patch/operation.go b/vendor/github.com/krishicks/yaml-patch/operation.go deleted file mode 100644 index 69353c77d6d4..000000000000 --- a/vendor/github.com/krishicks/yaml-patch/operation.go +++ /dev/null @@ -1,181 +0,0 @@ -package yamlpatch - -import ( - "errors" - "fmt" - "strings" -) - -// Op is a type alias -type Op string - -// Ops -const ( - opAdd Op = "add" - opRemove Op = "remove" - opReplace Op = "replace" - opMove Op = "move" - opCopy Op = "copy" - opTest Op = "test" -) - -// OpPath is an RFC6902 'pointer' -type OpPath string - -// Decompose returns the pointer's components: -// "/foo" => [], "foo" -// "/foo/1" => ["foo"], "1" -// "/foo/1/bar" => ["foo", "1"], "bar" -func (p *OpPath) Decompose() ([]string, string, error) { - path := string(*p) - - if !strings.HasPrefix(path, "/") { - return nil, "", fmt.Errorf("operation path is missing leading '/': %s", path) - } - - parts := strings.Split(path, "/")[1:] - - return parts[:len(parts)-1], parts[len(parts)-1], nil -} - -// ContainsExtendedSyntax returns whether the OpPath uses the "key=value" -// format, as in "/foo/name=bar", where /foo points at an array that contains -// an object with a key "name" that has a value "bar" -func (p *OpPath) ContainsExtendedSyntax() bool { - return strings.Contains(string(*p), "=") -} - -// String returns the OpPath as a string -func (p *OpPath) String() string { - return string(*p) -} - -// Operation is an RFC6902 'Operation' -// https://tools.ietf.org/html/rfc6902#section-4 -type Operation struct { - Op Op `yaml:"op,omitempty"` - Path OpPath `yaml:"path,omitempty"` - From OpPath `yaml:"from,omitempty"` - Value *Node `yaml:"value,omitempty"` -} - -// Perform executes the operation on the given container -func (o *Operation) Perform(c Container) error { - var err error - - switch o.Op { - case opAdd: - err = tryAdd(c, o) - case opRemove: - err = tryRemove(c, o) - case opReplace: - err = tryReplace(c, o) - case opMove: - err = tryMove(c, o) - case opCopy: - err = tryCopy(c, o) - case opTest: - err = tryTest(c, o) - default: - err = fmt.Errorf("Unexpected op: %s", o.Op) - } - - return err -} - -func tryAdd(doc Container, op *Operation) error { - con, key, err := findContainer(doc, &op.Path) - if err != nil { - return fmt.Errorf("yamlpatch add operation does not apply: doc is missing path: %s", op.Path) - } - - return con.Add(key, op.Value) -} - -func tryRemove(doc Container, op *Operation) error { - con, key, err := findContainer(doc, &op.Path) - if err != nil { - return fmt.Errorf("yamlpatch remove operation does not apply: doc is missing path: %s", op.Path) - } - - return con.Remove(key) -} - -func tryReplace(doc Container, op *Operation) error { - con, key, err := findContainer(doc, &op.Path) - if err != nil { - return fmt.Errorf("yamlpatch replace operation does not apply: doc is missing path: %s", op.Path) - } - - val, err := con.Get(key) - if val == nil || err != nil { - return fmt.Errorf("yamlpatch replace operation does not apply: doc is missing key: %s", op.Path) - } - - return con.Set(key, op.Value) -} - -func tryMove(doc Container, op *Operation) error { - con, key, err := findContainer(doc, &op.From) - if err != nil { - return fmt.Errorf("yamlpatch move operation does not apply: doc is missing from path: %s", op.From) - } - - val, err := con.Get(key) - if err != nil { - return err - } - - err = con.Remove(key) - if err != nil { - return err - } - - con, key, err = findContainer(doc, &op.Path) - if err != nil { - return fmt.Errorf("yamlpatch move operation does not apply: doc is missing destination path: %s", op.Path) - } - - return con.Set(key, val) -} - -func tryCopy(doc Container, op *Operation) error { - con, key, err := findContainer(doc, &op.From) - if err != nil { - return fmt.Errorf("copy operation does not apply: doc is missing from path: %s", op.From) - } - - val, err := con.Get(key) - if err != nil { - return err - } - - con, key, err = findContainer(doc, &op.Path) - if err != nil { - return fmt.Errorf("copy operation does not apply: doc is missing destination path: %s", op.Path) - } - - return con.Set(key, val) -} - -func tryTest(doc Container, op *Operation) error { - con, key, err := findContainer(doc, &op.Path) - if err != nil { - return fmt.Errorf("test operation does not apply: doc is missing from path: %s", op.From) - } - - val, err := con.Get(key) - if err != nil { - return err - } - - if op.Value.Empty() && val == nil { - return nil - } - - if op.Value.Equal(val) { - return nil - } - - return errors.New("test failed") -} diff --git a/vendor/github.com/krishicks/yaml-patch/patch.go b/vendor/github.com/krishicks/yaml-patch/patch.go deleted file mode 100644 index 910f39eb9522..000000000000 --- a/vendor/github.com/krishicks/yaml-patch/patch.go +++ /dev/null @@ -1,60 +0,0 @@ -package yamlpatch - -import ( - "fmt" - - yaml "gopkg.in/yaml.v2" -) - -// Patch is an ordered collection of operations. -type Patch []Operation - -// DecodePatch decodes the passed YAML document as if it were an RFC 6902 patch -func DecodePatch(bs []byte) (Patch, error) { - var p Patch - - err := yaml.Unmarshal(bs, &p) - if err != nil { - return nil, err - } - - return p, nil -} - -// Apply returns a YAML document that has been mutated per the patch -func (p Patch) Apply(doc []byte) ([]byte, error) { - var iface interface{} - err := yaml.Unmarshal(doc, &iface) - if err != nil { - return nil, fmt.Errorf("failed unmarshaling doc: %s\n\n%s", string(doc), err) - } - - var c Container - c = NewNode(&iface).Container() - - for _, op := range p { - pathfinder := NewPathFinder(c) - if op.Path.ContainsExtendedSyntax() { - paths := pathfinder.Find(string(op.Path)) - if paths == nil { - return nil, fmt.Errorf("could not expand pointer: %s", op.Path) - } - - for _, path := range paths { - newOp := op - newOp.Path = OpPath(path) - err = newOp.Perform(c) - if err != nil { - return nil, err - } - } - } else { - err = op.Perform(c) - if err != nil { - return nil, err - } - } - } - - return yaml.Marshal(c) -} diff --git a/vendor/github.com/krishicks/yaml-patch/pathfinder.go b/vendor/github.com/krishicks/yaml-patch/pathfinder.go deleted file mode 100644 index 06cfb1333476..000000000000 --- a/vendor/github.com/krishicks/yaml-patch/pathfinder.go +++ /dev/null @@ -1,109 +0,0 @@ -package yamlpatch - -import ( - "fmt" - "strings" -) - -// PathFinder can be used to find RFC6902-standard paths given non-standard -// (key=value) pointer syntax -type PathFinder struct { - root Container -} - -// NewPathFinder takes an interface that represents a YAML document and returns -// a new PathFinder -func NewPathFinder(container Container) *PathFinder { - return &PathFinder{ - root: container, - } -} - -// Find expands the given path into all matching paths, returning the canonical -// versions of those matching paths -func (p *PathFinder) Find(path string) []string { - parts := strings.Split(path, "/") - - if parts[1] == "" { - return []string{"/"} - } - - routes := map[string]Container{ - "": p.root, - } - - for _, part := range parts[1:] { - routes = find(decodePatchKey(part), routes) - } - - var paths []string - for k := range routes { - paths = append(paths, k) - } - - return paths -} - -func find(part string, routes map[string]Container) map[string]Container { - matches := map[string]Container{} - - for prefix, container := range routes { - if part == "-" { - for k := range routes { - matches[fmt.Sprintf("%s/-", k)] = routes[k] - } - return matches - } - - if kv := strings.Split(part, "="); len(kv) == 2 { - if newMatches := findAll(prefix, kv[0], kv[1], container); len(newMatches) > 0 { - matches = newMatches - } - continue - } - - if node, err := container.Get(part); err == nil { - path := fmt.Sprintf("%s/%s", prefix, part) - if node == nil { - matches[path] = container - } else { - matches[path] = node.Container() - } - } - } - - return matches -} - -func findAll(prefix, findKey, findValue string, container Container) map[string]Container { - if container == nil { - return nil - } - - if v, err := container.Get(findKey); err == nil && v != nil { - if vs, ok := v.Value().(string); ok && vs == findValue { - return map[string]Container{ - prefix: container, - } - } - } - - matches := map[string]Container{} - - switch it := container.(type) { - case *nodeMap: - for k, v := range *it { - for route, match := range findAll(fmt.Sprintf("%s/%s", prefix, k), findKey, findValue, v.Container()) { - matches[route] = match - } - } - case *nodeSlice: - for i, v := range *it { - for route, match := range findAll(fmt.Sprintf("%s/%d", prefix, i), findKey, findValue, v.Container()) { - matches[route] = match - } - } - } - - return matches -} diff --git a/vendor/github.com/krishicks/yaml-patch/placeholder_wrapper.go b/vendor/github.com/krishicks/yaml-patch/placeholder_wrapper.go deleted file mode 100644 index cbcc22a84203..000000000000 --- a/vendor/github.com/krishicks/yaml-patch/placeholder_wrapper.go +++ /dev/null @@ -1,51 +0,0 @@ -package yamlpatch - -import ( - "fmt" - "regexp" -) - -// PlaceholderWrapper can be used to wrap placeholders that make YAML invalid -// in single quotes to make otherwise valid YAML -type PlaceholderWrapper struct { - LeftSide string - RightSide string - unwrappedRegex *regexp.Regexp - wrappedRegex *regexp.Regexp -} - -// NewPlaceholderWrapper returns a new PlaceholderWrapper which knows how to -// wrap and unwrap the provided left and right sides of a placeholder, e.g. {{ -// and }} -func NewPlaceholderWrapper(left, right string) *PlaceholderWrapper { - escapedLeft := regexp.QuoteMeta(left) - escapedRight := regexp.QuoteMeta(right) - unwrappedRegex := regexp.MustCompile(`\s` + escapedLeft + `([^` + escapedRight + `]+)` + escapedRight) - wrappedRegex := regexp.MustCompile(`\s'` + escapedLeft + `([^` + escapedRight + `]+)` + escapedRight + `'`) - - return &PlaceholderWrapper{ - LeftSide: left, - RightSide: right, - unwrappedRegex: unwrappedRegex, - wrappedRegex: wrappedRegex, - } -} - -// Wrap the placeholder in single quotes to make it valid YAML -func (w *PlaceholderWrapper) Wrap(input []byte) []byte { - if !w.unwrappedRegex.Match(input) { - return input - } - - return w.unwrappedRegex.ReplaceAll(input, []byte(fmt.Sprintf(` '%s$1%s'`, w.LeftSide, w.RightSide))) -} - -// Unwrap the single quotes from the placeholder to make it invalid YAML -// (again) -func (w *PlaceholderWrapper) Unwrap(input []byte) []byte { - if !w.wrappedRegex.Match(input) { - return input - } - - return w.wrappedRegex.ReplaceAll(input, []byte(fmt.Sprintf(` %s$1%s`, w.LeftSide, w.RightSide))) -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 4d3f68564081..1733ca65a81d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -68,9 +68,6 @@ github.com/kevinburke/go-bindata github.com/kevinburke/go-bindata/go-bindata # github.com/konsorten/go-windows-terminal-sequences v1.0.3 github.com/konsorten/go-windows-terminal-sequences -# github.com/krishicks/yaml-patch v0.0.10 -## explicit -github.com/krishicks/yaml-patch # github.com/mattn/go-colorable v0.1.8 github.com/mattn/go-colorable # github.com/mattn/go-isatty v0.0.12