summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/coreos
diff options
context:
space:
mode:
authorThomas Boerger <thomas@webhippie.de>2016-11-29 17:26:36 +0100
committerLunny Xiao <xiaolunwen@gmail.com>2016-11-30 00:26:36 +0800
commitb6a95a8cb3d9e611caf1bb8c0d3ff773e00923d6 (patch)
tree2717811fd5b10ebaddccf3ab18070c7bc71afaec /vendor/github.com/coreos
parent4680c349ddea56e2a6a603c2d0a54bf2bb5bfe86 (diff)
downloadgitea-b6a95a8cb3d9e611caf1bb8c0d3ff773e00923d6.tar.gz
gitea-b6a95a8cb3d9e611caf1bb8c0d3ff773e00923d6.zip
Integrate public as bindata optionally (#293)
* Dropped unused codekit config * Integrated dynamic and static bindata for public * Ignore public bindata * Add a general generate make task * Integrated flexible public assets into web command * Updated vendoring, added all missiong govendor deps * Made the linter happy with the bindata and dynamic code * Moved public bindata definition to modules directory * Ignoring the new bindata path now * Updated to the new public modules import path * Updated public bindata command and drop the new prefix
Diffstat (limited to 'vendor/github.com/coreos')
-rw-r--r--vendor/github.com/coreos/etcd/LICENSE202
-rw-r--r--vendor/github.com/coreos/etcd/NOTICE5
-rw-r--r--vendor/github.com/coreos/etcd/error/error.go162
-rw-r--r--vendor/github.com/coreos/go-etcd/LICENSE202
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/add_child.go23
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/client.go476
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/cluster.go54
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/compare_and_delete.go34
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/compare_and_swap.go36
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/debug.go55
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/delete.go40
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/error.go49
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/get.go32
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/member.go30
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/options.go72
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/requests.go403
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/response.generated.go1587
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/response.go93
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/set_update_create.go137
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/shuffle.go19
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/version.go6
-rw-r--r--vendor/github.com/coreos/go-etcd/etcd/watch.go103
22 files changed, 3820 insertions, 0 deletions
diff --git a/vendor/github.com/coreos/etcd/LICENSE b/vendor/github.com/coreos/etcd/LICENSE
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/LICENSE
@@ -0,0 +1,202 @@
+
+ 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/coreos/etcd/NOTICE b/vendor/github.com/coreos/etcd/NOTICE
new file mode 100644
index 0000000000..b39ddfa5cb
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/NOTICE
@@ -0,0 +1,5 @@
+CoreOS Project
+Copyright 2014 CoreOS, Inc
+
+This product includes software developed at CoreOS, Inc.
+(http://www.coreos.com/).
diff --git a/vendor/github.com/coreos/etcd/error/error.go b/vendor/github.com/coreos/etcd/error/error.go
new file mode 100644
index 0000000000..c5cf8ffb48
--- /dev/null
+++ b/vendor/github.com/coreos/etcd/error/error.go
@@ -0,0 +1,162 @@
+// Copyright 2015 CoreOS, Inc.
+//
+// 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 error describes errors in etcd project. When any change happens,
+// Documentation/errorcode.md needs to be updated correspondingly.
+package error
+
+import (
+ "encoding/json"
+ "fmt"
+ "net/http"
+)
+
+var errors = map[int]string{
+ // command related errors
+ EcodeKeyNotFound: "Key not found",
+ EcodeTestFailed: "Compare failed", //test and set
+ EcodeNotFile: "Not a file",
+ ecodeNoMorePeer: "Reached the max number of peers in the cluster",
+ EcodeNotDir: "Not a directory",
+ EcodeNodeExist: "Key already exists", // create
+ ecodeKeyIsPreserved: "The prefix of given key is a keyword in etcd",
+ EcodeRootROnly: "Root is read only",
+ EcodeDirNotEmpty: "Directory not empty",
+ ecodeExistingPeerAddr: "Peer address has existed",
+ EcodeUnauthorized: "The request requires user authentication",
+
+ // Post form related errors
+ ecodeValueRequired: "Value is Required in POST form",
+ EcodePrevValueRequired: "PrevValue is Required in POST form",
+ EcodeTTLNaN: "The given TTL in POST form is not a number",
+ EcodeIndexNaN: "The given index in POST form is not a number",
+ ecodeValueOrTTLRequired: "Value or TTL is required in POST form",
+ ecodeTimeoutNaN: "The given timeout in POST form is not a number",
+ ecodeNameRequired: "Name is required in POST form",
+ ecodeIndexOrValueRequired: "Index or value is required",
+ ecodeIndexValueMutex: "Index and value cannot both be specified",
+ EcodeInvalidField: "Invalid field",
+ EcodeInvalidForm: "Invalid POST form",
+ EcodeRefreshValue: "Value provided on refresh",
+ EcodeRefreshTTLRequired: "A TTL must be provided on refresh",
+
+ // raft related errors
+ EcodeRaftInternal: "Raft Internal Error",
+ EcodeLeaderElect: "During Leader Election",
+
+ // etcd related errors
+ EcodeWatcherCleared: "watcher is cleared due to etcd recovery",
+ EcodeEventIndexCleared: "The event in requested index is outdated and cleared",
+ ecodeStandbyInternal: "Standby Internal Error",
+ ecodeInvalidActiveSize: "Invalid active size",
+ ecodeInvalidRemoveDelay: "Standby remove delay",
+
+ // client related errors
+ ecodeClientInternal: "Client Internal Error",
+}
+
+var errorStatus = map[int]int{
+ EcodeKeyNotFound: http.StatusNotFound,
+ EcodeNotFile: http.StatusForbidden,
+ EcodeDirNotEmpty: http.StatusForbidden,
+ EcodeUnauthorized: http.StatusUnauthorized,
+ EcodeTestFailed: http.StatusPreconditionFailed,
+ EcodeNodeExist: http.StatusPreconditionFailed,
+ EcodeRaftInternal: http.StatusInternalServerError,
+ EcodeLeaderElect: http.StatusInternalServerError,
+}
+
+const (
+ EcodeKeyNotFound = 100
+ EcodeTestFailed = 101
+ EcodeNotFile = 102
+ ecodeNoMorePeer = 103
+ EcodeNotDir = 104
+ EcodeNodeExist = 105
+ ecodeKeyIsPreserved = 106
+ EcodeRootROnly = 107
+ EcodeDirNotEmpty = 108
+ ecodeExistingPeerAddr = 109
+ EcodeUnauthorized = 110
+
+ ecodeValueRequired = 200
+ EcodePrevValueRequired = 201
+ EcodeTTLNaN = 202
+ EcodeIndexNaN = 203
+ ecodeValueOrTTLRequired = 204
+ ecodeTimeoutNaN = 205
+ ecodeNameRequired = 206
+ ecodeIndexOrValueRequired = 207
+ ecodeIndexValueMutex = 208
+ EcodeInvalidField = 209
+ EcodeInvalidForm = 210
+ EcodeRefreshValue = 211
+ EcodeRefreshTTLRequired = 212
+
+ EcodeRaftInternal = 300
+ EcodeLeaderElect = 301
+
+ EcodeWatcherCleared = 400
+ EcodeEventIndexCleared = 401
+ ecodeStandbyInternal = 402
+ ecodeInvalidActiveSize = 403
+ ecodeInvalidRemoveDelay = 404
+
+ ecodeClientInternal = 500
+)
+
+type Error struct {
+ ErrorCode int `json:"errorCode"`
+ Message string `json:"message"`
+ Cause string `json:"cause,omitempty"`
+ Index uint64 `json:"index"`
+}
+
+func NewRequestError(errorCode int, cause string) *Error {
+ return NewError(errorCode, cause, 0)
+}
+
+func NewError(errorCode int, cause string, index uint64) *Error {
+ return &Error{
+ ErrorCode: errorCode,
+ Message: errors[errorCode],
+ Cause: cause,
+ Index: index,
+ }
+}
+
+// Error is for the error interface
+func (e Error) Error() string {
+ return e.Message + " (" + e.Cause + ")"
+}
+
+func (e Error) toJsonString() string {
+ b, _ := json.Marshal(e)
+ return string(b)
+}
+
+func (e Error) StatusCode() int {
+ status, ok := errorStatus[e.ErrorCode]
+ if !ok {
+ status = http.StatusBadRequest
+ }
+ return status
+}
+
+func (e Error) WriteTo(w http.ResponseWriter) {
+ w.Header().Add("X-Etcd-Index", fmt.Sprint(e.Index))
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(e.StatusCode())
+ fmt.Fprintln(w, e.toJsonString())
+}
diff --git a/vendor/github.com/coreos/go-etcd/LICENSE b/vendor/github.com/coreos/go-etcd/LICENSE
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/LICENSE
@@ -0,0 +1,202 @@
+
+ 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/coreos/go-etcd/etcd/add_child.go b/vendor/github.com/coreos/go-etcd/etcd/add_child.go
new file mode 100644
index 0000000000..7122be049e
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/add_child.go
@@ -0,0 +1,23 @@
+package etcd
+
+// Add a new directory with a random etcd-generated key under the given path.
+func (c *Client) AddChildDir(key string, ttl uint64) (*Response, error) {
+ raw, err := c.post(key, "", ttl)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return raw.Unmarshal()
+}
+
+// Add a new file with a random etcd-generated key under the given path.
+func (c *Client) AddChild(key string, value string, ttl uint64) (*Response, error) {
+ raw, err := c.post(key, value, ttl)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return raw.Unmarshal()
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/client.go b/vendor/github.com/coreos/go-etcd/etcd/client.go
new file mode 100644
index 0000000000..60ed762b99
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/client.go
@@ -0,0 +1,476 @@
+package etcd
+
+import (
+ "crypto/tls"
+ "crypto/x509"
+ "encoding/json"
+ "errors"
+ "io"
+ "io/ioutil"
+ "math/rand"
+ "net"
+ "net/http"
+ "net/url"
+ "os"
+ "path"
+ "strings"
+ "time"
+)
+
+// See SetConsistency for how to use these constants.
+const (
+ // Using strings rather than iota because the consistency level
+ // could be persisted to disk, so it'd be better to use
+ // human-readable values.
+ STRONG_CONSISTENCY = "STRONG"
+ WEAK_CONSISTENCY = "WEAK"
+)
+
+const (
+ defaultBufferSize = 10
+)
+
+func init() {
+ rand.Seed(int64(time.Now().Nanosecond()))
+}
+
+type Config struct {
+ CertFile string `json:"certFile"`
+ KeyFile string `json:"keyFile"`
+ CaCertFile []string `json:"caCertFiles"`
+ DialTimeout time.Duration `json:"timeout"`
+ Consistency string `json:"consistency"`
+}
+
+type credentials struct {
+ username string
+ password string
+}
+
+type Client struct {
+ config Config `json:"config"`
+ cluster *Cluster `json:"cluster"`
+ httpClient *http.Client
+ credentials *credentials
+ transport *http.Transport
+ persistence io.Writer
+ cURLch chan string
+ // CheckRetry can be used to control the policy for failed requests
+ // and modify the cluster if needed.
+ // The client calls it before sending requests again, and
+ // stops retrying if CheckRetry returns some error. The cases that
+ // this function needs to handle include no response and unexpected
+ // http status code of response.
+ // If CheckRetry is nil, client will call the default one
+ // `DefaultCheckRetry`.
+ // Argument cluster is the etcd.Cluster object that these requests have been made on.
+ // Argument numReqs is the number of http.Requests that have been made so far.
+ // Argument lastResp is the http.Responses from the last request.
+ // Argument err is the reason of the failure.
+ CheckRetry func(cluster *Cluster, numReqs int,
+ lastResp http.Response, err error) error
+}
+
+// NewClient create a basic client that is configured to be used
+// with the given machine list.
+func NewClient(machines []string) *Client {
+ config := Config{
+ // default timeout is one second
+ DialTimeout: time.Second,
+ Consistency: WEAK_CONSISTENCY,
+ }
+
+ client := &Client{
+ cluster: NewCluster(machines),
+ config: config,
+ }
+
+ client.initHTTPClient()
+ client.saveConfig()
+
+ return client
+}
+
+// NewTLSClient create a basic client with TLS configuration
+func NewTLSClient(machines []string, cert, key, caCert string) (*Client, error) {
+ // overwrite the default machine to use https
+ if len(machines) == 0 {
+ machines = []string{"https://127.0.0.1:4001"}
+ }
+
+ config := Config{
+ // default timeout is one second
+ DialTimeout: time.Second,
+ Consistency: WEAK_CONSISTENCY,
+ CertFile: cert,
+ KeyFile: key,
+ CaCertFile: make([]string, 0),
+ }
+
+ client := &Client{
+ cluster: NewCluster(machines),
+ config: config,
+ }
+
+ err := client.initHTTPSClient(cert, key)
+ if err != nil {
+ return nil, err
+ }
+
+ err = client.AddRootCA(caCert)
+
+ client.saveConfig()
+
+ return client, nil
+}
+
+// NewClientFromFile creates a client from a given file path.
+// The given file is expected to use the JSON format.
+func NewClientFromFile(fpath string) (*Client, error) {
+ fi, err := os.Open(fpath)
+ if err != nil {
+ return nil, err
+ }
+
+ defer func() {
+ if err := fi.Close(); err != nil {
+ panic(err)
+ }
+ }()
+
+ return NewClientFromReader(fi)
+}
+
+// NewClientFromReader creates a Client configured from a given reader.
+// The configuration is expected to use the JSON format.
+func NewClientFromReader(reader io.Reader) (*Client, error) {
+ c := new(Client)
+
+ b, err := ioutil.ReadAll(reader)
+ if err != nil {
+ return nil, err
+ }
+
+ err = json.Unmarshal(b, c)
+ if err != nil {
+ return nil, err
+ }
+ if c.config.CertFile == "" {
+ c.initHTTPClient()
+ } else {
+ err = c.initHTTPSClient(c.config.CertFile, c.config.KeyFile)
+ }
+
+ if err != nil {
+ return nil, err
+ }
+
+ for _, caCert := range c.config.CaCertFile {
+ if err := c.AddRootCA(caCert); err != nil {
+ return nil, err
+ }
+ }
+
+ return c, nil
+}
+
+// Override the Client's HTTP Transport object
+func (c *Client) SetTransport(tr *http.Transport) {
+ c.httpClient.Transport = tr
+ c.transport = tr
+}
+
+func (c *Client) SetCredentials(username, password string) {
+ c.credentials = &credentials{username, password}
+}
+
+func (c *Client) Close() {
+ c.transport.DisableKeepAlives = true
+ c.transport.CloseIdleConnections()
+}
+
+// initHTTPClient initializes a HTTP client for etcd client
+func (c *Client) initHTTPClient() {
+ c.transport = &http.Transport{
+ Dial: c.DefaultDial,
+ TLSClientConfig: &tls.Config{
+ InsecureSkipVerify: true,
+ },
+ }
+ c.httpClient = &http.Client{Transport: c.transport}
+}
+
+// initHTTPClient initializes a HTTPS client for etcd client
+func (c *Client) initHTTPSClient(cert, key string) error {
+ if cert == "" || key == "" {
+ return errors.New("Require both cert and key path")
+ }
+
+ tlsCert, err := tls.LoadX509KeyPair(cert, key)
+ if err != nil {
+ return err
+ }
+
+ tlsConfig := &tls.Config{
+ Certificates: []tls.Certificate{tlsCert},
+ InsecureSkipVerify: true,
+ }
+
+ c.transport = &http.Transport{
+ TLSClientConfig: tlsConfig,
+ Dial: c.DefaultDial,
+ }
+
+ c.httpClient = &http.Client{Transport: c.transport}
+ return nil
+}
+
+// SetPersistence sets a writer to which the config will be
+// written every time it's changed.
+func (c *Client) SetPersistence(writer io.Writer) {
+ c.persistence = writer
+}
+
+// SetConsistency changes the consistency level of the client.
+//
+// When consistency is set to STRONG_CONSISTENCY, all requests,
+// including GET, are sent to the leader. This means that, assuming
+// the absence of leader failures, GET requests are guaranteed to see
+// the changes made by previous requests.
+//
+// When consistency is set to WEAK_CONSISTENCY, other requests
+// are still sent to the leader, but GET requests are sent to a
+// random server from the server pool. This reduces the read
+// load on the leader, but it's not guaranteed that the GET requests
+// will see changes made by previous requests (they might have not
+// yet been committed on non-leader servers).
+func (c *Client) SetConsistency(consistency string) error {
+ if !(consistency == STRONG_CONSISTENCY || consistency == WEAK_CONSISTENCY) {
+ return errors.New("The argument must be either STRONG_CONSISTENCY or WEAK_CONSISTENCY.")
+ }
+ c.config.Consistency = consistency
+ return nil
+}
+
+// Sets the DialTimeout value
+func (c *Client) SetDialTimeout(d time.Duration) {
+ c.config.DialTimeout = d
+}
+
+// AddRootCA adds a root CA cert for the etcd client
+func (c *Client) AddRootCA(caCert string) error {
+ if c.httpClient == nil {
+ return errors.New("Client has not been initialized yet!")
+ }
+
+ certBytes, err := ioutil.ReadFile(caCert)
+ if err != nil {
+ return err
+ }
+
+ tr, ok := c.httpClient.Transport.(*http.Transport)
+
+ if !ok {
+ panic("AddRootCA(): Transport type assert should not fail")
+ }
+
+ if tr.TLSClientConfig.RootCAs == nil {
+ caCertPool := x509.NewCertPool()
+ ok = caCertPool.AppendCertsFromPEM(certBytes)
+ if ok {
+ tr.TLSClientConfig.RootCAs = caCertPool
+ }
+ tr.TLSClientConfig.InsecureSkipVerify = false
+ } else {
+ ok = tr.TLSClientConfig.RootCAs.AppendCertsFromPEM(certBytes)
+ }
+
+ if !ok {
+ err = errors.New("Unable to load caCert")
+ }
+
+ c.config.CaCertFile = append(c.config.CaCertFile, caCert)
+ c.saveConfig()
+
+ return err
+}
+
+// SetCluster updates cluster information using the given machine list.
+func (c *Client) SetCluster(machines []string) bool {
+ success := c.internalSyncCluster(machines)
+ return success
+}
+
+func (c *Client) GetCluster() []string {
+ return c.cluster.Machines
+}
+
+// SyncCluster updates the cluster information using the internal machine list.
+// If no members are found, the intenral machine list is left untouched.
+func (c *Client) SyncCluster() bool {
+ return c.internalSyncCluster(c.cluster.Machines)
+}
+
+// internalSyncCluster syncs cluster information using the given machine list.
+func (c *Client) internalSyncCluster(machines []string) bool {
+ // comma-separated list of machines in the cluster.
+ members := ""
+
+ for _, machine := range machines {
+ httpPath := c.createHttpPath(machine, path.Join(version, "members"))
+ resp, err := c.httpClient.Get(httpPath)
+ if err != nil {
+ // try another machine in the cluster
+ continue
+ }
+
+ if resp.StatusCode != http.StatusOK { // fall-back to old endpoint
+ httpPath := c.createHttpPath(machine, path.Join(version, "machines"))
+ resp, err := c.httpClient.Get(httpPath)
+ if err != nil {
+ // try another machine in the cluster
+ continue
+ }
+ b, err := ioutil.ReadAll(resp.Body)
+ resp.Body.Close()
+ if err != nil {
+ // try another machine in the cluster
+ continue
+ }
+ members = string(b)
+ } else {
+ b, err := ioutil.ReadAll(resp.Body)
+ resp.Body.Close()
+ if err != nil {
+ // try another machine in the cluster
+ continue
+ }
+
+ var mCollection memberCollection
+ if err := json.Unmarshal(b, &mCollection); err != nil {
+ // try another machine
+ continue
+ }
+
+ urls := make([]string, 0)
+ for _, m := range mCollection {
+ urls = append(urls, m.ClientURLs...)
+ }
+
+ members = strings.Join(urls, ",")
+ }
+
+ // We should never do an empty cluster update.
+ if members == "" {
+ continue
+ }
+
+ // update Machines List
+ c.cluster.updateFromStr(members)
+ logger.Debug("sync.machines ", c.cluster.Machines)
+ c.saveConfig()
+ return true
+ }
+
+ return false
+}
+
+// createHttpPath creates a complete HTTP URL.
+// serverName should contain both the host name and a port number, if any.
+func (c *Client) createHttpPath(serverName string, _path string) string {
+ u, err := url.Parse(serverName)
+ if err != nil {
+ panic(err)
+ }
+
+ u.Path = path.Join(u.Path, _path)
+
+ if u.Scheme == "" {
+ u.Scheme = "http"
+ }
+ return u.String()
+}
+
+// DefaultDial attempts to open a TCP connection to the provided address, explicitly
+// enabling keep-alives with a one-second interval.
+func (c *Client) DefaultDial(network, addr string) (net.Conn, error) {
+ dialer := net.Dialer{
+ Timeout: c.config.DialTimeout,
+ KeepAlive: time.Second,
+ }
+
+ return dialer.Dial(network, addr)
+}
+
+func (c *Client) OpenCURL() {
+ c.cURLch = make(chan string, defaultBufferSize)
+}
+
+func (c *Client) CloseCURL() {
+ c.cURLch = nil
+}
+
+func (c *Client) sendCURL(command string) {
+ go func() {
+ select {
+ case c.cURLch <- command:
+ default:
+ }
+ }()
+}
+
+func (c *Client) RecvCURL() string {
+ return <-c.cURLch
+}
+
+// saveConfig saves the current config using c.persistence.
+func (c *Client) saveConfig() error {
+ if c.persistence != nil {
+ b, err := json.Marshal(c)
+ if err != nil {
+ return err
+ }
+
+ _, err = c.persistence.Write(b)
+ if err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// MarshalJSON implements the Marshaller interface
+// as defined by the standard JSON package.
+func (c *Client) MarshalJSON() ([]byte, error) {
+ b, err := json.Marshal(struct {
+ Config Config `json:"config"`
+ Cluster *Cluster `json:"cluster"`
+ }{
+ Config: c.config,
+ Cluster: c.cluster,
+ })
+
+ if err != nil {
+ return nil, err
+ }
+
+ return b, nil
+}
+
+// UnmarshalJSON implements the Unmarshaller interface
+// as defined by the standard JSON package.
+func (c *Client) UnmarshalJSON(b []byte) error {
+ temp := struct {
+ Config Config `json:"config"`
+ Cluster *Cluster `json:"cluster"`
+ }{}
+ err := json.Unmarshal(b, &temp)
+ if err != nil {
+ return err
+ }
+
+ c.cluster = temp.Cluster
+ c.config = temp.Config
+ return nil
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/cluster.go b/vendor/github.com/coreos/go-etcd/etcd/cluster.go
new file mode 100644
index 0000000000..d0461e17a2
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/cluster.go
@@ -0,0 +1,54 @@
+package etcd
+
+import (
+ "math/rand"
+ "strings"
+ "sync"
+)
+
+type Cluster struct {
+ Leader string `json:"leader"`
+ Machines []string `json:"machines"`
+ picked int
+ mu sync.RWMutex
+}
+
+func NewCluster(machines []string) *Cluster {
+ // if an empty slice was sent in then just assume HTTP 4001 on localhost
+ if len(machines) == 0 {
+ machines = []string{"http://127.0.0.1:4001"}
+ }
+
+ machines = shuffleStringSlice(machines)
+ logger.Debug("Shuffle cluster machines", machines)
+ // default leader and machines
+ return &Cluster{
+ Leader: "",
+ Machines: machines,
+ picked: rand.Intn(len(machines)),
+ }
+}
+
+func (cl *Cluster) failure() {
+ cl.mu.Lock()
+ defer cl.mu.Unlock()
+ cl.picked = (cl.picked + 1) % len(cl.Machines)
+}
+
+func (cl *Cluster) pick() string {
+ cl.mu.Lock()
+ defer cl.mu.Unlock()
+ return cl.Machines[cl.picked]
+}
+
+func (cl *Cluster) updateFromStr(machines string) {
+ cl.mu.Lock()
+ defer cl.mu.Unlock()
+
+ cl.Machines = strings.Split(machines, ",")
+ for i := range cl.Machines {
+ cl.Machines[i] = strings.TrimSpace(cl.Machines[i])
+ }
+ cl.Machines = shuffleStringSlice(cl.Machines)
+ cl.picked = rand.Intn(len(cl.Machines))
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/compare_and_delete.go b/vendor/github.com/coreos/go-etcd/etcd/compare_and_delete.go
new file mode 100644
index 0000000000..11131bb760
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/compare_and_delete.go
@@ -0,0 +1,34 @@
+package etcd
+
+import "fmt"
+
+func (c *Client) CompareAndDelete(key string, prevValue string, prevIndex uint64) (*Response, error) {
+ raw, err := c.RawCompareAndDelete(key, prevValue, prevIndex)
+ if err != nil {
+ return nil, err
+ }
+
+ return raw.Unmarshal()
+}
+
+func (c *Client) RawCompareAndDelete(key string, prevValue string, prevIndex uint64) (*RawResponse, error) {
+ if prevValue == "" && prevIndex == 0 {
+ return nil, fmt.Errorf("You must give either prevValue or prevIndex.")
+ }
+
+ options := Options{}
+ if prevValue != "" {
+ options["prevValue"] = prevValue
+ }
+ if prevIndex != 0 {
+ options["prevIndex"] = prevIndex
+ }
+
+ raw, err := c.delete(key, options)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return raw, err
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/compare_and_swap.go b/vendor/github.com/coreos/go-etcd/etcd/compare_and_swap.go
new file mode 100644
index 0000000000..bb4f90643a
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/compare_and_swap.go
@@ -0,0 +1,36 @@
+package etcd
+
+import "fmt"
+
+func (c *Client) CompareAndSwap(key string, value string, ttl uint64,
+ prevValue string, prevIndex uint64) (*Response, error) {
+ raw, err := c.RawCompareAndSwap(key, value, ttl, prevValue, prevIndex)
+ if err != nil {
+ return nil, err
+ }
+
+ return raw.Unmarshal()
+}
+
+func (c *Client) RawCompareAndSwap(key string, value string, ttl uint64,
+ prevValue string, prevIndex uint64) (*RawResponse, error) {
+ if prevValue == "" && prevIndex == 0 {
+ return nil, fmt.Errorf("You must give either prevValue or prevIndex.")
+ }
+
+ options := Options{}
+ if prevValue != "" {
+ options["prevValue"] = prevValue
+ }
+ if prevIndex != 0 {
+ options["prevIndex"] = prevIndex
+ }
+
+ raw, err := c.put(key, value, ttl, options)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return raw, err
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/debug.go b/vendor/github.com/coreos/go-etcd/etcd/debug.go
new file mode 100644
index 0000000000..0f777886ba
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/debug.go
@@ -0,0 +1,55 @@
+package etcd
+
+import (
+ "fmt"
+ "io/ioutil"
+ "log"
+ "strings"
+)
+
+var logger *etcdLogger
+
+func SetLogger(l *log.Logger) {
+ logger = &etcdLogger{l}
+}
+
+func GetLogger() *log.Logger {
+ return logger.log
+}
+
+type etcdLogger struct {
+ log *log.Logger
+}
+
+func (p *etcdLogger) Debug(args ...interface{}) {
+ msg := "DEBUG: " + fmt.Sprint(args...)
+ p.log.Println(msg)
+}
+
+func (p *etcdLogger) Debugf(f string, args ...interface{}) {
+ msg := "DEBUG: " + fmt.Sprintf(f, args...)
+ // Append newline if necessary
+ if !strings.HasSuffix(msg, "\n") {
+ msg = msg + "\n"
+ }
+ p.log.Print(msg)
+}
+
+func (p *etcdLogger) Warning(args ...interface{}) {
+ msg := "WARNING: " + fmt.Sprint(args...)
+ p.log.Println(msg)
+}
+
+func (p *etcdLogger) Warningf(f string, args ...interface{}) {
+ msg := "WARNING: " + fmt.Sprintf(f, args...)
+ // Append newline if necessary
+ if !strings.HasSuffix(msg, "\n") {
+ msg = msg + "\n"
+ }
+ p.log.Print(msg)
+}
+
+func init() {
+ // Default logger uses the go default log.
+ SetLogger(log.New(ioutil.Discard, "go-etcd", log.LstdFlags))
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/delete.go b/vendor/github.com/coreos/go-etcd/etcd/delete.go
new file mode 100644
index 0000000000..b37accd7db
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/delete.go
@@ -0,0 +1,40 @@
+package etcd
+
+// Delete deletes the given key.
+//
+// When recursive set to false, if the key points to a
+// directory the method will fail.
+//
+// When recursive set to true, if the key points to a file,
+// the file will be deleted; if the key points to a directory,
+// then everything under the directory (including all child directories)
+// will be deleted.
+func (c *Client) Delete(key string, recursive bool) (*Response, error) {
+ raw, err := c.RawDelete(key, recursive, false)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return raw.Unmarshal()
+}
+
+// DeleteDir deletes an empty directory or a key value pair
+func (c *Client) DeleteDir(key string) (*Response, error) {
+ raw, err := c.RawDelete(key, false, true)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return raw.Unmarshal()
+}
+
+func (c *Client) RawDelete(key string, recursive bool, dir bool) (*RawResponse, error) {
+ ops := Options{
+ "recursive": recursive,
+ "dir": dir,
+ }
+
+ return c.delete(key, ops)
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/error.go b/vendor/github.com/coreos/go-etcd/etcd/error.go
new file mode 100644
index 0000000000..66dca54b5c
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/error.go
@@ -0,0 +1,49 @@
+package etcd
+
+import (
+ "encoding/json"
+ "fmt"
+)
+
+const (
+ ErrCodeEtcdNotReachable = 501
+ ErrCodeUnhandledHTTPStatus = 502
+)
+
+var (
+ errorMap = map[int]string{
+ ErrCodeEtcdNotReachable: "All the given peers are not reachable",
+ }
+)
+
+type EtcdError struct {
+ ErrorCode int `json:"errorCode"`
+ Message string `json:"message"`
+ Cause string `json:"cause,omitempty"`
+ Index uint64 `json:"index"`
+}
+
+func (e EtcdError) Error() string {
+ return fmt.Sprintf("%v: %v (%v) [%v]", e.ErrorCode, e.Message, e.Cause, e.Index)
+}
+
+func newError(errorCode int, cause string, index uint64) *EtcdError {
+ return &EtcdError{
+ ErrorCode: errorCode,
+ Message: errorMap[errorCode],
+ Cause: cause,
+ Index: index,
+ }
+}
+
+func handleError(b []byte) error {
+ etcdErr := new(EtcdError)
+
+ err := json.Unmarshal(b, etcdErr)
+ if err != nil {
+ logger.Warningf("cannot unmarshal etcd error: %v", err)
+ return err
+ }
+
+ return etcdErr
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/get.go b/vendor/github.com/coreos/go-etcd/etcd/get.go
new file mode 100644
index 0000000000..09fe641c25
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/get.go
@@ -0,0 +1,32 @@
+package etcd
+
+// Get gets the file or directory associated with the given key.
+// If the key points to a directory, files and directories under
+// it will be returned in sorted or unsorted order, depending on
+// the sort flag.
+// If recursive is set to false, contents under child directories
+// will not be returned.
+// If recursive is set to true, all the contents will be returned.
+func (c *Client) Get(key string, sort, recursive bool) (*Response, error) {
+ raw, err := c.RawGet(key, sort, recursive)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return raw.Unmarshal()
+}
+
+func (c *Client) RawGet(key string, sort, recursive bool) (*RawResponse, error) {
+ var q bool
+ if c.config.Consistency == STRONG_CONSISTENCY {
+ q = true
+ }
+ ops := Options{
+ "recursive": recursive,
+ "sorted": sort,
+ "quorum": q,
+ }
+
+ return c.get(key, ops)
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/member.go b/vendor/github.com/coreos/go-etcd/etcd/member.go
new file mode 100644
index 0000000000..5b13b28e1a
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/member.go
@@ -0,0 +1,30 @@
+package etcd
+
+import "encoding/json"
+
+type Member struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+ PeerURLs []string `json:"peerURLs"`
+ ClientURLs []string `json:"clientURLs"`
+}
+
+type memberCollection []Member
+
+func (c *memberCollection) UnmarshalJSON(data []byte) error {
+ d := struct {
+ Members []Member
+ }{}
+
+ if err := json.Unmarshal(data, &d); err != nil {
+ return err
+ }
+
+ if d.Members == nil {
+ *c = make([]Member, 0)
+ return nil
+ }
+
+ *c = d.Members
+ return nil
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/options.go b/vendor/github.com/coreos/go-etcd/etcd/options.go
new file mode 100644
index 0000000000..d21c96f080
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/options.go
@@ -0,0 +1,72 @@
+package etcd
+
+import (
+ "fmt"
+ "net/url"
+ "reflect"
+)
+
+type Options map[string]interface{}
+
+// An internally-used data structure that represents a mapping
+// between valid options and their kinds
+type validOptions map[string]reflect.Kind
+
+// Valid options for GET, PUT, POST, DELETE
+// Using CAPITALIZED_UNDERSCORE to emphasize that these
+// values are meant to be used as constants.
+var (
+ VALID_GET_OPTIONS = validOptions{
+ "recursive": reflect.Bool,
+ "quorum": reflect.Bool,
+ "sorted": reflect.Bool,
+ "wait": reflect.Bool,
+ "waitIndex": reflect.Uint64,
+ }
+
+ VALID_PUT_OPTIONS = validOptions{
+ "prevValue": reflect.String,
+ "prevIndex": reflect.Uint64,
+ "prevExist": reflect.Bool,
+ "dir": reflect.Bool,
+ }
+
+ VALID_POST_OPTIONS = validOptions{}
+
+ VALID_DELETE_OPTIONS = validOptions{
+ "recursive": reflect.Bool,
+ "dir": reflect.Bool,
+ "prevValue": reflect.String,
+ "prevIndex": reflect.Uint64,
+ }
+)
+
+// Convert options to a string of HTML parameters
+func (ops Options) toParameters(validOps validOptions) (string, error) {
+ p := "?"
+ values := url.Values{}
+
+ if ops == nil {
+ return "", nil
+ }
+
+ for k, v := range ops {
+ // Check if the given option is valid (that it exists)
+ kind := validOps[k]
+ if kind == reflect.Invalid {
+ return "", fmt.Errorf("Invalid option: %v", k)
+ }
+
+ // Check if the given option is of the valid type
+ t := reflect.TypeOf(v)
+ if kind != t.Kind() {
+ return "", fmt.Errorf("Option %s should be of %v kind, not of %v kind.",
+ k, kind, t.Kind())
+ }
+
+ values.Set(k, fmt.Sprintf("%v", v))
+ }
+
+ p += values.Encode()
+ return p, nil
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/requests.go b/vendor/github.com/coreos/go-etcd/etcd/requests.go
new file mode 100644
index 0000000000..8f720f6f44
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/requests.go
@@ -0,0 +1,403 @@
+package etcd
+
+import (
+ "errors"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "net/http"
+ "net/url"
+ "path"
+ "strings"
+ "sync"
+ "time"
+)
+
+// Errors introduced by handling requests
+var (
+ ErrRequestCancelled = errors.New("sending request is cancelled")
+)
+
+type RawRequest struct {
+ Method string
+ RelativePath string
+ Values url.Values
+ Cancel <-chan bool
+}
+
+// NewRawRequest returns a new RawRequest
+func NewRawRequest(method, relativePath string, values url.Values, cancel <-chan bool) *RawRequest {
+ return &RawRequest{
+ Method: method,
+ RelativePath: relativePath,
+ Values: values,
+ Cancel: cancel,
+ }
+}
+
+// getCancelable issues a cancelable GET request
+func (c *Client) getCancelable(key string, options Options,
+ cancel <-chan bool) (*RawResponse, error) {
+ logger.Debugf("get %s [%s]", key, c.cluster.pick())
+ p := keyToPath(key)
+
+ str, err := options.toParameters(VALID_GET_OPTIONS)
+ if err != nil {
+ return nil, err
+ }
+ p += str
+
+ req := NewRawRequest("GET", p, nil, cancel)
+ resp, err := c.SendRequest(req)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return resp, nil
+}
+
+// get issues a GET request
+func (c *Client) get(key string, options Options) (*RawResponse, error) {
+ return c.getCancelable(key, options, nil)
+}
+
+// put issues a PUT request
+func (c *Client) put(key string, value string, ttl uint64,
+ options Options) (*RawResponse, error) {
+
+ logger.Debugf("put %s, %s, ttl: %d, [%s]", key, value, ttl, c.cluster.pick())
+ p := keyToPath(key)
+
+ str, err := options.toParameters(VALID_PUT_OPTIONS)
+ if err != nil {
+ return nil, err
+ }
+ p += str
+
+ req := NewRawRequest("PUT", p, buildValues(value, ttl), nil)
+ resp, err := c.SendRequest(req)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return resp, nil
+}
+
+// post issues a POST request
+func (c *Client) post(key string, value string, ttl uint64) (*RawResponse, error) {
+ logger.Debugf("post %s, %s, ttl: %d, [%s]", key, value, ttl, c.cluster.pick())
+ p := keyToPath(key)
+
+ req := NewRawRequest("POST", p, buildValues(value, ttl), nil)
+ resp, err := c.SendRequest(req)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return resp, nil
+}
+
+// delete issues a DELETE request
+func (c *Client) delete(key string, options Options) (*RawResponse, error) {
+ logger.Debugf("delete %s [%s]", key, c.cluster.pick())
+ p := keyToPath(key)
+
+ str, err := options.toParameters(VALID_DELETE_OPTIONS)
+ if err != nil {
+ return nil, err
+ }
+ p += str
+
+ req := NewRawRequest("DELETE", p, nil, nil)
+ resp, err := c.SendRequest(req)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return resp, nil
+}
+
+// SendRequest sends a HTTP request and returns a Response as defined by etcd
+func (c *Client) SendRequest(rr *RawRequest) (*RawResponse, error) {
+ var req *http.Request
+ var resp *http.Response
+ var httpPath string
+ var err error
+ var respBody []byte
+
+ var numReqs = 1
+
+ checkRetry := c.CheckRetry
+ if checkRetry == nil {
+ checkRetry = DefaultCheckRetry
+ }
+
+ cancelled := make(chan bool, 1)
+ reqLock := new(sync.Mutex)
+
+ if rr.Cancel != nil {
+ cancelRoutine := make(chan bool)
+ defer close(cancelRoutine)
+
+ go func() {
+ select {
+ case <-rr.Cancel:
+ cancelled <- true
+ logger.Debug("send.request is cancelled")
+ case <-cancelRoutine:
+ return
+ }
+
+ // Repeat canceling request until this thread is stopped
+ // because we have no idea about whether it succeeds.
+ for {
+ reqLock.Lock()
+ c.httpClient.Transport.(*http.Transport).CancelRequest(req)
+ reqLock.Unlock()
+
+ select {
+ case <-time.After(100 * time.Millisecond):
+ case <-cancelRoutine:
+ return
+ }
+ }
+ }()
+ }
+
+ // If we connect to a follower and consistency is required, retry until
+ // we connect to a leader
+ sleep := 25 * time.Millisecond
+ maxSleep := time.Second
+
+ for attempt := 0; ; attempt++ {
+ if attempt > 0 {
+ select {
+ case <-cancelled:
+ return nil, ErrRequestCancelled
+ case <-time.After(sleep):
+ sleep = sleep * 2
+ if sleep > maxSleep {
+ sleep = maxSleep
+ }
+ }
+ }
+
+ logger.Debug("Connecting to etcd: attempt ", attempt+1, " for ", rr.RelativePath)
+
+ // get httpPath if not set
+ if httpPath == "" {
+ httpPath = c.getHttpPath(rr.RelativePath)
+ }
+
+ // Return a cURL command if curlChan is set
+ if c.cURLch != nil {
+ command := fmt.Sprintf("curl -X %s %s", rr.Method, httpPath)
+ for key, value := range rr.Values {
+ command += fmt.Sprintf(" -d %s=%s", key, value[0])
+ }
+ if c.credentials != nil {
+ command += fmt.Sprintf(" -u %s", c.credentials.username)
+ }
+ c.sendCURL(command)
+ }
+
+ logger.Debug("send.request.to ", httpPath, " | method ", rr.Method)
+
+ req, err := func() (*http.Request, error) {
+ reqLock.Lock()
+ defer reqLock.Unlock()
+
+ if rr.Values == nil {
+ if req, err = http.NewRequest(rr.Method, httpPath, nil); err != nil {
+ return nil, err
+ }
+ } else {
+ body := strings.NewReader(rr.Values.Encode())
+ if req, err = http.NewRequest(rr.Method, httpPath, body); err != nil {
+ return nil, err
+ }
+
+ req.Header.Set("Content-Type",
+ "application/x-www-form-urlencoded; param=value")
+ }
+ return req, nil
+ }()
+
+ if err != nil {
+ return nil, err
+ }
+
+ if c.credentials != nil {
+ req.SetBasicAuth(c.credentials.username, c.credentials.password)
+ }
+
+ resp, err = c.httpClient.Do(req)
+ // clear previous httpPath
+ httpPath = ""
+ defer func() {
+ if resp != nil {
+ resp.Body.Close()
+ }
+ }()
+
+ // If the request was cancelled, return ErrRequestCancelled directly
+ select {
+ case <-cancelled:
+ return nil, ErrRequestCancelled
+ default:
+ }
+
+ numReqs++
+
+ // network error, change a machine!
+ if err != nil {
+ logger.Debug("network error: ", err.Error())
+ lastResp := http.Response{}
+ if checkErr := checkRetry(c.cluster, numReqs, lastResp, err); checkErr != nil {
+ return nil, checkErr
+ }
+
+ c.cluster.failure()
+ continue
+ }
+
+ // if there is no error, it should receive response
+ logger.Debug("recv.response.from ", httpPath)
+
+ if validHttpStatusCode[resp.StatusCode] {
+ // try to read byte code and break the loop
+ respBody, err = ioutil.ReadAll(resp.Body)
+ if err == nil {
+ logger.Debug("recv.success ", httpPath)
+ break
+ }
+ // ReadAll error may be caused due to cancel request
+ select {
+ case <-cancelled:
+ return nil, ErrRequestCancelled
+ default:
+ }
+
+ if err == io.ErrUnexpectedEOF {
+ // underlying connection was closed prematurely, probably by timeout
+ // TODO: empty body or unexpectedEOF can cause http.Transport to get hosed;
+ // this allows the client to detect that and take evasive action. Need
+ // to revisit once code.google.com/p/go/issues/detail?id=8648 gets fixed.
+ respBody = []byte{}
+ break
+ }
+ }
+
+ if resp.StatusCode == http.StatusTemporaryRedirect {
+ u, err := resp.Location()
+
+ if err != nil {
+ logger.Warning(err)
+ } else {
+ // set httpPath for following redirection
+ httpPath = u.String()
+ }
+ resp.Body.Close()
+ continue
+ }
+
+ if checkErr := checkRetry(c.cluster, numReqs, *resp,
+ errors.New("Unexpected HTTP status code")); checkErr != nil {
+ return nil, checkErr
+ }
+ resp.Body.Close()
+ }
+
+ r := &RawResponse{
+ StatusCode: resp.StatusCode,
+ Body: respBody,
+ Header: resp.Header,
+ }
+
+ return r, nil
+}
+
+// DefaultCheckRetry defines the retrying behaviour for bad HTTP requests
+// If we have retried 2 * machine number, stop retrying.
+// If status code is InternalServerError, sleep for 200ms.
+func DefaultCheckRetry(cluster *Cluster, numReqs int, lastResp http.Response,
+ err error) error {
+
+ if numReqs > 2*len(cluster.Machines) {
+ errStr := fmt.Sprintf("failed to propose on members %v twice [last error: %v]", cluster.Machines, err)
+ return newError(ErrCodeEtcdNotReachable, errStr, 0)
+ }
+
+ if isEmptyResponse(lastResp) {
+ // always retry if it failed to get response from one machine
+ return nil
+ }
+ if !shouldRetry(lastResp) {
+ body := []byte("nil")
+ if lastResp.Body != nil {
+ if b, err := ioutil.ReadAll(lastResp.Body); err == nil {
+ body = b
+ }
+ }
+ errStr := fmt.Sprintf("unhandled http status [%s] with body [%s]", http.StatusText(lastResp.StatusCode), body)
+ return newError(ErrCodeUnhandledHTTPStatus, errStr, 0)
+ }
+ // sleep some time and expect leader election finish
+ time.Sleep(time.Millisecond * 200)
+ logger.Warning("bad response status code ", lastResp.StatusCode)
+ return nil
+}
+
+func isEmptyResponse(r http.Response) bool { return r.StatusCode == 0 }
+
+// shouldRetry returns whether the reponse deserves retry.
+func shouldRetry(r http.Response) bool {
+ // TODO: only retry when the cluster is in leader election
+ // We cannot do it exactly because etcd doesn't support it well.
+ return r.StatusCode == http.StatusInternalServerError
+}
+
+func (c *Client) getHttpPath(s ...string) string {
+ fullPath := c.cluster.pick() + "/" + version
+ for _, seg := range s {
+ fullPath = fullPath + "/" + seg
+ }
+ return fullPath
+}
+
+// buildValues builds a url.Values map according to the given value and ttl
+func buildValues(value string, ttl uint64) url.Values {
+ v := url.Values{}
+
+ if value != "" {
+ v.Set("value", value)
+ }
+
+ if ttl > 0 {
+ v.Set("ttl", fmt.Sprintf("%v", ttl))
+ }
+
+ return v
+}
+
+// convert key string to http path exclude version, including URL escaping
+// for example: key[foo] -> path[keys/foo]
+// key[/%z] -> path[keys/%25z]
+// key[/] -> path[keys/]
+func keyToPath(key string) string {
+ // URL-escape our key, except for slashes
+ p := strings.Replace(url.QueryEscape(path.Join("keys", key)), "%2F", "/", -1)
+
+ // corner case: if key is "/" or "//" ect
+ // path join will clear the tailing "/"
+ // we need to add it back
+ if p == "keys" {
+ p = "keys/"
+ }
+
+ return p
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/response.generated.go b/vendor/github.com/coreos/go-etcd/etcd/response.generated.go
new file mode 100644
index 0000000000..95d2cd99d4
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/response.generated.go
@@ -0,0 +1,1587 @@
+// ************************************************************
+// DO NOT EDIT.
+// THIS FILE IS AUTO-GENERATED BY codecgen.
+// ************************************************************
+
+package etcd
+
+import (
+ "errors"
+ "fmt"
+ codec1978 "github.com/ugorji/go/codec"
+ pkg1_http "net/http"
+ "reflect"
+ "runtime"
+ time "time"
+)
+
+const (
+ // ----- content types ----
+ codecSelferC_UTF81978 = 1
+ codecSelferC_RAW1978 = 0
+ // ----- value types used ----
+ codecSelferValueTypeArray1978 = 10
+ codecSelferValueTypeMap1978 = 9
+ // ----- containerStateValues ----
+ codecSelfer_containerMapKey1978 = 2
+ codecSelfer_containerMapValue1978 = 3
+ codecSelfer_containerMapEnd1978 = 4
+ codecSelfer_containerArrayElem1978 = 6
+ codecSelfer_containerArrayEnd1978 = 7
+)
+
+var (
+ codecSelferBitsize1978 = uint8(reflect.TypeOf(uint(0)).Bits())
+ codecSelferOnlyMapOrArrayEncodeToStructErr1978 = errors.New(`only encoded map or array can be decoded into a struct`)
+)
+
+type codecSelfer1978 struct{}
+
+func init() {
+ if codec1978.GenVersion != 5 {
+ _, file, _, _ := runtime.Caller(0)
+ err := fmt.Errorf("codecgen version mismatch: current: %v, need %v. Re-generate file: %v",
+ 5, codec1978.GenVersion, file)
+ panic(err)
+ }
+ if false { // reference the types, but skip this branch at build/run time
+ var v0 pkg1_http.Header
+ var v1 time.Time
+ _, _ = v0, v1
+ }
+}
+
+func (x responseType) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ yym1 := z.EncBinary()
+ _ = yym1
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ r.EncodeInt(int64(x))
+ }
+}
+
+func (x *responseType) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym2 := z.DecBinary()
+ _ = yym2
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ *((*int)(x)) = int(r.DecodeInt(codecSelferBitsize1978))
+ }
+}
+
+func (x *RawResponse) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym3 := z.EncBinary()
+ _ = yym3
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep4 := !z.EncBinary()
+ yy2arr4 := z.EncBasicHandle().StructToArray
+ var yyq4 [3]bool
+ _, _, _ = yysep4, yyq4, yy2arr4
+ const yyr4 bool = false
+ var yynn4 int
+ if yyr4 || yy2arr4 {
+ r.EncodeArrayStart(3)
+ } else {
+ yynn4 = 3
+ for _, b := range yyq4 {
+ if b {
+ yynn4++
+ }
+ }
+ r.EncodeMapStart(yynn4)
+ yynn4 = 0
+ }
+ if yyr4 || yy2arr4 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ yym6 := z.EncBinary()
+ _ = yym6
+ if false {
+ } else {
+ r.EncodeInt(int64(x.StatusCode))
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("StatusCode"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ yym7 := z.EncBinary()
+ _ = yym7
+ if false {
+ } else {
+ r.EncodeInt(int64(x.StatusCode))
+ }
+ }
+ if yyr4 || yy2arr4 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ if x.Body == nil {
+ r.EncodeNil()
+ } else {
+ yym9 := z.EncBinary()
+ _ = yym9
+ if false {
+ } else {
+ r.EncodeStringBytes(codecSelferC_RAW1978, []byte(x.Body))
+ }
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("Body"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ if x.Body == nil {
+ r.EncodeNil()
+ } else {
+ yym10 := z.EncBinary()
+ _ = yym10
+ if false {
+ } else {
+ r.EncodeStringBytes(codecSelferC_RAW1978, []byte(x.Body))
+ }
+ }
+ }
+ if yyr4 || yy2arr4 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ if x.Header == nil {
+ r.EncodeNil()
+ } else {
+ yym12 := z.EncBinary()
+ _ = yym12
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x.Header) {
+ } else {
+ h.enchttp_Header((pkg1_http.Header)(x.Header), e)
+ }
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("Header"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ if x.Header == nil {
+ r.EncodeNil()
+ } else {
+ yym13 := z.EncBinary()
+ _ = yym13
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x.Header) {
+ } else {
+ h.enchttp_Header((pkg1_http.Header)(x.Header), e)
+ }
+ }
+ }
+ if yyr4 || yy2arr4 {
+ z.EncSendContainerState(codecSelfer_containerArrayEnd1978)
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapEnd1978)
+ }
+ }
+ }
+}
+
+func (x *RawResponse) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym14 := z.DecBinary()
+ _ = yym14
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct15 := r.ContainerType()
+ if yyct15 == codecSelferValueTypeMap1978 {
+ yyl15 := r.ReadMapStart()
+ if yyl15 == 0 {
+ z.DecSendContainerState(codecSelfer_containerMapEnd1978)
+ } else {
+ x.codecDecodeSelfFromMap(yyl15, d)
+ }
+ } else if yyct15 == codecSelferValueTypeArray1978 {
+ yyl15 := r.ReadArrayStart()
+ if yyl15 == 0 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ } else {
+ x.codecDecodeSelfFromArray(yyl15, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr1978)
+ }
+ }
+}
+
+func (x *RawResponse) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys16Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys16Slc
+ var yyhl16 bool = l >= 0
+ for yyj16 := 0; ; yyj16++ {
+ if yyhl16 {
+ if yyj16 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ z.DecSendContainerState(codecSelfer_containerMapKey1978)
+ yys16Slc = r.DecodeBytes(yys16Slc, true, true)
+ yys16 := string(yys16Slc)
+ z.DecSendContainerState(codecSelfer_containerMapValue1978)
+ switch yys16 {
+ case "StatusCode":
+ if r.TryDecodeAsNil() {
+ x.StatusCode = 0
+ } else {
+ x.StatusCode = int(r.DecodeInt(codecSelferBitsize1978))
+ }
+ case "Body":
+ if r.TryDecodeAsNil() {
+ x.Body = nil
+ } else {
+ yyv18 := &x.Body
+ yym19 := z.DecBinary()
+ _ = yym19
+ if false {
+ } else {
+ *yyv18 = r.DecodeBytes(*(*[]byte)(yyv18), false, false)
+ }
+ }
+ case "Header":
+ if r.TryDecodeAsNil() {
+ x.Header = nil
+ } else {
+ yyv20 := &x.Header
+ yym21 := z.DecBinary()
+ _ = yym21
+ if false {
+ } else if z.HasExtensions() && z.DecExt(yyv20) {
+ } else {
+ h.dechttp_Header((*pkg1_http.Header)(yyv20), d)
+ }
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys16)
+ } // end switch yys16
+ } // end for yyj16
+ z.DecSendContainerState(codecSelfer_containerMapEnd1978)
+}
+
+func (x *RawResponse) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj22 int
+ var yyb22 bool
+ var yyhl22 bool = l >= 0
+ yyj22++
+ if yyhl22 {
+ yyb22 = yyj22 > l
+ } else {
+ yyb22 = r.CheckBreak()
+ }
+ if yyb22 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ x.StatusCode = 0
+ } else {
+ x.StatusCode = int(r.DecodeInt(codecSelferBitsize1978))
+ }
+ yyj22++
+ if yyhl22 {
+ yyb22 = yyj22 > l
+ } else {
+ yyb22 = r.CheckBreak()
+ }
+ if yyb22 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ x.Body = nil
+ } else {
+ yyv24 := &x.Body
+ yym25 := z.DecBinary()
+ _ = yym25
+ if false {
+ } else {
+ *yyv24 = r.DecodeBytes(*(*[]byte)(yyv24), false, false)
+ }
+ }
+ yyj22++
+ if yyhl22 {
+ yyb22 = yyj22 > l
+ } else {
+ yyb22 = r.CheckBreak()
+ }
+ if yyb22 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ x.Header = nil
+ } else {
+ yyv26 := &x.Header
+ yym27 := z.DecBinary()
+ _ = yym27
+ if false {
+ } else if z.HasExtensions() && z.DecExt(yyv26) {
+ } else {
+ h.dechttp_Header((*pkg1_http.Header)(yyv26), d)
+ }
+ }
+ for {
+ yyj22++
+ if yyhl22 {
+ yyb22 = yyj22 > l
+ } else {
+ yyb22 = r.CheckBreak()
+ }
+ if yyb22 {
+ break
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ z.DecStructFieldNotFound(yyj22-1, "")
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+}
+
+func (x *Response) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym28 := z.EncBinary()
+ _ = yym28
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep29 := !z.EncBinary()
+ yy2arr29 := z.EncBasicHandle().StructToArray
+ var yyq29 [6]bool
+ _, _, _ = yysep29, yyq29, yy2arr29
+ const yyr29 bool = false
+ yyq29[2] = x.PrevNode != nil
+ var yynn29 int
+ if yyr29 || yy2arr29 {
+ r.EncodeArrayStart(6)
+ } else {
+ yynn29 = 5
+ for _, b := range yyq29 {
+ if b {
+ yynn29++
+ }
+ }
+ r.EncodeMapStart(yynn29)
+ yynn29 = 0
+ }
+ if yyr29 || yy2arr29 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ yym31 := z.EncBinary()
+ _ = yym31
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF81978, string(x.Action))
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("action"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ yym32 := z.EncBinary()
+ _ = yym32
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF81978, string(x.Action))
+ }
+ }
+ if yyr29 || yy2arr29 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ if x.Node == nil {
+ r.EncodeNil()
+ } else {
+ x.Node.CodecEncodeSelf(e)
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("node"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ if x.Node == nil {
+ r.EncodeNil()
+ } else {
+ x.Node.CodecEncodeSelf(e)
+ }
+ }
+ if yyr29 || yy2arr29 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ if yyq29[2] {
+ if x.PrevNode == nil {
+ r.EncodeNil()
+ } else {
+ x.PrevNode.CodecEncodeSelf(e)
+ }
+ } else {
+ r.EncodeNil()
+ }
+ } else {
+ if yyq29[2] {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("prevNode"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ if x.PrevNode == nil {
+ r.EncodeNil()
+ } else {
+ x.PrevNode.CodecEncodeSelf(e)
+ }
+ }
+ }
+ if yyr29 || yy2arr29 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ yym36 := z.EncBinary()
+ _ = yym36
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.EtcdIndex))
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("etcdIndex"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ yym37 := z.EncBinary()
+ _ = yym37
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.EtcdIndex))
+ }
+ }
+ if yyr29 || yy2arr29 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ yym39 := z.EncBinary()
+ _ = yym39
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.RaftIndex))
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("raftIndex"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ yym40 := z.EncBinary()
+ _ = yym40
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.RaftIndex))
+ }
+ }
+ if yyr29 || yy2arr29 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ yym42 := z.EncBinary()
+ _ = yym42
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.RaftTerm))
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("raftTerm"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ yym43 := z.EncBinary()
+ _ = yym43
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.RaftTerm))
+ }
+ }
+ if yyr29 || yy2arr29 {
+ z.EncSendContainerState(codecSelfer_containerArrayEnd1978)
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapEnd1978)
+ }
+ }
+ }
+}
+
+func (x *Response) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym44 := z.DecBinary()
+ _ = yym44
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct45 := r.ContainerType()
+ if yyct45 == codecSelferValueTypeMap1978 {
+ yyl45 := r.ReadMapStart()
+ if yyl45 == 0 {
+ z.DecSendContainerState(codecSelfer_containerMapEnd1978)
+ } else {
+ x.codecDecodeSelfFromMap(yyl45, d)
+ }
+ } else if yyct45 == codecSelferValueTypeArray1978 {
+ yyl45 := r.ReadArrayStart()
+ if yyl45 == 0 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ } else {
+ x.codecDecodeSelfFromArray(yyl45, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr1978)
+ }
+ }
+}
+
+func (x *Response) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys46Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys46Slc
+ var yyhl46 bool = l >= 0
+ for yyj46 := 0; ; yyj46++ {
+ if yyhl46 {
+ if yyj46 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ z.DecSendContainerState(codecSelfer_containerMapKey1978)
+ yys46Slc = r.DecodeBytes(yys46Slc, true, true)
+ yys46 := string(yys46Slc)
+ z.DecSendContainerState(codecSelfer_containerMapValue1978)
+ switch yys46 {
+ case "action":
+ if r.TryDecodeAsNil() {
+ x.Action = ""
+ } else {
+ x.Action = string(r.DecodeString())
+ }
+ case "node":
+ if r.TryDecodeAsNil() {
+ if x.Node != nil {
+ x.Node = nil
+ }
+ } else {
+ if x.Node == nil {
+ x.Node = new(Node)
+ }
+ x.Node.CodecDecodeSelf(d)
+ }
+ case "prevNode":
+ if r.TryDecodeAsNil() {
+ if x.PrevNode != nil {
+ x.PrevNode = nil
+ }
+ } else {
+ if x.PrevNode == nil {
+ x.PrevNode = new(Node)
+ }
+ x.PrevNode.CodecDecodeSelf(d)
+ }
+ case "etcdIndex":
+ if r.TryDecodeAsNil() {
+ x.EtcdIndex = 0
+ } else {
+ x.EtcdIndex = uint64(r.DecodeUint(64))
+ }
+ case "raftIndex":
+ if r.TryDecodeAsNil() {
+ x.RaftIndex = 0
+ } else {
+ x.RaftIndex = uint64(r.DecodeUint(64))
+ }
+ case "raftTerm":
+ if r.TryDecodeAsNil() {
+ x.RaftTerm = 0
+ } else {
+ x.RaftTerm = uint64(r.DecodeUint(64))
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys46)
+ } // end switch yys46
+ } // end for yyj46
+ z.DecSendContainerState(codecSelfer_containerMapEnd1978)
+}
+
+func (x *Response) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj53 int
+ var yyb53 bool
+ var yyhl53 bool = l >= 0
+ yyj53++
+ if yyhl53 {
+ yyb53 = yyj53 > l
+ } else {
+ yyb53 = r.CheckBreak()
+ }
+ if yyb53 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ x.Action = ""
+ } else {
+ x.Action = string(r.DecodeString())
+ }
+ yyj53++
+ if yyhl53 {
+ yyb53 = yyj53 > l
+ } else {
+ yyb53 = r.CheckBreak()
+ }
+ if yyb53 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ if x.Node != nil {
+ x.Node = nil
+ }
+ } else {
+ if x.Node == nil {
+ x.Node = new(Node)
+ }
+ x.Node.CodecDecodeSelf(d)
+ }
+ yyj53++
+ if yyhl53 {
+ yyb53 = yyj53 > l
+ } else {
+ yyb53 = r.CheckBreak()
+ }
+ if yyb53 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ if x.PrevNode != nil {
+ x.PrevNode = nil
+ }
+ } else {
+ if x.PrevNode == nil {
+ x.PrevNode = new(Node)
+ }
+ x.PrevNode.CodecDecodeSelf(d)
+ }
+ yyj53++
+ if yyhl53 {
+ yyb53 = yyj53 > l
+ } else {
+ yyb53 = r.CheckBreak()
+ }
+ if yyb53 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ x.EtcdIndex = 0
+ } else {
+ x.EtcdIndex = uint64(r.DecodeUint(64))
+ }
+ yyj53++
+ if yyhl53 {
+ yyb53 = yyj53 > l
+ } else {
+ yyb53 = r.CheckBreak()
+ }
+ if yyb53 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ x.RaftIndex = 0
+ } else {
+ x.RaftIndex = uint64(r.DecodeUint(64))
+ }
+ yyj53++
+ if yyhl53 {
+ yyb53 = yyj53 > l
+ } else {
+ yyb53 = r.CheckBreak()
+ }
+ if yyb53 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ x.RaftTerm = 0
+ } else {
+ x.RaftTerm = uint64(r.DecodeUint(64))
+ }
+ for {
+ yyj53++
+ if yyhl53 {
+ yyb53 = yyj53 > l
+ } else {
+ yyb53 = r.CheckBreak()
+ }
+ if yyb53 {
+ break
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ z.DecStructFieldNotFound(yyj53-1, "")
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+}
+
+func (x *Node) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym60 := z.EncBinary()
+ _ = yym60
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ yysep61 := !z.EncBinary()
+ yy2arr61 := z.EncBasicHandle().StructToArray
+ var yyq61 [8]bool
+ _, _, _ = yysep61, yyq61, yy2arr61
+ const yyr61 bool = false
+ yyq61[1] = x.Value != ""
+ yyq61[2] = x.Dir != false
+ yyq61[3] = x.Expiration != nil
+ yyq61[4] = x.TTL != 0
+ yyq61[5] = len(x.Nodes) != 0
+ yyq61[6] = x.ModifiedIndex != 0
+ yyq61[7] = x.CreatedIndex != 0
+ var yynn61 int
+ if yyr61 || yy2arr61 {
+ r.EncodeArrayStart(8)
+ } else {
+ yynn61 = 1
+ for _, b := range yyq61 {
+ if b {
+ yynn61++
+ }
+ }
+ r.EncodeMapStart(yynn61)
+ yynn61 = 0
+ }
+ if yyr61 || yy2arr61 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ yym63 := z.EncBinary()
+ _ = yym63
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF81978, string(x.Key))
+ }
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("key"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ yym64 := z.EncBinary()
+ _ = yym64
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF81978, string(x.Key))
+ }
+ }
+ if yyr61 || yy2arr61 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ if yyq61[1] {
+ yym66 := z.EncBinary()
+ _ = yym66
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF81978, string(x.Value))
+ }
+ } else {
+ r.EncodeString(codecSelferC_UTF81978, "")
+ }
+ } else {
+ if yyq61[1] {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("value"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ yym67 := z.EncBinary()
+ _ = yym67
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF81978, string(x.Value))
+ }
+ }
+ }
+ if yyr61 || yy2arr61 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ if yyq61[2] {
+ yym69 := z.EncBinary()
+ _ = yym69
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Dir))
+ }
+ } else {
+ r.EncodeBool(false)
+ }
+ } else {
+ if yyq61[2] {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("dir"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ yym70 := z.EncBinary()
+ _ = yym70
+ if false {
+ } else {
+ r.EncodeBool(bool(x.Dir))
+ }
+ }
+ }
+ if yyr61 || yy2arr61 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ if yyq61[3] {
+ if x.Expiration == nil {
+ r.EncodeNil()
+ } else {
+ yym72 := z.EncBinary()
+ _ = yym72
+ if false {
+ } else if yym73 := z.TimeRtidIfBinc(); yym73 != 0 {
+ r.EncodeBuiltin(yym73, x.Expiration)
+ } else if z.HasExtensions() && z.EncExt(x.Expiration) {
+ } else if yym72 {
+ z.EncBinaryMarshal(x.Expiration)
+ } else if !yym72 && z.IsJSONHandle() {
+ z.EncJSONMarshal(x.Expiration)
+ } else {
+ z.EncFallback(x.Expiration)
+ }
+ }
+ } else {
+ r.EncodeNil()
+ }
+ } else {
+ if yyq61[3] {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("expiration"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ if x.Expiration == nil {
+ r.EncodeNil()
+ } else {
+ yym74 := z.EncBinary()
+ _ = yym74
+ if false {
+ } else if yym75 := z.TimeRtidIfBinc(); yym75 != 0 {
+ r.EncodeBuiltin(yym75, x.Expiration)
+ } else if z.HasExtensions() && z.EncExt(x.Expiration) {
+ } else if yym74 {
+ z.EncBinaryMarshal(x.Expiration)
+ } else if !yym74 && z.IsJSONHandle() {
+ z.EncJSONMarshal(x.Expiration)
+ } else {
+ z.EncFallback(x.Expiration)
+ }
+ }
+ }
+ }
+ if yyr61 || yy2arr61 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ if yyq61[4] {
+ yym77 := z.EncBinary()
+ _ = yym77
+ if false {
+ } else {
+ r.EncodeInt(int64(x.TTL))
+ }
+ } else {
+ r.EncodeInt(0)
+ }
+ } else {
+ if yyq61[4] {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("ttl"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ yym78 := z.EncBinary()
+ _ = yym78
+ if false {
+ } else {
+ r.EncodeInt(int64(x.TTL))
+ }
+ }
+ }
+ if yyr61 || yy2arr61 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ if yyq61[5] {
+ if x.Nodes == nil {
+ r.EncodeNil()
+ } else {
+ x.Nodes.CodecEncodeSelf(e)
+ }
+ } else {
+ r.EncodeNil()
+ }
+ } else {
+ if yyq61[5] {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("nodes"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ if x.Nodes == nil {
+ r.EncodeNil()
+ } else {
+ x.Nodes.CodecEncodeSelf(e)
+ }
+ }
+ }
+ if yyr61 || yy2arr61 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ if yyq61[6] {
+ yym81 := z.EncBinary()
+ _ = yym81
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.ModifiedIndex))
+ }
+ } else {
+ r.EncodeUint(0)
+ }
+ } else {
+ if yyq61[6] {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("modifiedIndex"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ yym82 := z.EncBinary()
+ _ = yym82
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.ModifiedIndex))
+ }
+ }
+ }
+ if yyr61 || yy2arr61 {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ if yyq61[7] {
+ yym84 := z.EncBinary()
+ _ = yym84
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.CreatedIndex))
+ }
+ } else {
+ r.EncodeUint(0)
+ }
+ } else {
+ if yyq61[7] {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ r.EncodeString(codecSelferC_UTF81978, string("createdIndex"))
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ yym85 := z.EncBinary()
+ _ = yym85
+ if false {
+ } else {
+ r.EncodeUint(uint64(x.CreatedIndex))
+ }
+ }
+ }
+ if yyr61 || yy2arr61 {
+ z.EncSendContainerState(codecSelfer_containerArrayEnd1978)
+ } else {
+ z.EncSendContainerState(codecSelfer_containerMapEnd1978)
+ }
+ }
+ }
+}
+
+func (x *Node) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym86 := z.DecBinary()
+ _ = yym86
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ yyct87 := r.ContainerType()
+ if yyct87 == codecSelferValueTypeMap1978 {
+ yyl87 := r.ReadMapStart()
+ if yyl87 == 0 {
+ z.DecSendContainerState(codecSelfer_containerMapEnd1978)
+ } else {
+ x.codecDecodeSelfFromMap(yyl87, d)
+ }
+ } else if yyct87 == codecSelferValueTypeArray1978 {
+ yyl87 := r.ReadArrayStart()
+ if yyl87 == 0 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ } else {
+ x.codecDecodeSelfFromArray(yyl87, d)
+ }
+ } else {
+ panic(codecSelferOnlyMapOrArrayEncodeToStructErr1978)
+ }
+ }
+}
+
+func (x *Node) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yys88Slc = z.DecScratchBuffer() // default slice to decode into
+ _ = yys88Slc
+ var yyhl88 bool = l >= 0
+ for yyj88 := 0; ; yyj88++ {
+ if yyhl88 {
+ if yyj88 >= l {
+ break
+ }
+ } else {
+ if r.CheckBreak() {
+ break
+ }
+ }
+ z.DecSendContainerState(codecSelfer_containerMapKey1978)
+ yys88Slc = r.DecodeBytes(yys88Slc, true, true)
+ yys88 := string(yys88Slc)
+ z.DecSendContainerState(codecSelfer_containerMapValue1978)
+ switch yys88 {
+ case "key":
+ if r.TryDecodeAsNil() {
+ x.Key = ""
+ } else {
+ x.Key = string(r.DecodeString())
+ }
+ case "value":
+ if r.TryDecodeAsNil() {
+ x.Value = ""
+ } else {
+ x.Value = string(r.DecodeString())
+ }
+ case "dir":
+ if r.TryDecodeAsNil() {
+ x.Dir = false
+ } else {
+ x.Dir = bool(r.DecodeBool())
+ }
+ case "expiration":
+ if r.TryDecodeAsNil() {
+ if x.Expiration != nil {
+ x.Expiration = nil
+ }
+ } else {
+ if x.Expiration == nil {
+ x.Expiration = new(time.Time)
+ }
+ yym93 := z.DecBinary()
+ _ = yym93
+ if false {
+ } else if yym94 := z.TimeRtidIfBinc(); yym94 != 0 {
+ r.DecodeBuiltin(yym94, x.Expiration)
+ } else if z.HasExtensions() && z.DecExt(x.Expiration) {
+ } else if yym93 {
+ z.DecBinaryUnmarshal(x.Expiration)
+ } else if !yym93 && z.IsJSONHandle() {
+ z.DecJSONUnmarshal(x.Expiration)
+ } else {
+ z.DecFallback(x.Expiration, false)
+ }
+ }
+ case "ttl":
+ if r.TryDecodeAsNil() {
+ x.TTL = 0
+ } else {
+ x.TTL = int64(r.DecodeInt(64))
+ }
+ case "nodes":
+ if r.TryDecodeAsNil() {
+ x.Nodes = nil
+ } else {
+ yyv96 := &x.Nodes
+ yyv96.CodecDecodeSelf(d)
+ }
+ case "modifiedIndex":
+ if r.TryDecodeAsNil() {
+ x.ModifiedIndex = 0
+ } else {
+ x.ModifiedIndex = uint64(r.DecodeUint(64))
+ }
+ case "createdIndex":
+ if r.TryDecodeAsNil() {
+ x.CreatedIndex = 0
+ } else {
+ x.CreatedIndex = uint64(r.DecodeUint(64))
+ }
+ default:
+ z.DecStructFieldNotFound(-1, yys88)
+ } // end switch yys88
+ } // end for yyj88
+ z.DecSendContainerState(codecSelfer_containerMapEnd1978)
+}
+
+func (x *Node) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ var yyj99 int
+ var yyb99 bool
+ var yyhl99 bool = l >= 0
+ yyj99++
+ if yyhl99 {
+ yyb99 = yyj99 > l
+ } else {
+ yyb99 = r.CheckBreak()
+ }
+ if yyb99 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ x.Key = ""
+ } else {
+ x.Key = string(r.DecodeString())
+ }
+ yyj99++
+ if yyhl99 {
+ yyb99 = yyj99 > l
+ } else {
+ yyb99 = r.CheckBreak()
+ }
+ if yyb99 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ x.Value = ""
+ } else {
+ x.Value = string(r.DecodeString())
+ }
+ yyj99++
+ if yyhl99 {
+ yyb99 = yyj99 > l
+ } else {
+ yyb99 = r.CheckBreak()
+ }
+ if yyb99 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ x.Dir = false
+ } else {
+ x.Dir = bool(r.DecodeBool())
+ }
+ yyj99++
+ if yyhl99 {
+ yyb99 = yyj99 > l
+ } else {
+ yyb99 = r.CheckBreak()
+ }
+ if yyb99 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ if x.Expiration != nil {
+ x.Expiration = nil
+ }
+ } else {
+ if x.Expiration == nil {
+ x.Expiration = new(time.Time)
+ }
+ yym104 := z.DecBinary()
+ _ = yym104
+ if false {
+ } else if yym105 := z.TimeRtidIfBinc(); yym105 != 0 {
+ r.DecodeBuiltin(yym105, x.Expiration)
+ } else if z.HasExtensions() && z.DecExt(x.Expiration) {
+ } else if yym104 {
+ z.DecBinaryUnmarshal(x.Expiration)
+ } else if !yym104 && z.IsJSONHandle() {
+ z.DecJSONUnmarshal(x.Expiration)
+ } else {
+ z.DecFallback(x.Expiration, false)
+ }
+ }
+ yyj99++
+ if yyhl99 {
+ yyb99 = yyj99 > l
+ } else {
+ yyb99 = r.CheckBreak()
+ }
+ if yyb99 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ x.TTL = 0
+ } else {
+ x.TTL = int64(r.DecodeInt(64))
+ }
+ yyj99++
+ if yyhl99 {
+ yyb99 = yyj99 > l
+ } else {
+ yyb99 = r.CheckBreak()
+ }
+ if yyb99 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ x.Nodes = nil
+ } else {
+ yyv107 := &x.Nodes
+ yyv107.CodecDecodeSelf(d)
+ }
+ yyj99++
+ if yyhl99 {
+ yyb99 = yyj99 > l
+ } else {
+ yyb99 = r.CheckBreak()
+ }
+ if yyb99 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ x.ModifiedIndex = 0
+ } else {
+ x.ModifiedIndex = uint64(r.DecodeUint(64))
+ }
+ yyj99++
+ if yyhl99 {
+ yyb99 = yyj99 > l
+ } else {
+ yyb99 = r.CheckBreak()
+ }
+ if yyb99 {
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+ return
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ if r.TryDecodeAsNil() {
+ x.CreatedIndex = 0
+ } else {
+ x.CreatedIndex = uint64(r.DecodeUint(64))
+ }
+ for {
+ yyj99++
+ if yyhl99 {
+ yyb99 = yyj99 > l
+ } else {
+ yyb99 = r.CheckBreak()
+ }
+ if yyb99 {
+ break
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayElem1978)
+ z.DecStructFieldNotFound(yyj99-1, "")
+ }
+ z.DecSendContainerState(codecSelfer_containerArrayEnd1978)
+}
+
+func (x Nodes) CodecEncodeSelf(e *codec1978.Encoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ if x == nil {
+ r.EncodeNil()
+ } else {
+ yym110 := z.EncBinary()
+ _ = yym110
+ if false {
+ } else if z.HasExtensions() && z.EncExt(x) {
+ } else {
+ h.encNodes((Nodes)(x), e)
+ }
+ }
+}
+
+func (x *Nodes) CodecDecodeSelf(d *codec1978.Decoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+ yym111 := z.DecBinary()
+ _ = yym111
+ if false {
+ } else if z.HasExtensions() && z.DecExt(x) {
+ } else {
+ h.decNodes((*Nodes)(x), d)
+ }
+}
+
+func (x codecSelfer1978) enchttp_Header(v pkg1_http.Header, e *codec1978.Encoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ r.EncodeMapStart(len(v))
+ for yyk112, yyv112 := range v {
+ z.EncSendContainerState(codecSelfer_containerMapKey1978)
+ yym113 := z.EncBinary()
+ _ = yym113
+ if false {
+ } else {
+ r.EncodeString(codecSelferC_UTF81978, string(yyk112))
+ }
+ z.EncSendContainerState(codecSelfer_containerMapValue1978)
+ if yyv112 == nil {
+ r.EncodeNil()
+ } else {
+ yym114 := z.EncBinary()
+ _ = yym114
+ if false {
+ } else {
+ z.F.EncSliceStringV(yyv112, false, e)
+ }
+ }
+ }
+ z.EncSendContainerState(codecSelfer_containerMapEnd1978)
+}
+
+func (x codecSelfer1978) dechttp_Header(v *pkg1_http.Header, d *codec1978.Decoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+
+ yyv115 := *v
+ yyl115 := r.ReadMapStart()
+ yybh115 := z.DecBasicHandle()
+ if yyv115 == nil {
+ yyrl115, _ := z.DecInferLen(yyl115, yybh115.MaxInitLen, 40)
+ yyv115 = make(map[string][]string, yyrl115)
+ *v = yyv115
+ }
+ var yymk115 string
+ var yymv115 []string
+ var yymg115 bool
+ if yybh115.MapValueReset {
+ yymg115 = true
+ }
+ if yyl115 > 0 {
+ for yyj115 := 0; yyj115 < yyl115; yyj115++ {
+ z.DecSendContainerState(codecSelfer_containerMapKey1978)
+ if r.TryDecodeAsNil() {
+ yymk115 = ""
+ } else {
+ yymk115 = string(r.DecodeString())
+ }
+
+ if yymg115 {
+ yymv115 = yyv115[yymk115]
+ } else {
+ yymv115 = nil
+ }
+ z.DecSendContainerState(codecSelfer_containerMapValue1978)
+ if r.TryDecodeAsNil() {
+ yymv115 = nil
+ } else {
+ yyv117 := &yymv115
+ yym118 := z.DecBinary()
+ _ = yym118
+ if false {
+ } else {
+ z.F.DecSliceStringX(yyv117, false, d)
+ }
+ }
+
+ if yyv115 != nil {
+ yyv115[yymk115] = yymv115
+ }
+ }
+ } else if yyl115 < 0 {
+ for yyj115 := 0; !r.CheckBreak(); yyj115++ {
+ z.DecSendContainerState(codecSelfer_containerMapKey1978)
+ if r.TryDecodeAsNil() {
+ yymk115 = ""
+ } else {
+ yymk115 = string(r.DecodeString())
+ }
+
+ if yymg115 {
+ yymv115 = yyv115[yymk115]
+ } else {
+ yymv115 = nil
+ }
+ z.DecSendContainerState(codecSelfer_containerMapValue1978)
+ if r.TryDecodeAsNil() {
+ yymv115 = nil
+ } else {
+ yyv120 := &yymv115
+ yym121 := z.DecBinary()
+ _ = yym121
+ if false {
+ } else {
+ z.F.DecSliceStringX(yyv120, false, d)
+ }
+ }
+
+ if yyv115 != nil {
+ yyv115[yymk115] = yymv115
+ }
+ }
+ } // else len==0: TODO: Should we clear map entries?
+ z.DecSendContainerState(codecSelfer_containerMapEnd1978)
+}
+
+func (x codecSelfer1978) encNodes(v Nodes, e *codec1978.Encoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperEncoder(e)
+ _, _, _ = h, z, r
+ r.EncodeArrayStart(len(v))
+ for _, yyv122 := range v {
+ z.EncSendContainerState(codecSelfer_containerArrayElem1978)
+ if yyv122 == nil {
+ r.EncodeNil()
+ } else {
+ yyv122.CodecEncodeSelf(e)
+ }
+ }
+ z.EncSendContainerState(codecSelfer_containerArrayEnd1978)
+}
+
+func (x codecSelfer1978) decNodes(v *Nodes, d *codec1978.Decoder) {
+ var h codecSelfer1978
+ z, r := codec1978.GenHelperDecoder(d)
+ _, _, _ = h, z, r
+
+ yyv123 := *v
+ yyh123, yyl123 := z.DecSliceHelperStart()
+ var yyc123 bool
+ if yyl123 == 0 {
+ if yyv123 == nil {
+ yyv123 = []*Node{}
+ yyc123 = true
+ } else if len(yyv123) != 0 {
+ yyv123 = yyv123[:0]
+ yyc123 = true
+ }
+ } else if yyl123 > 0 {
+ var yyrr123, yyrl123 int
+ var yyrt123 bool
+ if yyl123 > cap(yyv123) {
+
+ yyrg123 := len(yyv123) > 0
+ yyv2123 := yyv123
+ yyrl123, yyrt123 = z.DecInferLen(yyl123, z.DecBasicHandle().MaxInitLen, 8)
+ if yyrt123 {
+ if yyrl123 <= cap(yyv123) {
+ yyv123 = yyv123[:yyrl123]
+ } else {
+ yyv123 = make([]*Node, yyrl123)
+ }
+ } else {
+ yyv123 = make([]*Node, yyrl123)
+ }
+ yyc123 = true
+ yyrr123 = len(yyv123)
+ if yyrg123 {
+ copy(yyv123, yyv2123)
+ }
+ } else if yyl123 != len(yyv123) {
+ yyv123 = yyv123[:yyl123]
+ yyc123 = true
+ }
+ yyj123 := 0
+ for ; yyj123 < yyrr123; yyj123++ {
+ yyh123.ElemContainerState(yyj123)
+ if r.TryDecodeAsNil() {
+ if yyv123[yyj123] != nil {
+ *yyv123[yyj123] = Node{}
+ }
+ } else {
+ if yyv123[yyj123] == nil {
+ yyv123[yyj123] = new(Node)
+ }
+ yyw124 := yyv123[yyj123]
+ yyw124.CodecDecodeSelf(d)
+ }
+
+ }
+ if yyrt123 {
+ for ; yyj123 < yyl123; yyj123++ {
+ yyv123 = append(yyv123, nil)
+ yyh123.ElemContainerState(yyj123)
+ if r.TryDecodeAsNil() {
+ if yyv123[yyj123] != nil {
+ *yyv123[yyj123] = Node{}
+ }
+ } else {
+ if yyv123[yyj123] == nil {
+ yyv123[yyj123] = new(Node)
+ }
+ yyw125 := yyv123[yyj123]
+ yyw125.CodecDecodeSelf(d)
+ }
+
+ }
+ }
+
+ } else {
+ yyj123 := 0
+ for ; !r.CheckBreak(); yyj123++ {
+
+ if yyj123 >= len(yyv123) {
+ yyv123 = append(yyv123, nil) // var yyz123 *Node
+ yyc123 = true
+ }
+ yyh123.ElemContainerState(yyj123)
+ if yyj123 < len(yyv123) {
+ if r.TryDecodeAsNil() {
+ if yyv123[yyj123] != nil {
+ *yyv123[yyj123] = Node{}
+ }
+ } else {
+ if yyv123[yyj123] == nil {
+ yyv123[yyj123] = new(Node)
+ }
+ yyw126 := yyv123[yyj123]
+ yyw126.CodecDecodeSelf(d)
+ }
+
+ } else {
+ z.DecSwallow()
+ }
+
+ }
+ if yyj123 < len(yyv123) {
+ yyv123 = yyv123[:yyj123]
+ yyc123 = true
+ } else if yyj123 == 0 && yyv123 == nil {
+ yyv123 = []*Node{}
+ yyc123 = true
+ }
+ }
+ yyh123.End()
+ if yyc123 {
+ *v = yyv123
+ }
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/response.go b/vendor/github.com/coreos/go-etcd/etcd/response.go
new file mode 100644
index 0000000000..69b38be46e
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/response.go
@@ -0,0 +1,93 @@
+package etcd
+
+//go:generate codecgen -d 1978 -o response.generated.go response.go
+
+import (
+ "net/http"
+ "strconv"
+ "time"
+
+ "github.com/ugorji/go/codec"
+)
+
+const (
+ rawResponse = iota
+ normalResponse
+)
+
+type responseType int
+
+type RawResponse struct {
+ StatusCode int
+ Body []byte
+ Header http.Header
+}
+
+var (
+ validHttpStatusCode = map[int]bool{
+ http.StatusCreated: true,
+ http.StatusOK: true,
+ http.StatusBadRequest: true,
+ http.StatusNotFound: true,
+ http.StatusPreconditionFailed: true,
+ http.StatusForbidden: true,
+ http.StatusUnauthorized: true,
+ }
+)
+
+// Unmarshal parses RawResponse and stores the result in Response
+func (rr *RawResponse) Unmarshal() (*Response, error) {
+ if rr.StatusCode != http.StatusOK && rr.StatusCode != http.StatusCreated {
+ return nil, handleError(rr.Body)
+ }
+
+ resp := new(Response)
+
+ err := codec.NewDecoderBytes(rr.Body, new(codec.JsonHandle)).Decode(resp)
+
+ if err != nil {
+ return nil, err
+ }
+
+ // attach index and term to response
+ resp.EtcdIndex, _ = strconv.ParseUint(rr.Header.Get("X-Etcd-Index"), 10, 64)
+ resp.RaftIndex, _ = strconv.ParseUint(rr.Header.Get("X-Raft-Index"), 10, 64)
+ resp.RaftTerm, _ = strconv.ParseUint(rr.Header.Get("X-Raft-Term"), 10, 64)
+
+ return resp, nil
+}
+
+type Response struct {
+ Action string `json:"action"`
+ Node *Node `json:"node"`
+ PrevNode *Node `json:"prevNode,omitempty"`
+ EtcdIndex uint64 `json:"etcdIndex"`
+ RaftIndex uint64 `json:"raftIndex"`
+ RaftTerm uint64 `json:"raftTerm"`
+}
+
+type Node struct {
+ Key string `json:"key, omitempty"`
+ Value string `json:"value,omitempty"`
+ Dir bool `json:"dir,omitempty"`
+ Expiration *time.Time `json:"expiration,omitempty"`
+ TTL int64 `json:"ttl,omitempty"`
+ Nodes Nodes `json:"nodes,omitempty"`
+ ModifiedIndex uint64 `json:"modifiedIndex,omitempty"`
+ CreatedIndex uint64 `json:"createdIndex,omitempty"`
+}
+
+type Nodes []*Node
+
+// interfaces for sorting
+func (ns Nodes) Len() int {
+ return len(ns)
+}
+
+func (ns Nodes) Less(i, j int) bool {
+ return ns[i].Key < ns[j].Key
+}
+
+func (ns Nodes) Swap(i, j int) {
+ ns[i], ns[j] = ns[j], ns[i]
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/set_update_create.go b/vendor/github.com/coreos/go-etcd/etcd/set_update_create.go
new file mode 100644
index 0000000000..e2840cf356
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/set_update_create.go
@@ -0,0 +1,137 @@
+package etcd
+
+// Set sets the given key to the given value.
+// It will create a new key value pair or replace the old one.
+// It will not replace a existing directory.
+func (c *Client) Set(key string, value string, ttl uint64) (*Response, error) {
+ raw, err := c.RawSet(key, value, ttl)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return raw.Unmarshal()
+}
+
+// SetDir sets the given key to a directory.
+// It will create a new directory or replace the old key value pair by a directory.
+// It will not replace a existing directory.
+func (c *Client) SetDir(key string, ttl uint64) (*Response, error) {
+ raw, err := c.RawSetDir(key, ttl)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return raw.Unmarshal()
+}
+
+// CreateDir creates a directory. It succeeds only if
+// the given key does not yet exist.
+func (c *Client) CreateDir(key string, ttl uint64) (*Response, error) {
+ raw, err := c.RawCreateDir(key, ttl)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return raw.Unmarshal()
+}
+
+// UpdateDir updates the given directory. It succeeds only if the
+// given key already exists.
+func (c *Client) UpdateDir(key string, ttl uint64) (*Response, error) {
+ raw, err := c.RawUpdateDir(key, ttl)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return raw.Unmarshal()
+}
+
+// Create creates a file with the given value under the given key. It succeeds
+// only if the given key does not yet exist.
+func (c *Client) Create(key string, value string, ttl uint64) (*Response, error) {
+ raw, err := c.RawCreate(key, value, ttl)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return raw.Unmarshal()
+}
+
+// CreateInOrder creates a file with a key that's guaranteed to be higher than other
+// keys in the given directory. It is useful for creating queues.
+func (c *Client) CreateInOrder(dir string, value string, ttl uint64) (*Response, error) {
+ raw, err := c.RawCreateInOrder(dir, value, ttl)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return raw.Unmarshal()
+}
+
+// Update updates the given key to the given value. It succeeds only if the
+// given key already exists.
+func (c *Client) Update(key string, value string, ttl uint64) (*Response, error) {
+ raw, err := c.RawUpdate(key, value, ttl)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return raw.Unmarshal()
+}
+
+func (c *Client) RawUpdateDir(key string, ttl uint64) (*RawResponse, error) {
+ ops := Options{
+ "prevExist": true,
+ "dir": true,
+ }
+
+ return c.put(key, "", ttl, ops)
+}
+
+func (c *Client) RawCreateDir(key string, ttl uint64) (*RawResponse, error) {
+ ops := Options{
+ "prevExist": false,
+ "dir": true,
+ }
+
+ return c.put(key, "", ttl, ops)
+}
+
+func (c *Client) RawSet(key string, value string, ttl uint64) (*RawResponse, error) {
+ return c.put(key, value, ttl, nil)
+}
+
+func (c *Client) RawSetDir(key string, ttl uint64) (*RawResponse, error) {
+ ops := Options{
+ "dir": true,
+ }
+
+ return c.put(key, "", ttl, ops)
+}
+
+func (c *Client) RawUpdate(key string, value string, ttl uint64) (*RawResponse, error) {
+ ops := Options{
+ "prevExist": true,
+ }
+
+ return c.put(key, value, ttl, ops)
+}
+
+func (c *Client) RawCreate(key string, value string, ttl uint64) (*RawResponse, error) {
+ ops := Options{
+ "prevExist": false,
+ }
+
+ return c.put(key, value, ttl, ops)
+}
+
+func (c *Client) RawCreateInOrder(dir string, value string, ttl uint64) (*RawResponse, error) {
+ return c.post(dir, value, ttl)
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/shuffle.go b/vendor/github.com/coreos/go-etcd/etcd/shuffle.go
new file mode 100644
index 0000000000..c26ddac30c
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/shuffle.go
@@ -0,0 +1,19 @@
+package etcd
+
+import (
+ "math/rand"
+)
+
+func shuffleStringSlice(cards []string) []string {
+ size := len(cards)
+ //Do not need to copy if nothing changed
+ if size <= 1 {
+ return cards
+ }
+ shuffled := make([]string, size)
+ index := rand.Perm(size)
+ for i := range cards {
+ shuffled[index[i]] = cards[i]
+ }
+ return shuffled
+}
diff --git a/vendor/github.com/coreos/go-etcd/etcd/version.go b/vendor/github.com/coreos/go-etcd/etcd/version.go
new file mode 100644
index 0000000000..b1e9ed2713
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/version.go
@@ -0,0 +1,6 @@
+package etcd
+
+const (
+ version = "v2"
+ packageVersion = "v2.0.0+git"
+)
diff --git a/vendor/github.com/coreos/go-etcd/etcd/watch.go b/vendor/github.com/coreos/go-etcd/etcd/watch.go
new file mode 100644
index 0000000000..aa8d3df301
--- /dev/null
+++ b/vendor/github.com/coreos/go-etcd/etcd/watch.go
@@ -0,0 +1,103 @@
+package etcd
+
+import (
+ "errors"
+)
+
+// Errors introduced by the Watch command.
+var (
+ ErrWatchStoppedByUser = errors.New("Watch stopped by the user via stop channel")
+)
+
+// If recursive is set to true the watch returns the first change under the given
+// prefix since the given index.
+//
+// If recursive is set to false the watch returns the first change to the given key
+// since the given index.
+//
+// To watch for the latest change, set waitIndex = 0.
+//
+// If a receiver channel is given, it will be a long-term watch. Watch will block at the
+//channel. After someone receives the channel, it will go on to watch that
+// prefix. If a stop channel is given, the client can close long-term watch using
+// the stop channel.
+func (c *Client) Watch(prefix string, waitIndex uint64, recursive bool,
+ receiver chan *Response, stop chan bool) (*Response, error) {
+ logger.Debugf("watch %s [%s]", prefix, c.cluster.Leader)
+ if receiver == nil {
+ raw, err := c.watchOnce(prefix, waitIndex, recursive, stop)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return raw.Unmarshal()
+ }
+ defer close(receiver)
+
+ for {
+ raw, err := c.watchOnce(prefix, waitIndex, recursive, stop)
+
+ if err != nil {
+ return nil, err
+ }
+
+ resp, err := raw.Unmarshal()
+
+ if err != nil {
+ return nil, err
+ }
+
+ waitIndex = resp.Node.ModifiedIndex + 1
+ receiver <- resp
+ }
+}
+
+func (c *Client) RawWatch(prefix string, waitIndex uint64, recursive bool,
+ receiver chan *RawResponse, stop chan bool) (*RawResponse, error) {
+
+ logger.Debugf("rawWatch %s [%s]", prefix, c.cluster.Leader)
+ if receiver == nil {
+ return c.watchOnce(prefix, waitIndex, recursive, stop)
+ }
+
+ for {
+ raw, err := c.watchOnce(prefix, waitIndex, recursive, stop)
+
+ if err != nil {
+ return nil, err
+ }
+
+ resp, err := raw.Unmarshal()
+
+ if err != nil {
+ return nil, err
+ }
+
+ waitIndex = resp.Node.ModifiedIndex + 1
+ receiver <- raw
+ }
+}
+
+// helper func
+// return when there is change under the given prefix
+func (c *Client) watchOnce(key string, waitIndex uint64, recursive bool, stop chan bool) (*RawResponse, error) {
+
+ options := Options{
+ "wait": true,
+ }
+ if waitIndex > 0 {
+ options["waitIndex"] = waitIndex
+ }
+ if recursive {
+ options["recursive"] = true
+ }
+
+ resp, err := c.getCancelable(key, options, stop)
+
+ if err == ErrRequestCancelled {
+ return nil, ErrWatchStoppedByUser
+ }
+
+ return resp, err
+}