summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/armon
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-08-06 21:47:05 +0200
committerWim <wim@42.be>2018-08-06 21:47:05 +0200
commit51062863a5c34d81e296cf15c61140911037cf3b (patch)
tree9b5e044672486326c7a0ca8fb26430f37bf4d83c /vendor/github.com/armon
parent4fb4b7aa6c02a54db8ad8dd98e4d321396926c0d (diff)
downloadmatterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.gz
matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.bz2
matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.zip
Use mod vendor for vendored directory (backwards compatible)
Diffstat (limited to 'vendor/github.com/armon')
-rw-r--r--vendor/github.com/armon/consul-api/LICENSE362
-rw-r--r--vendor/github.com/armon/consul-api/acl.go140
-rw-r--r--vendor/github.com/armon/consul-api/agent.go272
-rw-r--r--vendor/github.com/armon/consul-api/api.go323
-rw-r--r--vendor/github.com/armon/consul-api/catalog.go181
-rw-r--r--vendor/github.com/armon/consul-api/event.go104
-rw-r--r--vendor/github.com/armon/consul-api/health.go136
-rw-r--r--vendor/github.com/armon/consul-api/kv.go219
-rw-r--r--vendor/github.com/armon/consul-api/session.go204
-rw-r--r--vendor/github.com/armon/consul-api/status.go43
10 files changed, 0 insertions, 1984 deletions
diff --git a/vendor/github.com/armon/consul-api/LICENSE b/vendor/github.com/armon/consul-api/LICENSE
deleted file mode 100644
index f0e5c79e..00000000
--- a/vendor/github.com/armon/consul-api/LICENSE
+++ /dev/null
@@ -1,362 +0,0 @@
-Mozilla Public License, version 2.0
-
-1. Definitions
-
-1.1. "Contributor"
-
- means each individual or legal entity that creates, contributes to the
- creation of, or owns Covered Software.
-
-1.2. "Contributor Version"
-
- means the combination of the Contributions of others (if any) used by a
- Contributor and that particular Contributor's Contribution.
-
-1.3. "Contribution"
-
- means Covered Software of a particular Contributor.
-
-1.4. "Covered Software"
-
- means Source Code Form to which the initial Contributor has attached the
- notice in Exhibit A, the Executable Form of such Source Code Form, and
- Modifications of such Source Code Form, in each case including portions
- thereof.
-
-1.5. "Incompatible With Secondary Licenses"
- means
-
- a. that the initial Contributor has attached the notice described in
- Exhibit B to the Covered Software; or
-
- b. that the Covered Software was made available under the terms of
- version 1.1 or earlier of the License, but not also under the terms of
- a Secondary License.
-
-1.6. "Executable Form"
-
- means any form of the work other than Source Code Form.
-
-1.7. "Larger Work"
-
- means a work that combines Covered Software with other material, in a
- separate file or files, that is not Covered Software.
-
-1.8. "License"
-
- means this document.
-
-1.9. "Licensable"
-
- means having the right to grant, to the maximum extent possible, whether
- at the time of the initial grant or subsequently, any and all of the
- rights conveyed by this License.
-
-1.10. "Modifications"
-
- means any of the following:
-
- a. any file in Source Code Form that results from an addition to,
- deletion from, or modification of the contents of Covered Software; or
-
- b. any new file in Source Code Form that contains any Covered Software.
-
-1.11. "Patent Claims" of a Contributor
-
- means any patent claim(s), including without limitation, method,
- process, and apparatus claims, in any patent Licensable by such
- Contributor that would be infringed, but for the grant of the License,
- by the making, using, selling, offering for sale, having made, import,
- or transfer of either its Contributions or its Contributor Version.
-
-1.12. "Secondary License"
-
- means either the GNU General Public License, Version 2.0, the GNU Lesser
- General Public License, Version 2.1, the GNU Affero General Public
- License, Version 3.0, or any later versions of those licenses.
-
-1.13. "Source Code Form"
-
- means the form of the work preferred for making modifications.
-
-1.14. "You" (or "Your")
-
- means an individual or a legal entity exercising rights under this
- License. For legal entities, "You" includes any entity that controls, is
- controlled by, or is under common control with You. For purposes of this
- definition, "control" means (a) the power, direct or indirect, to cause
- the direction or management of such entity, whether by contract or
- otherwise, or (b) ownership of more than fifty percent (50%) of the
- outstanding shares or beneficial ownership of such entity.
-
-
-2. License Grants and Conditions
-
-2.1. Grants
-
- Each Contributor hereby grants You a world-wide, royalty-free,
- non-exclusive license:
-
- a. under intellectual property rights (other than patent or trademark)
- Licensable by such Contributor to use, reproduce, make available,
- modify, display, perform, distribute, and otherwise exploit its
- Contributions, either on an unmodified basis, with Modifications, or
- as part of a Larger Work; and
-
- b. under Patent Claims of such Contributor to make, use, sell, offer for
- sale, have made, import, and otherwise transfer either its
- Contributions or its Contributor Version.
-
-2.2. Effective Date
-
- The licenses granted in Section 2.1 with respect to any Contribution
- become effective for each Contribution on the date the Contributor first
- distributes such Contribution.
-
-2.3. Limitations on Grant Scope
-
- The licenses granted in this Section 2 are the only rights granted under
- this License. No additional rights or licenses will be implied from the
- distribution or licensing of Covered Software under this License.
- Notwithstanding Section 2.1(b) above, no patent license is granted by a
- Contributor:
-
- a. for any code that a Contributor has removed from Covered Software; or
-
- b. for infringements caused by: (i) Your and any other third party's
- modifications of Covered Software, or (ii) the combination of its
- Contributions with other software (except as part of its Contributor
- Version); or
-
- c. under Patent Claims infringed by Covered Software in the absence of
- its Contributions.
-
- This License does not grant any rights in the trademarks, service marks,
- or logos of any Contributor (except as may be necessary to comply with
- the notice requirements in Section 3.4).
-
-2.4. Subsequent Licenses
-
- No Contributor makes additional grants as a result of Your choice to
- distribute the Covered Software under a subsequent version of this
- License (see Section 10.2) or under the terms of a Secondary License (if
- permitted under the terms of Section 3.3).
-
-2.5. Representation
-
- Each Contributor represents that the Contributor believes its
- Contributions are its original creation(s) or it has sufficient rights to
- grant the rights to its Contributions conveyed by this License.
-
-2.6. Fair Use
-
- This License is not intended to limit any rights You have under
- applicable copyright doctrines of fair use, fair dealing, or other
- equivalents.
-
-2.7. Conditions
-
- Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
- Section 2.1.
-
-
-3. Responsibilities
-
-3.1. Distribution of Source Form
-
- All distribution of Covered Software in Source Code Form, including any
- Modifications that You create or to which You contribute, must be under
- the terms of this License. You must inform recipients that the Source
- Code Form of the Covered Software is governed by the terms of this
- License, and how they can obtain a copy of this License. You may not
- attempt to alter or restrict the recipients' rights in the Source Code
- Form.
-
-3.2. Distribution of Executable Form
-
- If You distribute Covered Software in Executable Form then:
-
- a. such Covered Software must also be made available in Source Code Form,
- as described in Section 3.1, and You must inform recipients of the
- Executable Form how they can obtain a copy of such Source Code Form by
- reasonable means in a timely manner, at a charge no more than the cost
- of distribution to the recipient; and
-
- b. You may distribute such Executable Form under the terms of this
- License, or sublicense it under different terms, provided that the
- license for the Executable Form does not attempt to limit or alter the
- recipients' rights in the Source Code Form under this License.
-
-3.3. Distribution of a Larger Work
-
- You may create and distribute a Larger Work under terms of Your choice,
- provided that You also comply with the requirements of this License for
- the Covered Software. If the Larger Work is a combination of Covered
- Software with a work governed by one or more Secondary Licenses, and the
- Covered Software is not Incompatible With Secondary Licenses, this
- License permits You to additionally distribute such Covered Software
- under the terms of such Secondary License(s), so that the recipient of
- the Larger Work may, at their option, further distribute the Covered
- Software under the terms of either this License or such Secondary
- License(s).
-
-3.4. Notices
-
- You may not remove or alter the substance of any license notices
- (including copyright notices, patent notices, disclaimers of warranty, or
- limitations of liability) contained within the Source Code Form of the
- Covered Software, except that You may alter any license notices to the
- extent required to remedy known factual inaccuracies.
-
-3.5. Application of Additional Terms
-
- You may choose to offer, and to charge a fee for, warranty, support,
- indemnity or liability obligations to one or more recipients of Covered
- Software. However, You may do so only on Your own behalf, and not on
- behalf of any Contributor. You must make it absolutely clear that any
- such warranty, support, indemnity, or liability obligation is offered by
- You alone, and You hereby agree to indemnify every Contributor for any
- liability incurred by such Contributor as a result of warranty, support,
- indemnity or liability terms You offer. You may include additional
- disclaimers of warranty and limitations of liability specific to any
- jurisdiction.
-
-4. Inability to Comply Due to Statute or Regulation
-
- If it is impossible for You to comply with any of the terms of this License
- with respect to some or all of the Covered Software due to statute,
- judicial order, or regulation then You must: (a) comply with the terms of
- this License to the maximum extent possible; and (b) describe the
- limitations and the code they affect. Such description must be placed in a
- text file included with all distributions of the Covered Software under
- this License. Except to the extent prohibited by statute or regulation,
- such description must be sufficiently detailed for a recipient of ordinary
- skill to be able to understand it.
-
-5. Termination
-
-5.1. The rights granted under this License will terminate automatically if You
- fail to comply with any of its terms. However, if You become compliant,
- then the rights granted under this License from a particular Contributor
- are reinstated (a) provisionally, unless and until such Contributor
- explicitly and finally terminates Your grants, and (b) on an ongoing
- basis, if such Contributor fails to notify You of the non-compliance by
- some reasonable means prior to 60 days after You have come back into
- compliance. Moreover, Your grants from a particular Contributor are
- reinstated on an ongoing basis if such Contributor notifies You of the
- non-compliance by some reasonable means, this is the first time You have
- received notice of non-compliance with this License from such
- Contributor, and You become compliant prior to 30 days after Your receipt
- of the notice.
-
-5.2. If You initiate litigation against any entity by asserting a patent
- infringement claim (excluding declaratory judgment actions,
- counter-claims, and cross-claims) alleging that a Contributor Version
- directly or indirectly infringes any patent, then the rights granted to
- You by any and all Contributors for the Covered Software under Section
- 2.1 of this License shall terminate.
-
-5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
- license agreements (excluding distributors and resellers) which have been
- validly granted by You or Your distributors under this License prior to
- termination shall survive termination.
-
-6. Disclaimer of Warranty
-
- Covered Software is provided under this License on an "as is" basis,
- without warranty of any kind, either expressed, implied, or statutory,
- including, without limitation, warranties that the Covered Software is free
- of defects, merchantable, fit for a particular purpose or non-infringing.
- The entire risk as to the quality and performance of the Covered Software
- is with You. Should any Covered Software prove defective in any respect,
- You (not any Contributor) assume the cost of any necessary servicing,
- repair, or correction. This disclaimer of warranty constitutes an essential
- part of this License. No use of any Covered Software is authorized under
- this License except under this disclaimer.
-
-7. Limitation of Liability
-
- Under no circumstances and under no legal theory, whether tort (including
- negligence), contract, or otherwise, shall any Contributor, or anyone who
- distributes Covered Software as permitted above, be liable to You for any
- direct, indirect, special, incidental, or consequential damages of any
- character including, without limitation, damages for lost profits, loss of
- goodwill, work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses, even if such party shall have been
- informed of the possibility of such damages. This limitation of liability
- shall not apply to liability for death or personal injury resulting from
- such party's negligence to the extent applicable law prohibits such
- limitation. Some jurisdictions do not allow the exclusion or limitation of
- incidental or consequential damages, so this exclusion and limitation may
- not apply to You.
-
-8. Litigation
-
- Any litigation relating to this License may be brought only in the courts
- of a jurisdiction where the defendant maintains its principal place of
- business and such litigation shall be governed by laws of that
- jurisdiction, without reference to its conflict-of-law provisions. Nothing
- in this Section shall prevent a party's ability to bring cross-claims or
- counter-claims.
-
-9. Miscellaneous
-
- This License represents the complete agreement concerning the subject
- matter hereof. If any provision of this License is held to be
- unenforceable, such provision shall be reformed only to the extent
- necessary to make it enforceable. Any law or regulation which provides that
- the language of a contract shall be construed against the drafter shall not
- be used to construe this License against a Contributor.
-
-
-10. Versions of the License
-
-10.1. New Versions
-
- Mozilla Foundation is the license steward. Except as provided in Section
- 10.3, no one other than the license steward has the right to modify or
- publish new versions of this License. Each version will be given a
- distinguishing version number.
-
-10.2. Effect of New Versions
-
- You may distribute the Covered Software under the terms of the version
- of the License under which You originally received the Covered Software,
- or under the terms of any subsequent version published by the license
- steward.
-
-10.3. Modified Versions
-
- If you create software not governed by this License, and you want to
- create a new license for such software, you may create and use a
- modified version of this License if you rename the license and remove
- any references to the name of the license steward (except to note that
- such modified license differs from this License).
-
-10.4. Distributing Source Code Form that is Incompatible With Secondary
- Licenses If You choose to distribute Source Code Form that is
- Incompatible With Secondary Licenses under the terms of this version of
- the License, the notice described in Exhibit B of this License must be
- attached.
-
-Exhibit A - Source Code Form License Notice
-
- This Source Code Form is subject to the
- terms of the Mozilla Public License, v.
- 2.0. If a copy of the MPL was not
- distributed with this file, You can
- obtain one at
- http://mozilla.org/MPL/2.0/.
-
-If it is not possible or desirable to put the notice in a particular file,
-then You may include the notice in a location (such as a LICENSE file in a
-relevant directory) where a recipient would be likely to look for such a
-notice.
-
-You may add additional accurate notices of copyright ownership.
-
-Exhibit B - "Incompatible With Secondary Licenses" Notice
-
- This Source Code Form is "Incompatible
- With Secondary Licenses", as defined by
- the Mozilla Public License, v. 2.0. \ No newline at end of file
diff --git a/vendor/github.com/armon/consul-api/acl.go b/vendor/github.com/armon/consul-api/acl.go
deleted file mode 100644
index e0179f54..00000000
--- a/vendor/github.com/armon/consul-api/acl.go
+++ /dev/null
@@ -1,140 +0,0 @@
-package consulapi
-
-const (
- // ACLCLientType is the client type token
- ACLClientType = "client"
-
- // ACLManagementType is the management type token
- ACLManagementType = "management"
-)
-
-// ACLEntry is used to represent an ACL entry
-type ACLEntry struct {
- CreateIndex uint64
- ModifyIndex uint64
- ID string
- Name string
- Type string
- Rules string
-}
-
-// ACL can be used to query the ACL endpoints
-type ACL struct {
- c *Client
-}
-
-// ACL returns a handle to the ACL endpoints
-func (c *Client) ACL() *ACL {
- return &ACL{c}
-}
-
-// Create is used to generate a new token with the given parameters
-func (a *ACL) Create(acl *ACLEntry, q *WriteOptions) (string, *WriteMeta, error) {
- r := a.c.newRequest("PUT", "/v1/acl/create")
- r.setWriteOptions(q)
- r.obj = acl
- rtt, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return "", nil, err
- }
- defer resp.Body.Close()
-
- wm := &WriteMeta{RequestTime: rtt}
- var out struct{ ID string }
- if err := decodeBody(resp, &out); err != nil {
- return "", nil, err
- }
- return out.ID, wm, nil
-}
-
-// Update is used to update the rules of an existing token
-func (a *ACL) Update(acl *ACLEntry, q *WriteOptions) (*WriteMeta, error) {
- r := a.c.newRequest("PUT", "/v1/acl/update")
- r.setWriteOptions(q)
- r.obj = acl
- rtt, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return nil, err
- }
- defer resp.Body.Close()
-
- wm := &WriteMeta{RequestTime: rtt}
- return wm, nil
-}
-
-// Destroy is used to destroy a given ACL token ID
-func (a *ACL) Destroy(id string, q *WriteOptions) (*WriteMeta, error) {
- r := a.c.newRequest("PUT", "/v1/acl/destroy/"+id)
- r.setWriteOptions(q)
- rtt, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return nil, err
- }
- resp.Body.Close()
-
- wm := &WriteMeta{RequestTime: rtt}
- return wm, nil
-}
-
-// Clone is used to return a new token cloned from an existing one
-func (a *ACL) Clone(id string, q *WriteOptions) (string, *WriteMeta, error) {
- r := a.c.newRequest("PUT", "/v1/acl/clone/"+id)
- r.setWriteOptions(q)
- rtt, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return "", nil, err
- }
- defer resp.Body.Close()
-
- wm := &WriteMeta{RequestTime: rtt}
- var out struct{ ID string }
- if err := decodeBody(resp, &out); err != nil {
- return "", nil, err
- }
- return out.ID, wm, nil
-}
-
-// Info is used to query for information about an ACL token
-func (a *ACL) Info(id string, q *QueryOptions) (*ACLEntry, *QueryMeta, error) {
- r := a.c.newRequest("GET", "/v1/acl/info/"+id)
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var entries []*ACLEntry
- if err := decodeBody(resp, &entries); err != nil {
- return nil, nil, err
- }
- if len(entries) > 0 {
- return entries[0], qm, nil
- }
- return nil, qm, nil
-}
-
-// List is used to get all the ACL tokens
-func (a *ACL) List(q *QueryOptions) ([]*ACLEntry, *QueryMeta, error) {
- r := a.c.newRequest("GET", "/v1/acl/list")
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var entries []*ACLEntry
- if err := decodeBody(resp, &entries); err != nil {
- return nil, nil, err
- }
- return entries, qm, nil
-}
diff --git a/vendor/github.com/armon/consul-api/agent.go b/vendor/github.com/armon/consul-api/agent.go
deleted file mode 100644
index eec93cb9..00000000
--- a/vendor/github.com/armon/consul-api/agent.go
+++ /dev/null
@@ -1,272 +0,0 @@
-package consulapi
-
-import (
- "fmt"
-)
-
-// AgentCheck represents a check known to the agent
-type AgentCheck struct {
- Node string
- CheckID string
- Name string
- Status string
- Notes string
- Output string
- ServiceID string
- ServiceName string
-}
-
-// AgentService represents a service known to the agent
-type AgentService struct {
- ID string
- Service string
- Tags []string
- Port int
-}
-
-// AgentMember represents a cluster member known to the agent
-type AgentMember struct {
- Name string
- Addr string
- Port uint16
- Tags map[string]string
- Status int
- ProtocolMin uint8
- ProtocolMax uint8
- ProtocolCur uint8
- DelegateMin uint8
- DelegateMax uint8
- DelegateCur uint8
-}
-
-// AgentServiceRegistration is used to register a new service
-type AgentServiceRegistration struct {
- ID string `json:",omitempty"`
- Name string `json:",omitempty"`
- Tags []string `json:",omitempty"`
- Port int `json:",omitempty"`
- Check *AgentServiceCheck
-}
-
-// AgentCheckRegistration is used to register a new check
-type AgentCheckRegistration struct {
- ID string `json:",omitempty"`
- Name string `json:",omitempty"`
- Notes string `json:",omitempty"`
- AgentServiceCheck
-}
-
-// AgentServiceCheck is used to create an associated
-// check for a service
-type AgentServiceCheck struct {
- Script string `json:",omitempty"`
- Interval string `json:",omitempty"`
- TTL string `json:",omitempty"`
-}
-
-// Agent can be used to query the Agent endpoints
-type Agent struct {
- c *Client
-
- // cache the node name
- nodeName string
-}
-
-// Agent returns a handle to the agent endpoints
-func (c *Client) Agent() *Agent {
- return &Agent{c: c}
-}
-
-// Self is used to query the agent we are speaking to for
-// information about itself
-func (a *Agent) Self() (map[string]map[string]interface{}, error) {
- r := a.c.newRequest("GET", "/v1/agent/self")
- _, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return nil, err
- }
- defer resp.Body.Close()
-
- var out map[string]map[string]interface{}
- if err := decodeBody(resp, &out); err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// NodeName is used to get the node name of the agent
-func (a *Agent) NodeName() (string, error) {
- if a.nodeName != "" {
- return a.nodeName, nil
- }
- info, err := a.Self()
- if err != nil {
- return "", err
- }
- name := info["Config"]["NodeName"].(string)
- a.nodeName = name
- return name, nil
-}
-
-// Checks returns the locally registered checks
-func (a *Agent) Checks() (map[string]*AgentCheck, error) {
- r := a.c.newRequest("GET", "/v1/agent/checks")
- _, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return nil, err
- }
- defer resp.Body.Close()
-
- var out map[string]*AgentCheck
- if err := decodeBody(resp, &out); err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// Services returns the locally registered services
-func (a *Agent) Services() (map[string]*AgentService, error) {
- r := a.c.newRequest("GET", "/v1/agent/services")
- _, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return nil, err
- }
- defer resp.Body.Close()
-
- var out map[string]*AgentService
- if err := decodeBody(resp, &out); err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// Members returns the known gossip members. The WAN
-// flag can be used to query a server for WAN members.
-func (a *Agent) Members(wan bool) ([]*AgentMember, error) {
- r := a.c.newRequest("GET", "/v1/agent/members")
- if wan {
- r.params.Set("wan", "1")
- }
- _, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return nil, err
- }
- defer resp.Body.Close()
-
- var out []*AgentMember
- if err := decodeBody(resp, &out); err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// ServiceRegister is used to register a new service with
-// the local agent
-func (a *Agent) ServiceRegister(service *AgentServiceRegistration) error {
- r := a.c.newRequest("PUT", "/v1/agent/service/register")
- r.obj = service
- _, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return err
- }
- resp.Body.Close()
- return nil
-}
-
-// ServiceDeregister is used to deregister a service with
-// the local agent
-func (a *Agent) ServiceDeregister(serviceID string) error {
- r := a.c.newRequest("PUT", "/v1/agent/service/deregister/"+serviceID)
- _, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return err
- }
- resp.Body.Close()
- return nil
-}
-
-// PassTTL is used to set a TTL check to the passing state
-func (a *Agent) PassTTL(checkID, note string) error {
- return a.UpdateTTL(checkID, note, "pass")
-}
-
-// WarnTTL is used to set a TTL check to the warning state
-func (a *Agent) WarnTTL(checkID, note string) error {
- return a.UpdateTTL(checkID, note, "warn")
-}
-
-// FailTTL is used to set a TTL check to the failing state
-func (a *Agent) FailTTL(checkID, note string) error {
- return a.UpdateTTL(checkID, note, "fail")
-}
-
-// UpdateTTL is used to update the TTL of a check
-func (a *Agent) UpdateTTL(checkID, note, status string) error {
- switch status {
- case "pass":
- case "warn":
- case "fail":
- default:
- return fmt.Errorf("Invalid status: %s", status)
- }
- endpoint := fmt.Sprintf("/v1/agent/check/%s/%s", status, checkID)
- r := a.c.newRequest("PUT", endpoint)
- r.params.Set("note", note)
- _, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return err
- }
- resp.Body.Close()
- return nil
-}
-
-// CheckRegister is used to register a new check with
-// the local agent
-func (a *Agent) CheckRegister(check *AgentCheckRegistration) error {
- r := a.c.newRequest("PUT", "/v1/agent/check/register")
- r.obj = check
- _, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return err
- }
- resp.Body.Close()
- return nil
-}
-
-// CheckDeregister is used to deregister a check with
-// the local agent
-func (a *Agent) CheckDeregister(checkID string) error {
- r := a.c.newRequest("PUT", "/v1/agent/check/deregister/"+checkID)
- _, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return err
- }
- resp.Body.Close()
- return nil
-}
-
-// Join is used to instruct the agent to attempt a join to
-// another cluster member
-func (a *Agent) Join(addr string, wan bool) error {
- r := a.c.newRequest("PUT", "/v1/agent/join/"+addr)
- if wan {
- r.params.Set("wan", "1")
- }
- _, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return err
- }
- resp.Body.Close()
- return nil
-}
-
-// ForceLeave is used to have the agent eject a failed node
-func (a *Agent) ForceLeave(node string) error {
- r := a.c.newRequest("PUT", "/v1/agent/force-leave/"+node)
- _, resp, err := requireOK(a.c.doRequest(r))
- if err != nil {
- return err
- }
- resp.Body.Close()
- return nil
-}
diff --git a/vendor/github.com/armon/consul-api/api.go b/vendor/github.com/armon/consul-api/api.go
deleted file mode 100644
index e1335769..00000000
--- a/vendor/github.com/armon/consul-api/api.go
+++ /dev/null
@@ -1,323 +0,0 @@
-package consulapi
-
-import (
- "bytes"
- "encoding/json"
- "fmt"
- "io"
- "net/http"
- "net/url"
- "strconv"
- "time"
-)
-
-// QueryOptions are used to parameterize a query
-type QueryOptions struct {
- // Providing a datacenter overwrites the DC provided
- // by the Config
- Datacenter string
-
- // AllowStale allows any Consul server (non-leader) to service
- // a read. This allows for lower latency and higher throughput
- AllowStale bool
-
- // RequireConsistent forces the read to be fully consistent.
- // This is more expensive but prevents ever performing a stale
- // read.
- RequireConsistent bool
-
- // WaitIndex is used to enable a blocking query. Waits
- // until the timeout or the next index is reached
- WaitIndex uint64
-
- // WaitTime is used to bound the duration of a wait.
- // Defaults to that of the Config, but can be overriden.
- WaitTime time.Duration
-
- // Token is used to provide a per-request ACL token
- // which overrides the agent's default token.
- Token string
-}
-
-// WriteOptions are used to parameterize a write
-type WriteOptions struct {
- // Providing a datacenter overwrites the DC provided
- // by the Config
- Datacenter string
-
- // Token is used to provide a per-request ACL token
- // which overrides the agent's default token.
- Token string
-}
-
-// QueryMeta is used to return meta data about a query
-type QueryMeta struct {
- // LastIndex. This can be used as a WaitIndex to perform
- // a blocking query
- LastIndex uint64
-
- // Time of last contact from the leader for the
- // server servicing the request
- LastContact time.Duration
-
- // Is there a known leader
- KnownLeader bool
-
- // How long did the request take
- RequestTime time.Duration
-}
-
-// WriteMeta is used to return meta data about a write
-type WriteMeta struct {
- // How long did the request take
- RequestTime time.Duration
-}
-
-// HttpBasicAuth is used to authenticate http client with HTTP Basic Authentication
-type HttpBasicAuth struct {
- // Username to use for HTTP Basic Authentication
- Username string
-
- // Password to use for HTTP Basic Authentication
- Password string
-}
-
-// Config is used to configure the creation of a client
-type Config struct {
- // Address is the address of the Consul server
- Address string
-
- // Scheme is the URI scheme for the Consul server
- Scheme string
-
- // Datacenter to use. If not provided, the default agent datacenter is used.
- Datacenter string
-
- // HttpClient is the client to use. Default will be
- // used if not provided.
- HttpClient *http.Client
-
- // HttpAuth is the auth info to use for http access.
- HttpAuth *HttpBasicAuth
-
- // WaitTime limits how long a Watch will block. If not provided,
- // the agent default values will be used.
- WaitTime time.Duration
-
- // Token is used to provide a per-request ACL token
- // which overrides the agent's default token.
- Token string
-}
-
-// DefaultConfig returns a default configuration for the client
-func DefaultConfig() *Config {
- return &Config{
- Address: "127.0.0.1:8500",
- Scheme: "http",
- HttpClient: http.DefaultClient,
- }
-}
-
-// Client provides a client to the Consul API
-type Client struct {
- config Config
-}
-
-// NewClient returns a new client
-func NewClient(config *Config) (*Client, error) {
- // bootstrap the config
- defConfig := DefaultConfig()
-
- if len(config.Address) == 0 {
- config.Address = defConfig.Address
- }
-
- if len(config.Scheme) == 0 {
- config.Scheme = defConfig.Scheme
- }
-
- if config.HttpClient == nil {
- config.HttpClient = defConfig.HttpClient
- }
-
- client := &Client{
- config: *config,
- }
- return client, nil
-}
-
-// request is used to help build up a request
-type request struct {
- config *Config
- method string
- url *url.URL
- params url.Values
- body io.Reader
- obj interface{}
-}
-
-// setQueryOptions is used to annotate the request with
-// additional query options
-func (r *request) setQueryOptions(q *QueryOptions) {
- if q == nil {
- return
- }
- if q.Datacenter != "" {
- r.params.Set("dc", q.Datacenter)
- }
- if q.AllowStale {
- r.params.Set("stale", "")
- }
- if q.RequireConsistent {
- r.params.Set("consistent", "")
- }
- if q.WaitIndex != 0 {
- r.params.Set("index", strconv.FormatUint(q.WaitIndex, 10))
- }
- if q.WaitTime != 0 {
- r.params.Set("wait", durToMsec(q.WaitTime))
- }
- if q.Token != "" {
- r.params.Set("token", q.Token)
- }
-}
-
-// durToMsec converts a duration to a millisecond specified string
-func durToMsec(dur time.Duration) string {
- return fmt.Sprintf("%dms", dur/time.Millisecond)
-}
-
-// setWriteOptions is used to annotate the request with
-// additional write options
-func (r *request) setWriteOptions(q *WriteOptions) {
- if q == nil {
- return
- }
- if q.Datacenter != "" {
- r.params.Set("dc", q.Datacenter)
- }
- if q.Token != "" {
- r.params.Set("token", q.Token)
- }
-}
-
-// toHTTP converts the request to an HTTP request
-func (r *request) toHTTP() (*http.Request, error) {
- // Encode the query parameters
- r.url.RawQuery = r.params.Encode()
-
- // Get the url sring
- urlRaw := r.url.String()
-
- // Check if we should encode the body
- if r.body == nil && r.obj != nil {
- if b, err := encodeBody(r.obj); err != nil {
- return nil, err
- } else {
- r.body = b
- }
- }
-
- // Create the HTTP request
- req, err := http.NewRequest(r.method, urlRaw, r.body)
-
- // Setup auth
- if err == nil && r.config.HttpAuth != nil {
- req.SetBasicAuth(r.config.HttpAuth.Username, r.config.HttpAuth.Password)
- }
-
- return req, err
-}
-
-// newRequest is used to create a new request
-func (c *Client) newRequest(method, path string) *request {
- r := &request{
- config: &c.config,
- method: method,
- url: &url.URL{
- Scheme: c.config.Scheme,
- Host: c.config.Address,
- Path: path,
- },
- params: make(map[string][]string),
- }
- if c.config.Datacenter != "" {
- r.params.Set("dc", c.config.Datacenter)
- }
- if c.config.WaitTime != 0 {
- r.params.Set("wait", durToMsec(r.config.WaitTime))
- }
- if c.config.Token != "" {
- r.params.Set("token", r.config.Token)
- }
- return r
-}
-
-// doRequest runs a request with our client
-func (c *Client) doRequest(r *request) (time.Duration, *http.Response, error) {
- req, err := r.toHTTP()
- if err != nil {
- return 0, nil, err
- }
- start := time.Now()
- resp, err := c.config.HttpClient.Do(req)
- diff := time.Now().Sub(start)
- return diff, resp, err
-}
-
-// parseQueryMeta is used to help parse query meta-data
-func parseQueryMeta(resp *http.Response, q *QueryMeta) error {
- header := resp.Header
-
- // Parse the X-Consul-Index
- index, err := strconv.ParseUint(header.Get("X-Consul-Index"), 10, 64)
- if err != nil {
- return fmt.Errorf("Failed to parse X-Consul-Index: %v", err)
- }
- q.LastIndex = index
-
- // Parse the X-Consul-LastContact
- last, err := strconv.ParseUint(header.Get("X-Consul-LastContact"), 10, 64)
- if err != nil {
- return fmt.Errorf("Failed to parse X-Consul-LastContact: %v", err)
- }
- q.LastContact = time.Duration(last) * time.Millisecond
-
- // Parse the X-Consul-KnownLeader
- switch header.Get("X-Consul-KnownLeader") {
- case "true":
- q.KnownLeader = true
- default:
- q.KnownLeader = false
- }
- return nil
-}
-
-// decodeBody is used to JSON decode a body
-func decodeBody(resp *http.Response, out interface{}) error {
- dec := json.NewDecoder(resp.Body)
- return dec.Decode(out)
-}
-
-// encodeBody is used to encode a request body
-func encodeBody(obj interface{}) (io.Reader, error) {
- buf := bytes.NewBuffer(nil)
- enc := json.NewEncoder(buf)
- if err := enc.Encode(obj); err != nil {
- return nil, err
- }
- return buf, nil
-}
-
-// requireOK is used to wrap doRequest and check for a 200
-func requireOK(d time.Duration, resp *http.Response, e error) (time.Duration, *http.Response, error) {
- if e != nil {
- return d, resp, e
- }
- if resp.StatusCode != 200 {
- var buf bytes.Buffer
- io.Copy(&buf, resp.Body)
- return d, resp, fmt.Errorf("Unexpected response code: %d (%s)", resp.StatusCode, buf.Bytes())
- }
- return d, resp, e
-}
diff --git a/vendor/github.com/armon/consul-api/catalog.go b/vendor/github.com/armon/consul-api/catalog.go
deleted file mode 100644
index 8080e2a9..00000000
--- a/vendor/github.com/armon/consul-api/catalog.go
+++ /dev/null
@@ -1,181 +0,0 @@
-package consulapi
-
-type Node struct {
- Node string
- Address string
-}
-
-type CatalogService struct {
- Node string
- Address string
- ServiceID string
- ServiceName string
- ServiceTags []string
- ServicePort int
-}
-
-type CatalogNode struct {
- Node *Node
- Services map[string]*AgentService
-}
-
-type CatalogRegistration struct {
- Node string
- Address string
- Datacenter string
- Service *AgentService
- Check *AgentCheck
-}
-
-type CatalogDeregistration struct {
- Node string
- Address string
- Datacenter string
- ServiceID string
- CheckID string
-}
-
-// Catalog can be used to query the Catalog endpoints
-type Catalog struct {
- c *Client
-}
-
-// Catalog returns a handle to the catalog endpoints
-func (c *Client) Catalog() *Catalog {
- return &Catalog{c}
-}
-
-func (c *Catalog) Register(reg *CatalogRegistration, q *WriteOptions) (*WriteMeta, error) {
- r := c.c.newRequest("PUT", "/v1/catalog/register")
- r.setWriteOptions(q)
- r.obj = reg
- rtt, resp, err := requireOK(c.c.doRequest(r))
- if err != nil {
- return nil, err
- }
- resp.Body.Close()
-
- wm := &WriteMeta{}
- wm.RequestTime = rtt
-
- return wm, nil
-}
-
-func (c *Catalog) Deregister(dereg *CatalogDeregistration, q *WriteOptions) (*WriteMeta, error) {
- r := c.c.newRequest("PUT", "/v1/catalog/deregister")
- r.setWriteOptions(q)
- r.obj = dereg
- rtt, resp, err := requireOK(c.c.doRequest(r))
- if err != nil {
- return nil, err
- }
- resp.Body.Close()
-
- wm := &WriteMeta{}
- wm.RequestTime = rtt
-
- return wm, nil
-}
-
-// Datacenters is used to query for all the known datacenters
-func (c *Catalog) Datacenters() ([]string, error) {
- r := c.c.newRequest("GET", "/v1/catalog/datacenters")
- _, resp, err := requireOK(c.c.doRequest(r))
- if err != nil {
- return nil, err
- }
- defer resp.Body.Close()
-
- var out []string
- if err := decodeBody(resp, &out); err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// Nodes is used to query all the known nodes
-func (c *Catalog) Nodes(q *QueryOptions) ([]*Node, *QueryMeta, error) {
- r := c.c.newRequest("GET", "/v1/catalog/nodes")
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(c.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var out []*Node
- if err := decodeBody(resp, &out); err != nil {
- return nil, nil, err
- }
- return out, qm, nil
-}
-
-// Services is used to query for all known services
-func (c *Catalog) Services(q *QueryOptions) (map[string][]string, *QueryMeta, error) {
- r := c.c.newRequest("GET", "/v1/catalog/services")
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(c.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var out map[string][]string
- if err := decodeBody(resp, &out); err != nil {
- return nil, nil, err
- }
- return out, qm, nil
-}
-
-// Service is used to query catalog entries for a given service
-func (c *Catalog) Service(service, tag string, q *QueryOptions) ([]*CatalogService, *QueryMeta, error) {
- r := c.c.newRequest("GET", "/v1/catalog/service/"+service)
- r.setQueryOptions(q)
- if tag != "" {
- r.params.Set("tag", tag)
- }
- rtt, resp, err := requireOK(c.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var out []*CatalogService
- if err := decodeBody(resp, &out); err != nil {
- return nil, nil, err
- }
- return out, qm, nil
-}
-
-// Node is used to query for service information about a single node
-func (c *Catalog) Node(node string, q *QueryOptions) (*CatalogNode, *QueryMeta, error) {
- r := c.c.newRequest("GET", "/v1/catalog/node/"+node)
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(c.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var out *CatalogNode
- if err := decodeBody(resp, &out); err != nil {
- return nil, nil, err
- }
- return out, qm, nil
-}
diff --git a/vendor/github.com/armon/consul-api/event.go b/vendor/github.com/armon/consul-api/event.go
deleted file mode 100644
index 59813d40..00000000
--- a/vendor/github.com/armon/consul-api/event.go
+++ /dev/null
@@ -1,104 +0,0 @@
-package consulapi
-
-import (
- "bytes"
- "strconv"
-)
-
-// Event can be used to query the Event endpoints
-type Event struct {
- c *Client
-}
-
-// UserEvent represents an event that was fired by the user
-type UserEvent struct {
- ID string
- Name string
- Payload []byte
- NodeFilter string
- ServiceFilter string
- TagFilter string
- Version int
- LTime uint64
-}
-
-// Event returns a handle to the event endpoints
-func (c *Client) Event() *Event {
- return &Event{c}
-}
-
-// Fire is used to fire a new user event. Only the Name, Payload and Filters
-// are respected. This returns the ID or an associated error. Cross DC requests
-// are supported.
-func (e *Event) Fire(params *UserEvent, q *WriteOptions) (string, *WriteMeta, error) {
- r := e.c.newRequest("PUT", "/v1/event/fire/"+params.Name)
- r.setWriteOptions(q)
- if params.NodeFilter != "" {
- r.params.Set("node", params.NodeFilter)
- }
- if params.ServiceFilter != "" {
- r.params.Set("service", params.ServiceFilter)
- }
- if params.TagFilter != "" {
- r.params.Set("tag", params.TagFilter)
- }
- if params.Payload != nil {
- r.body = bytes.NewReader(params.Payload)
- }
-
- rtt, resp, err := requireOK(e.c.doRequest(r))
- if err != nil {
- return "", nil, err
- }
- defer resp.Body.Close()
-
- wm := &WriteMeta{RequestTime: rtt}
- var out UserEvent
- if err := decodeBody(resp, &out); err != nil {
- return "", nil, err
- }
- return out.ID, wm, nil
-}
-
-// List is used to get the most recent events an agent has received.
-// This list can be optionally filtered by the name. This endpoint supports
-// quasi-blocking queries. The index is not monotonic, nor does it provide provide
-// LastContact or KnownLeader.
-func (e *Event) List(name string, q *QueryOptions) ([]*UserEvent, *QueryMeta, error) {
- r := e.c.newRequest("GET", "/v1/event/list")
- r.setQueryOptions(q)
- if name != "" {
- r.params.Set("name", name)
- }
- rtt, resp, err := requireOK(e.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var entries []*UserEvent
- if err := decodeBody(resp, &entries); err != nil {
- return nil, nil, err
- }
- return entries, qm, nil
-}
-
-// IDToIndex is a bit of a hack. This simulates the index generation to
-// convert an event ID into a WaitIndex.
-func (e *Event) IDToIndex(uuid string) uint64 {
- lower := uuid[0:8] + uuid[9:13] + uuid[14:18]
- upper := uuid[19:23] + uuid[24:36]
- lowVal, err := strconv.ParseUint(lower, 16, 64)
- if err != nil {
- panic("Failed to convert " + lower)
- }
- highVal, err := strconv.ParseUint(upper, 16, 64)
- if err != nil {
- panic("Failed to convert " + upper)
- }
- return lowVal ^ highVal
-}
diff --git a/vendor/github.com/armon/consul-api/health.go b/vendor/github.com/armon/consul-api/health.go
deleted file mode 100644
index 12225790..00000000
--- a/vendor/github.com/armon/consul-api/health.go
+++ /dev/null
@@ -1,136 +0,0 @@
-package consulapi
-
-import (
- "fmt"
-)
-
-// HealthCheck is used to represent a single check
-type HealthCheck struct {
- Node string
- CheckID string
- Name string
- Status string
- Notes string
- Output string
- ServiceID string
- ServiceName string
-}
-
-// ServiceEntry is used for the health service endpoint
-type ServiceEntry struct {
- Node *Node
- Service *AgentService
- Checks []*HealthCheck
-}
-
-// Health can be used to query the Health endpoints
-type Health struct {
- c *Client
-}
-
-// Health returns a handle to the health endpoints
-func (c *Client) Health() *Health {
- return &Health{c}
-}
-
-// Node is used to query for checks belonging to a given node
-func (h *Health) Node(node string, q *QueryOptions) ([]*HealthCheck, *QueryMeta, error) {
- r := h.c.newRequest("GET", "/v1/health/node/"+node)
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(h.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var out []*HealthCheck
- if err := decodeBody(resp, &out); err != nil {
- return nil, nil, err
- }
- return out, qm, nil
-}
-
-// Checks is used to return the checks associated with a service
-func (h *Health) Checks(service string, q *QueryOptions) ([]*HealthCheck, *QueryMeta, error) {
- r := h.c.newRequest("GET", "/v1/health/checks/"+service)
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(h.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var out []*HealthCheck
- if err := decodeBody(resp, &out); err != nil {
- return nil, nil, err
- }
- return out, qm, nil
-}
-
-// Service is used to query health information along with service info
-// for a given service. It can optionally do server-side filtering on a tag
-// or nodes with passing health checks only.
-func (h *Health) Service(service, tag string, passingOnly bool, q *QueryOptions) ([]*ServiceEntry, *QueryMeta, error) {
- r := h.c.newRequest("GET", "/v1/health/service/"+service)
- r.setQueryOptions(q)
- if tag != "" {
- r.params.Set("tag", tag)
- }
- if passingOnly {
- r.params.Set("passing", "1")
- }
- rtt, resp, err := requireOK(h.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var out []*ServiceEntry
- if err := decodeBody(resp, &out); err != nil {
- return nil, nil, err
- }
- return out, qm, nil
-}
-
-// State is used to retrieve all the checks in a given state.
-// The wildcard "any" state can also be used for all checks.
-func (h *Health) State(state string, q *QueryOptions) ([]*HealthCheck, *QueryMeta, error) {
- switch state {
- case "any":
- case "warning":
- case "critical":
- case "passing":
- case "unknown":
- default:
- return nil, nil, fmt.Errorf("Unsupported state: %v", state)
- }
- r := h.c.newRequest("GET", "/v1/health/state/"+state)
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(h.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var out []*HealthCheck
- if err := decodeBody(resp, &out); err != nil {
- return nil, nil, err
- }
- return out, qm, nil
-}
diff --git a/vendor/github.com/armon/consul-api/kv.go b/vendor/github.com/armon/consul-api/kv.go
deleted file mode 100644
index 98c3b1a0..00000000
--- a/vendor/github.com/armon/consul-api/kv.go
+++ /dev/null
@@ -1,219 +0,0 @@
-package consulapi
-
-import (
- "bytes"
- "fmt"
- "io"
- "net/http"
- "strconv"
- "strings"
-)
-
-// KVPair is used to represent a single K/V entry
-type KVPair struct {
- Key string
- CreateIndex uint64
- ModifyIndex uint64
- LockIndex uint64
- Flags uint64
- Value []byte
- Session string
-}
-
-// KVPairs is a list of KVPair objects
-type KVPairs []*KVPair
-
-// KV is used to manipulate the K/V API
-type KV struct {
- c *Client
-}
-
-// KV is used to return a handle to the K/V apis
-func (c *Client) KV() *KV {
- return &KV{c}
-}
-
-// Get is used to lookup a single key
-func (k *KV) Get(key string, q *QueryOptions) (*KVPair, *QueryMeta, error) {
- resp, qm, err := k.getInternal(key, nil, q)
- if err != nil {
- return nil, nil, err
- }
- if resp == nil {
- return nil, qm, nil
- }
- defer resp.Body.Close()
-
- var entries []*KVPair
- if err := decodeBody(resp, &entries); err != nil {
- return nil, nil, err
- }
- if len(entries) > 0 {
- return entries[0], qm, nil
- }
- return nil, qm, nil
-}
-
-// List is used to lookup all keys under a prefix
-func (k *KV) List(prefix string, q *QueryOptions) (KVPairs, *QueryMeta, error) {
- resp, qm, err := k.getInternal(prefix, map[string]string{"recurse": ""}, q)
- if err != nil {
- return nil, nil, err
- }
- if resp == nil {
- return nil, qm, nil
- }
- defer resp.Body.Close()
-
- var entries []*KVPair
- if err := decodeBody(resp, &entries); err != nil {
- return nil, nil, err
- }
- return entries, qm, nil
-}
-
-// Keys is used to list all the keys under a prefix. Optionally,
-// a separator can be used to limit the responses.
-func (k *KV) Keys(prefix, separator string, q *QueryOptions) ([]string, *QueryMeta, error) {
- params := map[string]string{"keys": ""}
- if separator != "" {
- params["separator"] = separator
- }
- resp, qm, err := k.getInternal(prefix, params, q)
- if err != nil {
- return nil, nil, err
- }
- if resp == nil {
- return nil, qm, nil
- }
- defer resp.Body.Close()
-
- var entries []string
- if err := decodeBody(resp, &entries); err != nil {
- return nil, nil, err
- }
- return entries, qm, nil
-}
-
-func (k *KV) getInternal(key string, params map[string]string, q *QueryOptions) (*http.Response, *QueryMeta, error) {
- r := k.c.newRequest("GET", "/v1/kv/"+key)
- r.setQueryOptions(q)
- for param, val := range params {
- r.params.Set(param, val)
- }
- rtt, resp, err := k.c.doRequest(r)
- if err != nil {
- return nil, nil, err
- }
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- if resp.StatusCode == 404 {
- resp.Body.Close()
- return nil, qm, nil
- } else if resp.StatusCode != 200 {
- resp.Body.Close()
- return nil, nil, fmt.Errorf("Unexpected response code: %d", resp.StatusCode)
- }
- return resp, qm, nil
-}
-
-// Put is used to write a new value. Only the
-// Key, Flags and Value is respected.
-func (k *KV) Put(p *KVPair, q *WriteOptions) (*WriteMeta, error) {
- params := make(map[string]string, 1)
- if p.Flags != 0 {
- params["flags"] = strconv.FormatUint(p.Flags, 10)
- }
- _, wm, err := k.put(p.Key, params, p.Value, q)
- return wm, err
-}
-
-// CAS is used for a Check-And-Set operation. The Key,
-// ModifyIndex, Flags and Value are respected. Returns true
-// on success or false on failures.
-func (k *KV) CAS(p *KVPair, q *WriteOptions) (bool, *WriteMeta, error) {
- params := make(map[string]string, 2)
- if p.Flags != 0 {
- params["flags"] = strconv.FormatUint(p.Flags, 10)
- }
- params["cas"] = strconv.FormatUint(p.ModifyIndex, 10)
- return k.put(p.Key, params, p.Value, q)
-}
-
-// Acquire is used for a lock acquisiiton operation. The Key,
-// Flags, Value and Session are respected. Returns true
-// on success or false on failures.
-func (k *KV) Acquire(p *KVPair, q *WriteOptions) (bool, *WriteMeta, error) {
- params := make(map[string]string, 2)
- if p.Flags != 0 {
- params["flags"] = strconv.FormatUint(p.Flags, 10)
- }
- params["acquire"] = p.Session
- return k.put(p.Key, params, p.Value, q)
-}
-
-// Release is used for a lock release operation. The Key,
-// Flags, Value and Session are respected. Returns true
-// on success or false on failures.
-func (k *KV) Release(p *KVPair, q *WriteOptions) (bool, *WriteMeta, error) {
- params := make(map[string]string, 2)
- if p.Flags != 0 {
- params["flags"] = strconv.FormatUint(p.Flags, 10)
- }
- params["release"] = p.Session
- return k.put(p.Key, params, p.Value, q)
-}
-
-func (k *KV) put(key string, params map[string]string, body []byte, q *WriteOptions) (bool, *WriteMeta, error) {
- r := k.c.newRequest("PUT", "/v1/kv/"+key)
- r.setWriteOptions(q)
- for param, val := range params {
- r.params.Set(param, val)
- }
- r.body = bytes.NewReader(body)
- rtt, resp, err := requireOK(k.c.doRequest(r))
- if err != nil {
- return false, nil, err
- }
- defer resp.Body.Close()
-
- qm := &WriteMeta{}
- qm.RequestTime = rtt
-
- var buf bytes.Buffer
- if _, err := io.Copy(&buf, resp.Body); err != nil {
- return false, nil, fmt.Errorf("Failed to read response: %v", err)
- }
- res := strings.Contains(string(buf.Bytes()), "true")
- return res, qm, nil
-}
-
-// Delete is used to delete a single key
-func (k *KV) Delete(key string, w *WriteOptions) (*WriteMeta, error) {
- return k.deleteInternal(key, nil, w)
-}
-
-// DeleteTree is used to delete all keys under a prefix
-func (k *KV) DeleteTree(prefix string, w *WriteOptions) (*WriteMeta, error) {
- return k.deleteInternal(prefix, []string{"recurse"}, w)
-}
-
-func (k *KV) deleteInternal(key string, params []string, q *WriteOptions) (*WriteMeta, error) {
- r := k.c.newRequest("DELETE", "/v1/kv/"+key)
- r.setWriteOptions(q)
- for _, param := range params {
- r.params.Set(param, "")
- }
- rtt, resp, err := requireOK(k.c.doRequest(r))
- if err != nil {
- return nil, err
- }
- resp.Body.Close()
-
- qm := &WriteMeta{}
- qm.RequestTime = rtt
- return qm, nil
-}
diff --git a/vendor/github.com/armon/consul-api/session.go b/vendor/github.com/armon/consul-api/session.go
deleted file mode 100644
index 4fbfc5ee..00000000
--- a/vendor/github.com/armon/consul-api/session.go
+++ /dev/null
@@ -1,204 +0,0 @@
-package consulapi
-
-import (
- "time"
-)
-
-// SessionEntry represents a session in consul
-type SessionEntry struct {
- CreateIndex uint64
- ID string
- Name string
- Node string
- Checks []string
- LockDelay time.Duration
- Behavior string
- TTL string
-}
-
-// Session can be used to query the Session endpoints
-type Session struct {
- c *Client
-}
-
-// Session returns a handle to the session endpoints
-func (c *Client) Session() *Session {
- return &Session{c}
-}
-
-// CreateNoChecks is like Create but is used specifically to create
-// a session with no associated health checks.
-func (s *Session) CreateNoChecks(se *SessionEntry, q *WriteOptions) (string, *WriteMeta, error) {
- body := make(map[string]interface{})
- body["Checks"] = []string{}
- if se != nil {
- if se.Name != "" {
- body["Name"] = se.Name
- }
- if se.Node != "" {
- body["Node"] = se.Node
- }
- if se.LockDelay != 0 {
- body["LockDelay"] = durToMsec(se.LockDelay)
- }
- if se.Behavior != "" {
- body["Behavior"] = se.Behavior
- }
- if se.TTL != "" {
- body["TTL"] = se.TTL
- }
- }
- return s.create(body, q)
-
-}
-
-// Create makes a new session. Providing a session entry can
-// customize the session. It can also be nil to use defaults.
-func (s *Session) Create(se *SessionEntry, q *WriteOptions) (string, *WriteMeta, error) {
- var obj interface{}
- if se != nil {
- body := make(map[string]interface{})
- obj = body
- if se.Name != "" {
- body["Name"] = se.Name
- }
- if se.Node != "" {
- body["Node"] = se.Node
- }
- if se.LockDelay != 0 {
- body["LockDelay"] = durToMsec(se.LockDelay)
- }
- if len(se.Checks) > 0 {
- body["Checks"] = se.Checks
- }
- if se.Behavior != "" {
- body["Behavior"] = se.Behavior
- }
- if se.TTL != "" {
- body["TTL"] = se.TTL
- }
- }
- return s.create(obj, q)
-}
-
-func (s *Session) create(obj interface{}, q *WriteOptions) (string, *WriteMeta, error) {
- r := s.c.newRequest("PUT", "/v1/session/create")
- r.setWriteOptions(q)
- r.obj = obj
- rtt, resp, err := requireOK(s.c.doRequest(r))
- if err != nil {
- return "", nil, err
- }
- defer resp.Body.Close()
-
- wm := &WriteMeta{RequestTime: rtt}
- var out struct{ ID string }
- if err := decodeBody(resp, &out); err != nil {
- return "", nil, err
- }
- return out.ID, wm, nil
-}
-
-// Destroy invalides a given session
-func (s *Session) Destroy(id string, q *WriteOptions) (*WriteMeta, error) {
- r := s.c.newRequest("PUT", "/v1/session/destroy/"+id)
- r.setWriteOptions(q)
- rtt, resp, err := requireOK(s.c.doRequest(r))
- if err != nil {
- return nil, err
- }
- resp.Body.Close()
-
- wm := &WriteMeta{RequestTime: rtt}
- return wm, nil
-}
-
-// Renew renews the TTL on a given session
-func (s *Session) Renew(id string, q *WriteOptions) (*SessionEntry, *WriteMeta, error) {
- r := s.c.newRequest("PUT", "/v1/session/renew/"+id)
- r.setWriteOptions(q)
- rtt, resp, err := requireOK(s.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- wm := &WriteMeta{RequestTime: rtt}
-
- var entries []*SessionEntry
- if err := decodeBody(resp, &entries); err != nil {
- return nil, wm, err
- }
-
- if len(entries) > 0 {
- return entries[0], wm, nil
- }
- return nil, wm, nil
-}
-
-// Info looks up a single session
-func (s *Session) Info(id string, q *QueryOptions) (*SessionEntry, *QueryMeta, error) {
- r := s.c.newRequest("GET", "/v1/session/info/"+id)
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(s.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var entries []*SessionEntry
- if err := decodeBody(resp, &entries); err != nil {
- return nil, nil, err
- }
-
- if len(entries) > 0 {
- return entries[0], qm, nil
- }
- return nil, qm, nil
-}
-
-// List gets sessions for a node
-func (s *Session) Node(node string, q *QueryOptions) ([]*SessionEntry, *QueryMeta, error) {
- r := s.c.newRequest("GET", "/v1/session/node/"+node)
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(s.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var entries []*SessionEntry
- if err := decodeBody(resp, &entries); err != nil {
- return nil, nil, err
- }
- return entries, qm, nil
-}
-
-// List gets all active sessions
-func (s *Session) List(q *QueryOptions) ([]*SessionEntry, *QueryMeta, error) {
- r := s.c.newRequest("GET", "/v1/session/list")
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(s.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var entries []*SessionEntry
- if err := decodeBody(resp, &entries); err != nil {
- return nil, nil, err
- }
- return entries, qm, nil
-}
diff --git a/vendor/github.com/armon/consul-api/status.go b/vendor/github.com/armon/consul-api/status.go
deleted file mode 100644
index 21c31982..00000000
--- a/vendor/github.com/armon/consul-api/status.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package consulapi
-
-// Status can be used to query the Status endpoints
-type Status struct {
- c *Client
-}
-
-// Status returns a handle to the status endpoints
-func (c *Client) Status() *Status {
- return &Status{c}
-}
-
-// Leader is used to query for a known leader
-func (s *Status) Leader() (string, error) {
- r := s.c.newRequest("GET", "/v1/status/leader")
- _, resp, err := requireOK(s.c.doRequest(r))
- if err != nil {
- return "", err
- }
- defer resp.Body.Close()
-
- var leader string
- if err := decodeBody(resp, &leader); err != nil {
- return "", err
- }
- return leader, nil
-}
-
-// Peers is used to query for a known raft peers
-func (s *Status) Peers() ([]string, error) {
- r := s.c.newRequest("GET", "/v1/status/peers")
- _, resp, err := requireOK(s.c.doRequest(r))
- if err != nil {
- return nil, err
- }
- defer resp.Body.Close()
-
- var peers []string
- if err := decodeBody(resp, &peers); err != nil {
- return nil, err
- }
- return peers, nil
-}