From 607c92f04f933a1d9026c601dcc28c8a1c0c11a6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Jul 2021 10:14:01 +0300 Subject: [PATCH] Bump github.com/hashicorp/consul/api from 1.8.1 to 1.9.1 (#93) Bumps [github.com/hashicorp/consul/api](https://github.com/hashicorp/consul) from 1.8.1 to 1.9.1. - [Release notes](https://github.com/hashicorp/consul/releases) - [Changelog](https://github.com/hashicorp/consul/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/consul/compare/v1.8.1...v1.9.1) --- updated-dependencies: - dependency-name: github.com/hashicorp/consul/api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 9 +- vendor/github.com/hashicorp/consul/api/acl.go | 140 ++++++++++----- .../github.com/hashicorp/consul/api/agent.go | 139 ++++++++++----- vendor/github.com/hashicorp/consul/api/api.go | 69 +++++++- .../hashicorp/consul/api/catalog.go | 18 +- .../hashicorp/consul/api/config_entry.go | 163 +++++++++++++++--- .../consul/api/config_entry_cluster.go | 53 ++++++ .../hashicorp/consul/api/connect_ca.go | 14 +- .../hashicorp/consul/api/connect_intention.go | 20 +-- .../hashicorp/consul/api/coordinate.go | 8 +- .../github.com/hashicorp/consul/api/debug.go | 24 ++- .../hashicorp/consul/api/discovery_chain.go | 2 +- .../github.com/hashicorp/consul/api/event.go | 5 +- vendor/github.com/hashicorp/consul/api/go.mod | 2 +- vendor/github.com/hashicorp/consul/api/go.sum | 13 +- .../github.com/hashicorp/consul/api/health.go | 9 +- vendor/github.com/hashicorp/consul/api/kv.go | 15 +- .../hashicorp/consul/api/namespace.go | 10 +- .../hashicorp/consul/api/operator_area.go | 8 +- .../consul/api/operator_autopilot.go | 25 ++- .../hashicorp/consul/api/operator_keyring.go | 8 +- .../hashicorp/consul/api/operator_license.go | 46 ++--- .../hashicorp/consul/api/operator_raft.go | 6 +- .../hashicorp/consul/api/prepared_query.go | 4 +- .../hashicorp/consul/api/session.go | 2 +- .../hashicorp/consul/api/snapshot.go | 1 + .../github.com/hashicorp/consul/api/status.go | 4 +- vendor/github.com/hashicorp/consul/api/txn.go | 2 +- vendor/modules.txt | 2 +- 30 files changed, 584 insertions(+), 239 deletions(-) create mode 100644 vendor/github.com/hashicorp/consul/api/config_entry_cluster.go diff --git a/go.mod b/go.mod index 0edaf0dd..2915b901 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.15 require ( github.com/go-redis/redis/v8 v8.11.0 - github.com/hashicorp/consul/api v1.8.1 + github.com/hashicorp/consul/api v1.9.1 github.com/hashicorp/go-hclog v0.16.2 github.com/onsi/ginkgo v1.16.1 // indirect github.com/onsi/gomega v1.11.0 // indirect diff --git a/go.sum b/go.sum index d51dc09a..301fd076 100644 --- a/go.sum +++ b/go.sum @@ -36,10 +36,10 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/hashicorp/consul/api v1.8.1 h1:BOEQaMWoGMhmQ29fC26bi0qb7/rId9JzZP2V0Xmx7m8= -github.com/hashicorp/consul/api v1.8.1/go.mod h1:sDjTOq0yUyv5G4h+BqSea7Fn6BU+XbolEz1952UB+mk= -github.com/hashicorp/consul/sdk v0.7.0 h1:H6R9d008jDcHPQPAqPNuydAshJ4v5/8URdFnUvK/+sc= -github.com/hashicorp/consul/sdk v0.7.0/go.mod h1:fY08Y9z5SvJqevyZNy6WWPXiG3KwBPAvlcdx16zZ0fM= +github.com/hashicorp/consul/api v1.9.1 h1:SngrdG2L62qqLsUz85qcPhFZ78rPf8tcD5qjMgs6MME= +github.com/hashicorp/consul/api v1.9.1/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= +github.com/hashicorp/consul/sdk v0.8.0 h1:OJtKBtEjboEZvG6AOUdh4Z1Zbyu0WcxQ0qatRrZHTVU= +github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= @@ -121,6 +121,7 @@ github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSg github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= diff --git a/vendor/github.com/hashicorp/consul/api/acl.go b/vendor/github.com/hashicorp/consul/api/acl.go index 7453feb8..d94c2807 100644 --- a/vendor/github.com/hashicorp/consul/api/acl.go +++ b/vendor/github.com/hashicorp/consul/api/acl.go @@ -270,16 +270,61 @@ type ACLAuthMethodNamespaceRule struct { type ACLAuthMethodListEntry struct { Name string Type string - DisplayName string `json:",omitempty"` - Description string `json:",omitempty"` - CreateIndex uint64 - ModifyIndex uint64 + DisplayName string `json:",omitempty"` + Description string `json:",omitempty"` + MaxTokenTTL time.Duration `json:",omitempty"` + + // TokenLocality defines the kind of token that this auth method produces. + // This can be either 'local' or 'global'. If empty 'local' is assumed. + TokenLocality string `json:",omitempty"` + CreateIndex uint64 + ModifyIndex uint64 // Namespace is the namespace the ACLAuthMethodListEntry is associated with. // Namespacing is a Consul Enterprise feature. Namespace string `json:",omitempty"` } +// This is nearly identical to the ACLAuthMethod MarshalJSON +func (m *ACLAuthMethodListEntry) MarshalJSON() ([]byte, error) { + type Alias ACLAuthMethodListEntry + exported := &struct { + MaxTokenTTL string `json:",omitempty"` + *Alias + }{ + MaxTokenTTL: m.MaxTokenTTL.String(), + Alias: (*Alias)(m), + } + if m.MaxTokenTTL == 0 { + exported.MaxTokenTTL = "" + } + + return json.Marshal(exported) +} + +// This is nearly identical to the ACLAuthMethod UnmarshalJSON +func (m *ACLAuthMethodListEntry) UnmarshalJSON(data []byte) error { + type Alias ACLAuthMethodListEntry + aux := &struct { + MaxTokenTTL string + *Alias + }{ + Alias: (*Alias)(m), + } + + if err := json.Unmarshal(data, &aux); err != nil { + return err + } + var err error + if aux.MaxTokenTTL != "" { + if m.MaxTokenTTL, err = time.ParseDuration(aux.MaxTokenTTL); err != nil { + return err + } + } + + return nil +} + // ParseKubernetesAuthMethodConfig takes a raw config map and returns a parsed // KubernetesAuthMethodConfig. func ParseKubernetesAuthMethodConfig(raw map[string]interface{}) (*KubernetesAuthMethodConfig, error) { @@ -404,7 +449,7 @@ func (a *ACL) Bootstrap() (*ACLToken, *WriteMeta, error) { if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out ACLToken @@ -425,7 +470,7 @@ func (a *ACL) Create(acl *ACLEntry, q *WriteOptions) (string, *WriteMeta, error) if err != nil { return "", nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out struct{ ID string } @@ -446,7 +491,7 @@ func (a *ACL) Update(acl *ACLEntry, q *WriteOptions) (*WriteMeta, error) { if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} return wm, nil @@ -462,7 +507,7 @@ func (a *ACL) Destroy(id string, q *WriteOptions) (*WriteMeta, error) { if err != nil { return nil, err } - resp.Body.Close() + closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} return wm, nil @@ -478,7 +523,7 @@ func (a *ACL) Clone(id string, q *WriteOptions) (string, *WriteMeta, error) { if err != nil { return "", nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out struct{ ID string } @@ -498,7 +543,7 @@ func (a *ACL) Info(id string, q *QueryOptions) (*ACLEntry, *QueryMeta, error) { if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -524,7 +569,7 @@ func (a *ACL) List(q *QueryOptions) ([]*ACLEntry, *QueryMeta, error) { if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -545,7 +590,7 @@ func (a *ACL) Replication(q *QueryOptions) (*ACLReplicationStatus, *QueryMeta, e if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -568,7 +613,7 @@ func (a *ACL) TokenCreate(token *ACLToken, q *WriteOptions) (*ACLToken, *WriteMe if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out ACLToken @@ -593,7 +638,7 @@ func (a *ACL) TokenUpdate(token *ACLToken, q *WriteOptions) (*ACLToken, *WriteMe if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out ACLToken @@ -620,7 +665,7 @@ func (a *ACL) TokenClone(tokenID string, description string, q *WriteOptions) (* if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out ACLToken @@ -640,7 +685,7 @@ func (a *ACL) TokenDelete(tokenID string, q *WriteOptions) (*WriteMeta, error) { if err != nil { return nil, err } - resp.Body.Close() + closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} return wm, nil @@ -655,7 +700,7 @@ func (a *ACL) TokenRead(tokenID string, q *QueryOptions) (*ACLToken, *QueryMeta, if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -679,7 +724,7 @@ func (a *ACL) TokenReadSelf(q *QueryOptions) (*ACLToken, *QueryMeta, error) { if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -702,7 +747,7 @@ func (a *ACL) TokenList(q *QueryOptions) ([]*ACLTokenListEntry, *QueryMeta, erro if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -728,7 +773,7 @@ func (a *ACL) PolicyCreate(policy *ACLPolicy, q *WriteOptions) (*ACLPolicy, *Wri if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out ACLPolicy @@ -753,7 +798,7 @@ func (a *ACL) PolicyUpdate(policy *ACLPolicy, q *WriteOptions) (*ACLPolicy, *Wri if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out ACLPolicy @@ -772,7 +817,7 @@ func (a *ACL) PolicyDelete(policyID string, q *WriteOptions) (*WriteMeta, error) if err != nil { return nil, err } - resp.Body.Close() + closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} return wm, nil @@ -786,7 +831,7 @@ func (a *ACL) PolicyRead(policyID string, q *QueryOptions) (*ACLPolicy, *QueryMe if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -808,7 +853,7 @@ func (a *ACL) PolicyReadByName(policyName string, q *QueryOptions) (*ACLPolicy, if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -835,7 +880,7 @@ func (a *ACL) PolicyList(q *QueryOptions) ([]*ACLPolicyListEntry, *QueryMeta, er if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -855,11 +900,12 @@ func (a *ACL) PolicyList(q *QueryOptions) ([]*ACLPolicyListEntry, *QueryMeta, er func (a *ACL) RulesTranslate(rules io.Reader) (string, error) { r := a.c.newRequest("POST", "/v1/acl/rules/translate") r.body = rules + r.header.Set("Content-Type", "text/plain") rtt, resp, err := requireOK(a.c.doRequest(r)) if err != nil { return "", err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) qm.RequestTime = rtt @@ -883,7 +929,7 @@ func (a *ACL) RulesTranslateToken(tokenID string) (string, error) { if err != nil { return "", err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) qm.RequestTime = rtt @@ -910,7 +956,7 @@ func (a *ACL) RoleCreate(role *ACLRole, q *WriteOptions) (*ACLRole, *WriteMeta, if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out ACLRole @@ -935,7 +981,7 @@ func (a *ACL) RoleUpdate(role *ACLRole, q *WriteOptions) (*ACLRole, *WriteMeta, if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out ACLRole @@ -954,7 +1000,7 @@ func (a *ACL) RoleDelete(roleID string, q *WriteOptions) (*WriteMeta, error) { if err != nil { return nil, err } - resp.Body.Close() + closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} return wm, nil @@ -968,7 +1014,7 @@ func (a *ACL) RoleRead(roleID string, q *QueryOptions) (*ACLRole, *QueryMeta, er if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -994,7 +1040,7 @@ func (a *ACL) RoleReadByName(roleName string, q *QueryOptions) (*ACLRole, *Query if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -1022,7 +1068,7 @@ func (a *ACL) RoleList(q *QueryOptions) ([]*ACLRole, *QueryMeta, error) { if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -1048,7 +1094,7 @@ func (a *ACL) AuthMethodCreate(method *ACLAuthMethod, q *WriteOptions) (*ACLAuth if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out ACLAuthMethod @@ -1072,7 +1118,7 @@ func (a *ACL) AuthMethodUpdate(method *ACLAuthMethod, q *WriteOptions) (*ACLAuth if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out ACLAuthMethod @@ -1095,7 +1141,7 @@ func (a *ACL) AuthMethodDelete(methodName string, q *WriteOptions) (*WriteMeta, if err != nil { return nil, err } - resp.Body.Close() + closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} return wm, nil @@ -1113,7 +1159,7 @@ func (a *ACL) AuthMethodRead(methodName string, q *QueryOptions) (*ACLAuthMethod if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -1141,7 +1187,7 @@ func (a *ACL) AuthMethodList(q *QueryOptions) ([]*ACLAuthMethodListEntry, *Query if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -1169,7 +1215,7 @@ func (a *ACL) BindingRuleCreate(rule *ACLBindingRule, q *WriteOptions) (*ACLBind if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out ACLBindingRule @@ -1194,7 +1240,7 @@ func (a *ACL) BindingRuleUpdate(rule *ACLBindingRule, q *WriteOptions) (*ACLBind if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out ACLBindingRule @@ -1213,7 +1259,7 @@ func (a *ACL) BindingRuleDelete(bindingRuleID string, q *WriteOptions) (*WriteMe if err != nil { return nil, err } - resp.Body.Close() + closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} return wm, nil @@ -1227,7 +1273,7 @@ func (a *ACL) BindingRuleRead(bindingRuleID string, q *QueryOptions) (*ACLBindin if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -1256,7 +1302,7 @@ func (a *ACL) BindingRuleList(methodName string, q *QueryOptions) ([]*ACLBinding if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -1279,7 +1325,7 @@ func (a *ACL) Login(auth *ACLLoginParams, q *WriteOptions) (*ACLToken, *WriteMet if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out ACLToken @@ -1297,7 +1343,7 @@ func (a *ACL) Logout(q *WriteOptions) (*WriteMeta, error) { if err != nil { return nil, err } - resp.Body.Close() + closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} return wm, nil @@ -1317,7 +1363,7 @@ func (a *ACL) OIDCAuthURL(auth *ACLOIDCAuthURLParams, q *WriteOptions) (string, if err != nil { return "", nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out aclOIDCAuthURLResponse @@ -1352,7 +1398,7 @@ func (a *ACL) OIDCCallback(auth *ACLOIDCCallbackParams, q *WriteOptions) (*ACLTo if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out ACLToken diff --git a/vendor/github.com/hashicorp/consul/api/agent.go b/vendor/github.com/hashicorp/consul/api/agent.go index a4cc143f..ec144c7f 100644 --- a/vendor/github.com/hashicorp/consul/api/agent.go +++ b/vendor/github.com/hashicorp/consul/api/agent.go @@ -3,6 +3,7 @@ package api import ( "bufio" "bytes" + "context" "fmt" "io" "net/http" @@ -62,6 +63,7 @@ type AgentCheck struct { ServiceID string ServiceName string Type string + ExposedPort int Definition HealthCheckDefinition Namespace string `json:",omitempty"` } @@ -81,6 +83,7 @@ type AgentService struct { Meta map[string]string Port int Address string + SocketPath string TaggedAddresses map[string]ServiceAddress `json:",omitempty"` Weights AgentWeights EnableTagOverride bool @@ -113,14 +116,17 @@ type AgentServiceConnect struct { // AgentServiceConnectProxyConfig is the proxy configuration in a connect-proxy // ServiceDefinition or response. type AgentServiceConnectProxyConfig struct { - DestinationServiceName string `json:",omitempty"` - DestinationServiceID string `json:",omitempty"` - LocalServiceAddress string `json:",omitempty"` - LocalServicePort int `json:",omitempty"` - Config map[string]interface{} `json:",omitempty" bexpr:"-"` - Upstreams []Upstream `json:",omitempty"` - MeshGateway MeshGatewayConfig `json:",omitempty"` - Expose ExposeConfig `json:",omitempty"` + DestinationServiceName string `json:",omitempty"` + DestinationServiceID string `json:",omitempty"` + LocalServiceAddress string `json:",omitempty"` + LocalServicePort int `json:",omitempty"` + LocalServiceSocketPath string `json:",omitempty"` + Mode ProxyMode `json:",omitempty"` + TransparentProxy *TransparentProxyConfig `json:",omitempty"` + Config map[string]interface{} `json:",omitempty" bexpr:"-"` + Upstreams []Upstream `json:",omitempty"` + MeshGateway MeshGatewayConfig `json:",omitempty"` + Expose ExposeConfig `json:",omitempty"` } const ( @@ -266,12 +272,23 @@ type AgentServiceRegistration struct { Namespace string `json:",omitempty" bexpr:"-" hash:"ignore"` } -//ServiceRegisterOpts is used to pass extra options to the service register. +// ServiceRegisterOpts is used to pass extra options to the service register. type ServiceRegisterOpts struct { //Missing healthchecks will be deleted from the agent. //Using this parameter allows to idempotently register a service and its checks without //having to manually deregister checks. ReplaceExistingChecks bool + + // ctx is an optional context pass through to the underlying HTTP + // request layer. Use WithContext() to set the context. + ctx context.Context +} + +// WithContext sets the context to be used for the request on a new ServiceRegisterOpts, +// and returns the opts. +func (o ServiceRegisterOpts) WithContext(ctx context.Context) ServiceRegisterOpts { + o.ctx = ctx + return o } // AgentCheckRegistration is used to register a new check @@ -301,6 +318,7 @@ type AgentServiceCheck struct { TCP string `json:",omitempty"` Status string `json:",omitempty"` Notes string `json:",omitempty"` + TLSServerName string `json:",omitempty"` TLSSkipVerify bool `json:",omitempty"` GRPC string `json:",omitempty"` GRPCUseTLS bool `json:",omitempty"` @@ -392,8 +410,11 @@ type Upstream struct { Datacenter string `json:",omitempty"` LocalBindAddress string `json:",omitempty"` LocalBindPort int `json:",omitempty"` + LocalBindSocketPath string `json:",omitempty"` + LocalBindSocketMode string `json:",omitempty"` Config map[string]interface{} `json:",omitempty" bexpr:"-"` MeshGateway MeshGatewayConfig `json:",omitempty"` + CentrallyConfigured bool `json:",omitempty" bexpr:"-"` } // Agent can be used to query the Agent endpoints @@ -417,7 +438,7 @@ func (a *Agent) Self() (map[string]map[string]interface{}, error) { if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var out map[string]map[string]interface{} if err := decodeBody(resp, &out); err != nil { @@ -435,7 +456,7 @@ func (a *Agent) Host() (map[string]interface{}, error) { if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var out map[string]interface{} if err := decodeBody(resp, &out); err != nil { @@ -452,7 +473,7 @@ func (a *Agent) Metrics() (*MetricsInfo, error) { if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var out *MetricsInfo if err := decodeBody(resp, &out); err != nil { @@ -468,7 +489,7 @@ func (a *Agent) Reload() error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -494,13 +515,20 @@ func (a *Agent) Checks() (map[string]*AgentCheck, error) { // ChecksWithFilter returns a subset of the locally registered checks that match // the given filter expression func (a *Agent) ChecksWithFilter(filter string) (map[string]*AgentCheck, error) { + return a.ChecksWithFilterOpts(filter, nil) +} + +// ChecksWithFilterOpts returns a subset of the locally registered checks that match +// the given filter expression and QueryOptions. +func (a *Agent) ChecksWithFilterOpts(filter string, q *QueryOptions) (map[string]*AgentCheck, error) { r := a.c.newRequest("GET", "/v1/agent/checks") + r.setQueryOptions(q) r.filterQuery(filter) _, resp, err := requireOK(a.c.doRequest(r)) if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var out map[string]*AgentCheck if err := decodeBody(resp, &out); err != nil { @@ -517,13 +545,20 @@ func (a *Agent) Services() (map[string]*AgentService, error) { // ServicesWithFilter returns a subset of the locally registered services that match // the given filter expression func (a *Agent) ServicesWithFilter(filter string) (map[string]*AgentService, error) { + return a.ServicesWithFilterOpts(filter, nil) +} + +// ServicesWithFilterOpts returns a subset of the locally registered services that match +// the given filter expression and QueryOptions. +func (a *Agent) ServicesWithFilterOpts(filter string, q *QueryOptions) (map[string]*AgentService, error) { r := a.c.newRequest("GET", "/v1/agent/services") + r.setQueryOptions(q) r.filterQuery(filter) _, resp, err := requireOK(a.c.doRequest(r)) if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var out map[string]*AgentService if err := decodeBody(resp, &out); err != nil { @@ -546,7 +581,7 @@ func (a *Agent) AgentHealthServiceByID(serviceID string) (string, *AgentServiceC if err != nil { return "", nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) // Service not Found if resp.StatusCode == http.StatusNotFound { return HealthCritical, nil, nil @@ -580,7 +615,7 @@ func (a *Agent) AgentHealthServiceByName(service string) (string, []AgentService if err != nil { return "", nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) // Service not Found if resp.StatusCode == http.StatusNotFound { return HealthCritical, nil, nil @@ -613,7 +648,7 @@ func (a *Agent) Service(serviceID string, q *QueryOptions) (*AgentService, *Quer if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -638,7 +673,7 @@ func (a *Agent) Members(wan bool) ([]*AgentMember, error) { if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var out []*AgentMember if err := decodeBody(resp, &out); err != nil { @@ -660,7 +695,7 @@ func (a *Agent) MembersOpts(opts MembersOpts) ([]*AgentMember, error) { if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var out []*AgentMember if err := decodeBody(resp, &out); err != nil { @@ -688,6 +723,7 @@ func (a *Agent) ServiceRegisterOpts(service *AgentServiceRegistration, opts Serv func (a *Agent) serviceRegister(service *AgentServiceRegistration, opts ServiceRegisterOpts) error { r := a.c.newRequest("PUT", "/v1/agent/service/register") r.obj = service + r.ctx = opts.ctx if opts.ReplaceExistingChecks { r.params.Set("replace-existing-checks", "true") } @@ -695,7 +731,7 @@ func (a *Agent) serviceRegister(service *AgentServiceRegistration, opts ServiceR if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -707,7 +743,20 @@ func (a *Agent) ServiceDeregister(serviceID string) error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) + return nil +} + +// ServiceDeregisterOpts is used to deregister a service with +// the local agent with QueryOptions. +func (a *Agent) ServiceDeregisterOpts(serviceID string, q *QueryOptions) error { + r := a.c.newRequest("PUT", "/v1/agent/service/deregister/"+serviceID) + r.setQueryOptions(q) + _, resp, err := requireOK(a.c.doRequest(r)) + if err != nil { + return err + } + closeResponseBody(resp) return nil } @@ -762,7 +811,7 @@ func (a *Agent) updateTTL(checkID, note, status string) error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -785,6 +834,10 @@ type checkUpdate struct { // strings for compatibility (though a newer version of Consul will still be // required to use this API). func (a *Agent) UpdateTTL(checkID, output, status string) error { + return a.UpdateTTLOpts(checkID, output, status, nil) +} + +func (a *Agent) UpdateTTLOpts(checkID, output, status string, q *QueryOptions) error { switch status { case "pass", HealthPassing: status = HealthPassing @@ -798,6 +851,7 @@ func (a *Agent) UpdateTTL(checkID, output, status string) error { endpoint := fmt.Sprintf("/v1/agent/check/update/%s", checkID) r := a.c.newRequest("PUT", endpoint) + r.setQueryOptions(q) r.obj = &checkUpdate{ Status: status, Output: output, @@ -807,7 +861,7 @@ func (a *Agent) UpdateTTL(checkID, output, status string) error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -820,19 +874,26 @@ func (a *Agent) CheckRegister(check *AgentCheckRegistration) error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } // CheckDeregister is used to deregister a check with // the local agent func (a *Agent) CheckDeregister(checkID string) error { + return a.CheckDeregisterOpts(checkID, nil) +} + +// CheckDeregisterOpts is used to deregister a check with +// the local agent using query options +func (a *Agent) CheckDeregisterOpts(checkID string, q *QueryOptions) error { r := a.c.newRequest("PUT", "/v1/agent/check/deregister/"+checkID) + r.setQueryOptions(q) _, resp, err := requireOK(a.c.doRequest(r)) if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -847,7 +908,7 @@ func (a *Agent) Join(addr string, wan bool) error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -858,7 +919,7 @@ func (a *Agent) Leave() error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -869,7 +930,7 @@ func (a *Agent) ForceLeave(node string) error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -882,7 +943,7 @@ func (a *Agent) ForceLeavePrune(node string) error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -895,7 +956,7 @@ func (a *Agent) ConnectAuthorize(auth *AgentAuthorizeParams) (*AgentAuthorize, e if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var out AgentAuthorize if err := decodeBody(resp, &out); err != nil { @@ -912,7 +973,7 @@ func (a *Agent) ConnectCARoots(q *QueryOptions) (*CARootList, *QueryMeta, error) if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -933,7 +994,7 @@ func (a *Agent) ConnectCALeaf(serviceID string, q *QueryOptions) (*LeafCert, *Qu if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -956,7 +1017,7 @@ func (a *Agent) EnableServiceMaintenance(serviceID, reason string) error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -969,7 +1030,7 @@ func (a *Agent) DisableServiceMaintenance(serviceID string) error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -983,7 +1044,7 @@ func (a *Agent) EnableNodeMaintenance(reason string) error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -996,7 +1057,7 @@ func (a *Agent) DisableNodeMaintenance() error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -1027,7 +1088,7 @@ func (a *Agent) monitor(loglevel string, logJSON bool, stopCh <-chan struct{}, q } logCh := make(chan string, 64) go func() { - defer resp.Body.Close() + defer closeResponseBody(resp) scanner := bufio.NewScanner(resp.Body) for { select { @@ -1135,7 +1196,7 @@ func (a *Agent) updateTokenOnce(target, token string, q *WriteOptions) (*WriteMe if err != nil { return nil, 0, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} diff --git a/vendor/github.com/hashicorp/consul/api/api.go b/vendor/github.com/hashicorp/consul/api/api.go index 08f00c40..a35980a9 100644 --- a/vendor/github.com/hashicorp/consul/api/api.go +++ b/vendor/github.com/hashicorp/consul/api/api.go @@ -14,6 +14,7 @@ import ( "os" "strconv" "strings" + "sync" "time" "github.com/hashicorp/go-cleanhttp" @@ -548,9 +549,48 @@ func (c *Config) GenerateEnv() []string { // Client provides a client to the Consul API type Client struct { + modifyLock sync.RWMutex + headers http.Header + config Config } +// Headers gets the current set of headers used for requests. This returns a +// copy; to modify it call AddHeader or SetHeaders. +func (c *Client) Headers() http.Header { + c.modifyLock.RLock() + defer c.modifyLock.RUnlock() + + if c.headers == nil { + return nil + } + + ret := make(http.Header) + for k, v := range c.headers { + for _, val := range v { + ret[k] = append(ret[k], val) + } + } + + return ret +} + +// AddHeader allows a single header key/value pair to be added +// in a race-safe fashion. +func (c *Client) AddHeader(key, value string) { + c.modifyLock.Lock() + defer c.modifyLock.Unlock() + c.headers.Add(key, value) +} + +// SetHeaders clears all previous headers and uses only the given +// ones going forward. +func (c *Client) SetHeaders(headers http.Header) { + c.modifyLock.Lock() + defer c.modifyLock.Unlock() + c.headers = headers +} + // NewClient returns a new client func NewClient(config *Config) (*Client, error) { // bootstrap the config @@ -640,7 +680,7 @@ func NewClient(config *Config) (*Client, error) { config.Token = defConfig.Token } - return &Client{config: *config}, nil + return &Client{config: *config, headers: make(http.Header)}, nil } // NewHttpClient returns an http client configured with the given Transport and TLS @@ -831,6 +871,12 @@ func (r *request) toHTTP() (*http.Request, error) { req.Host = r.url.Host req.Header = r.header + // Content-Type must always be set when a body is present + // See https://github.com/hashicorp/consul/issues/10011 + if req.Body != nil && req.Header.Get("Content-Type") == "" { + req.Header.Set("Content-Type", "application/json") + } + // Setup auth if r.config.HttpAuth != nil { req.SetBasicAuth(r.config.HttpAuth.Username, r.config.HttpAuth.Password) @@ -853,8 +899,9 @@ func (c *Client) newRequest(method, path string) *request { Path: path, }, params: make(map[string][]string), - header: make(http.Header), + header: c.Headers(), } + if c.config.Datacenter != "" { r.params.Set("dc", c.config.Datacenter) } @@ -892,7 +939,7 @@ func (c *Client) query(endpoint string, out interface{}, q *QueryOptions) (*Quer if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -914,7 +961,7 @@ func (c *Client) write(endpoint string, in, out interface{}, q *WriteOptions) (* if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} if out != nil { @@ -1008,7 +1055,7 @@ func encodeBody(obj interface{}) (io.Reader, error) { func requireOK(d time.Duration, resp *http.Response, e error) (time.Duration, *http.Response, error) { if e != nil { if resp != nil { - resp.Body.Close() + closeResponseBody(resp) } return d, nil, e } @@ -1018,6 +1065,14 @@ func requireOK(d time.Duration, resp *http.Response, e error) (time.Duration, *h return d, resp, nil } +// closeResponseBody reads resp.Body until EOF, and then closes it. The read +// is necessary to ensure that the http.Client's underlying RoundTripper is able +// to re-use the TCP connection. See godoc on net/http.Client.Do. +func closeResponseBody(resp *http.Response) error { + _, _ = io.Copy(ioutil.Discard, resp.Body) + return resp.Body.Close() +} + func (req *request) filterQuery(filter string) { if filter == "" { return @@ -1032,14 +1087,14 @@ func (req *request) filterQuery(filter string) { func generateUnexpectedResponseCodeError(resp *http.Response) error { var buf bytes.Buffer io.Copy(&buf, resp.Body) - resp.Body.Close() + closeResponseBody(resp) return fmt.Errorf("Unexpected response code: %d (%s)", resp.StatusCode, buf.Bytes()) } func requireNotFoundOrOK(d time.Duration, resp *http.Response, e error) (bool, time.Duration, *http.Response, error) { if e != nil { if resp != nil { - resp.Body.Close() + closeResponseBody(resp) } return false, d, nil, e } diff --git a/vendor/github.com/hashicorp/consul/api/catalog.go b/vendor/github.com/hashicorp/consul/api/catalog.go index 607d5d06..b8588d82 100644 --- a/vendor/github.com/hashicorp/consul/api/catalog.go +++ b/vendor/github.com/hashicorp/consul/api/catalog.go @@ -122,7 +122,7 @@ func (c *Catalog) Register(reg *CatalogRegistration, q *WriteOptions) (*WriteMet if err != nil { return nil, err } - resp.Body.Close() + closeResponseBody(resp) wm := &WriteMeta{} wm.RequestTime = rtt @@ -138,7 +138,7 @@ func (c *Catalog) Deregister(dereg *CatalogDeregistration, q *WriteOptions) (*Wr if err != nil { return nil, err } - resp.Body.Close() + closeResponseBody(resp) wm := &WriteMeta{} wm.RequestTime = rtt @@ -153,7 +153,7 @@ func (c *Catalog) Datacenters() ([]string, error) { if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var out []string if err := decodeBody(resp, &out); err != nil { @@ -170,7 +170,7 @@ func (c *Catalog) Nodes(q *QueryOptions) ([]*Node, *QueryMeta, error) { if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -191,7 +191,7 @@ func (c *Catalog) Services(q *QueryOptions) (map[string][]string, *QueryMeta, er if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -248,7 +248,7 @@ func (c *Catalog) service(service string, tags []string, q *QueryOptions, connec if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -269,7 +269,7 @@ func (c *Catalog) Node(node string, q *QueryOptions) (*CatalogNode, *QueryMeta, if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -293,7 +293,7 @@ func (c *Catalog) NodeServiceList(node string, q *QueryOptions) (*CatalogNodeSer if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -314,7 +314,7 @@ func (c *Catalog) GatewayServices(gateway string, q *QueryOptions) ([]*GatewaySe if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) diff --git a/vendor/github.com/hashicorp/consul/api/config_entry.go b/vendor/github.com/hashicorp/consul/api/config_entry.go index f5ef60e2..e28c7dc1 100644 --- a/vendor/github.com/hashicorp/consul/api/config_entry.go +++ b/vendor/github.com/hashicorp/consul/api/config_entry.go @@ -21,8 +21,10 @@ const ( IngressGateway string = "ingress-gateway" TerminatingGateway string = "terminating-gateway" ServiceIntentions string = "service-intentions" + MeshConfig string = "mesh" ProxyConfigGlobal string = "global" + MeshConfigMesh string = "mesh" ) type ConfigEntry interface { @@ -46,8 +48,8 @@ const ( // should be direct and not flow through a mesh gateway. MeshGatewayModeNone MeshGatewayMode = "none" - // MeshGatewayModeLocal represents that the Upstrea Connect connections - // should be made to a mesh gateway in the local datacenter. This is + // MeshGatewayModeLocal represents that the Upstream Connect connections + // should be made to a mesh gateway in the local datacenter. MeshGatewayModeLocal MeshGatewayMode = "local" // MeshGatewayModeRemote represents that the Upstream Connect connections @@ -62,6 +64,33 @@ type MeshGatewayConfig struct { Mode MeshGatewayMode `json:",omitempty"` } +type ProxyMode string + +const ( + // ProxyModeDefault represents no specific mode and should + // be used to indicate that a different layer of the configuration + // chain should take precedence + ProxyModeDefault ProxyMode = "" + + // ProxyModeTransparent represents that inbound and outbound application + // traffic is being captured and redirected through the proxy. + ProxyModeTransparent ProxyMode = "transparent" + + // ProxyModeDirect represents that the proxy's listeners must be dialed directly + // by the local application and other proxies. + ProxyModeDirect ProxyMode = "direct" +) + +type TransparentProxyConfig struct { + // The port of the listener where outbound application traffic is being redirected to. + OutboundListenerPort int `json:",omitempty" alias:"outbound_listener_port"` + + // DialedDirectly indicates whether transparent proxies can dial this proxy instance directly. + // The discovery chain is not considered when dialing a service instance directly. + // This setting is useful when addressing stateful services, such as a database cluster with a leader node. + DialedDirectly bool `json:",omitempty" alias:"dialed_directly"` +} + // ExposeConfig describes HTTP paths to expose through Envoy outside of Connect. // Users can expose individual paths and/or all HTTP/GRPC paths for checks. type ExposeConfig struct { @@ -91,14 +120,100 @@ type ExposePath struct { ParsedFromCheck bool } +type UpstreamConfiguration struct { + // Overrides is a slice of per-service configuration. The name field is + // required. + Overrides []*UpstreamConfig `json:",omitempty"` + + // Defaults contains default configuration for all upstreams of a given + // service. The name field must be empty. + Defaults *UpstreamConfig `json:",omitempty"` +} + +type UpstreamConfig struct { + // Name is only accepted within a service-defaults config entry. + Name string `json:",omitempty"` + // Namespace is only accepted within a service-defaults config entry. + Namespace string `json:",omitempty"` + + // EnvoyListenerJSON is a complete override ("escape hatch") for the upstream's + // listener. + // + // Note: This escape hatch is NOT compatible with the discovery chain and + // will be ignored if a discovery chain is active. + EnvoyListenerJSON string `json:",omitempty" alias:"envoy_listener_json"` + + // EnvoyClusterJSON is a complete override ("escape hatch") for the upstream's + // cluster. The Connect client TLS certificate and context will be injected + // overriding any TLS settings present. + // + // Note: This escape hatch is NOT compatible with the discovery chain and + // will be ignored if a discovery chain is active. + EnvoyClusterJSON string `json:",omitempty" alias:"envoy_cluster_json"` + + // Protocol describes the upstream's service protocol. Valid values are "tcp", + // "http" and "grpc". Anything else is treated as tcp. The enables protocol + // aware features like per-request metrics and connection pooling, tracing, + // routing etc. + Protocol string `json:",omitempty"` + + // ConnectTimeoutMs is the number of milliseconds to timeout making a new + // connection to this upstream. Defaults to 5000 (5 seconds) if not set. + ConnectTimeoutMs int `json:",omitempty" alias:"connect_timeout_ms"` + + // Limits are the set of limits that are applied to the proxy for a specific upstream of a + // service instance. + Limits *UpstreamLimits `json:",omitempty"` + + // PassiveHealthCheck configuration determines how upstream proxy instances will + // be monitored for removal from the load balancing pool. + PassiveHealthCheck *PassiveHealthCheck `json:",omitempty" alias:"passive_health_check"` + + // MeshGatewayConfig controls how Mesh Gateways are configured and used + MeshGateway MeshGatewayConfig `json:",omitempty" alias:"mesh_gateway" ` +} + +type PassiveHealthCheck struct { + // Interval between health check analysis sweeps. Each sweep may remove + // hosts or return hosts to the pool. + Interval time.Duration `json:",omitempty"` + + // MaxFailures is the count of consecutive failures that results in a host + // being removed from the pool. + MaxFailures uint32 `alias:"max_failures"` +} + +// UpstreamLimits describes the limits that are associated with a specific +// upstream of a service instance. +type UpstreamLimits struct { + // MaxConnections is the maximum number of connections the local proxy can + // make to the upstream service. + MaxConnections *int `alias:"max_connections"` + + // MaxPendingRequests is the maximum number of requests that will be queued + // waiting for an available connection. This is mostly applicable to HTTP/1.1 + // clusters since all HTTP/2 requests are streamed over a single + // connection. + MaxPendingRequests *int `alias:"max_pending_requests"` + + // MaxConcurrentRequests is the maximum number of in-flight requests that will be allowed + // to the upstream cluster at a point in time. This is mostly applicable to HTTP/2 + // clusters since all HTTP/1.1 requests are limited by MaxConnections. + MaxConcurrentRequests *int `alias:"max_concurrent_requests"` +} + type ServiceConfigEntry struct { - Kind string - Name string - Namespace string `json:",omitempty"` - Protocol string `json:",omitempty"` - MeshGateway MeshGatewayConfig `json:",omitempty" alias:"mesh_gateway"` - Expose ExposeConfig `json:",omitempty"` - ExternalSNI string `json:",omitempty" alias:"external_sni"` + Kind string + Name string + Namespace string `json:",omitempty"` + Protocol string `json:",omitempty"` + Mode ProxyMode `json:",omitempty"` + TransparentProxy *TransparentProxyConfig `json:",omitempty" alias:"transparent_proxy"` + MeshGateway MeshGatewayConfig `json:",omitempty" alias:"mesh_gateway"` + Expose ExposeConfig `json:",omitempty"` + ExternalSNI string `json:",omitempty" alias:"external_sni"` + UpstreamConfig *UpstreamConfiguration `json:",omitempty" alias:"upstream_config"` + Meta map[string]string `json:",omitempty"` CreateIndex uint64 ModifyIndex uint64 @@ -129,15 +244,17 @@ func (s *ServiceConfigEntry) GetModifyIndex() uint64 { } type ProxyConfigEntry struct { - Kind string - Name string - Namespace string `json:",omitempty"` - Config map[string]interface{} `json:",omitempty"` - MeshGateway MeshGatewayConfig `json:",omitempty" alias:"mesh_gateway"` - Expose ExposeConfig `json:",omitempty"` - Meta map[string]string `json:",omitempty"` - CreateIndex uint64 - ModifyIndex uint64 + Kind string + Name string + Namespace string `json:",omitempty"` + Mode ProxyMode `json:",omitempty"` + TransparentProxy *TransparentProxyConfig `json:",omitempty" alias:"transparent_proxy"` + Config map[string]interface{} `json:",omitempty"` + MeshGateway MeshGatewayConfig `json:",omitempty" alias:"mesh_gateway"` + Expose ExposeConfig `json:",omitempty"` + Meta map[string]string `json:",omitempty"` + CreateIndex uint64 + ModifyIndex uint64 } func (p *ProxyConfigEntry) GetKind() string { @@ -182,6 +299,8 @@ func makeConfigEntry(kind, name string) (ConfigEntry, error) { return &TerminatingGatewayConfigEntry{Kind: kind, Name: name}, nil case ServiceIntentions: return &ServiceIntentionsConfigEntry{Kind: kind, Name: name}, nil + case MeshConfig: + return &MeshConfigEntry{}, nil default: return nil, fmt.Errorf("invalid config entry kind: %s", kind) } @@ -288,7 +407,7 @@ func (conf *ConfigEntries) Get(kind string, name string, q *QueryOptions) (Confi return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -313,7 +432,7 @@ func (conf *ConfigEntries) List(kind string, q *QueryOptions) ([]ConfigEntry, *Q return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -351,7 +470,7 @@ func (conf *ConfigEntries) set(entry ConfigEntry, params map[string]string, w *W if err != nil { return false, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var buf bytes.Buffer if _, err := io.Copy(&buf, resp.Body); err != nil { @@ -374,7 +493,7 @@ func (conf *ConfigEntries) Delete(kind string, name string, w *WriteOptions) (*W if err != nil { return nil, err } - resp.Body.Close() + closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} return wm, nil } diff --git a/vendor/github.com/hashicorp/consul/api/config_entry_cluster.go b/vendor/github.com/hashicorp/consul/api/config_entry_cluster.go new file mode 100644 index 00000000..9ec18ea6 --- /dev/null +++ b/vendor/github.com/hashicorp/consul/api/config_entry_cluster.go @@ -0,0 +1,53 @@ +package api + +import "encoding/json" + +type MeshConfigEntry struct { + Namespace string `json:",omitempty"` + TransparentProxy TransparentProxyMeshConfig `alias:"transparent_proxy"` + Meta map[string]string `json:",omitempty"` + CreateIndex uint64 + ModifyIndex uint64 +} + +type TransparentProxyMeshConfig struct { + MeshDestinationsOnly bool `alias:"mesh_destinations_only"` +} + +func (e *MeshConfigEntry) GetKind() string { + return MeshConfig +} + +func (e *MeshConfigEntry) GetName() string { + return MeshConfigMesh +} + +func (e *MeshConfigEntry) GetNamespace() string { + return e.Namespace +} + +func (e *MeshConfigEntry) GetMeta() map[string]string { + return e.Meta +} + +func (e *MeshConfigEntry) GetCreateIndex() uint64 { + return e.CreateIndex +} + +func (e *MeshConfigEntry) GetModifyIndex() uint64 { + return e.ModifyIndex +} + +// MarshalJSON adds the Kind field so that the JSON can be decoded back into the +// correct type. +func (e *MeshConfigEntry) MarshalJSON() ([]byte, error) { + type Alias MeshConfigEntry + source := &struct { + Kind string + *Alias + }{ + Kind: MeshConfig, + Alias: (*Alias)(e), + } + return json.Marshal(source) +} diff --git a/vendor/github.com/hashicorp/consul/api/connect_ca.go b/vendor/github.com/hashicorp/consul/api/connect_ca.go index 26a7bfb1..f8a83dc1 100644 --- a/vendor/github.com/hashicorp/consul/api/connect_ca.go +++ b/vendor/github.com/hashicorp/consul/api/connect_ca.go @@ -23,6 +23,14 @@ type CAConfig struct { // configuration is an error. State map[string]string + // ForceWithoutCrossSigning indicates that the CA reconfiguration should go + // ahead even if the current CA is unable to cross sign certificates. This + // risks temporary connection failures during the rollout as new leafs will be + // rejected by proxies that have not yet observed the new root cert but is the + // only option if a CA that doesn't support cross signing needs to be + // reconfigured or mirated away from. + ForceWithoutCrossSigning bool + CreateIndex uint64 ModifyIndex uint64 } @@ -130,7 +138,7 @@ func (h *Connect) CARoots(q *QueryOptions) (*CARootList, *QueryMeta, error) { if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -151,7 +159,7 @@ func (h *Connect) CAGetConfig(q *QueryOptions) (*CAConfig, *QueryMeta, error) { if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -173,7 +181,7 @@ func (h *Connect) CASetConfig(conf *CAConfig, q *WriteOptions) (*WriteMeta, erro if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{} wm.RequestTime = rtt diff --git a/vendor/github.com/hashicorp/consul/api/connect_intention.go b/vendor/github.com/hashicorp/consul/api/connect_intention.go index 26fb6cc4..d1f0b653 100644 --- a/vendor/github.com/hashicorp/consul/api/connect_intention.go +++ b/vendor/github.com/hashicorp/consul/api/connect_intention.go @@ -170,7 +170,7 @@ func (h *Connect) Intentions(q *QueryOptions) ([]*Intention, *QueryMeta, error) if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -194,7 +194,7 @@ func (h *Connect) IntentionGetExact(source, destination string, q *QueryOptions) if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -226,7 +226,7 @@ func (h *Connect) IntentionGet(id string, q *QueryOptions) (*Intention, *QueryMe if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -259,7 +259,7 @@ func (h *Connect) IntentionDeleteExact(source, destination string, q *WriteOptio if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &WriteMeta{} qm.RequestTime = rtt @@ -277,7 +277,7 @@ func (h *Connect) IntentionDelete(id string, q *WriteOptions) (*WriteMeta, error if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &WriteMeta{} qm.RequestTime = rtt @@ -303,7 +303,7 @@ func (h *Connect) IntentionMatch(args *IntentionMatch, q *QueryOptions) (map[str if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -330,7 +330,7 @@ func (h *Connect) IntentionCheck(args *IntentionCheck, q *QueryOptions) (bool, * if err != nil { return false, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -355,7 +355,7 @@ func (c *Connect) IntentionUpsert(ixn *Intention, q *WriteOptions) (*WriteMeta, if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{} wm.RequestTime = rtt @@ -382,7 +382,7 @@ func (c *Connect) IntentionCreate(ixn *Intention, q *WriteOptions) (string, *Wri if err != nil { return "", nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{} wm.RequestTime = rtt @@ -406,7 +406,7 @@ func (c *Connect) IntentionUpdate(ixn *Intention, q *WriteOptions) (*WriteMeta, if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{} wm.RequestTime = rtt diff --git a/vendor/github.com/hashicorp/consul/api/coordinate.go b/vendor/github.com/hashicorp/consul/api/coordinate.go index 776630f6..32c7822c 100644 --- a/vendor/github.com/hashicorp/consul/api/coordinate.go +++ b/vendor/github.com/hashicorp/consul/api/coordinate.go @@ -37,7 +37,7 @@ func (c *Coordinate) Datacenters() ([]*CoordinateDatacenterMap, error) { if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var out []*CoordinateDatacenterMap if err := decodeBody(resp, &out); err != nil { @@ -54,7 +54,7 @@ func (c *Coordinate) Nodes(q *QueryOptions) ([]*CoordinateEntry, *QueryMeta, err if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -76,7 +76,7 @@ func (c *Coordinate) Update(coord *CoordinateEntry, q *WriteOptions) (*WriteMeta if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{} wm.RequestTime = rtt @@ -92,7 +92,7 @@ func (c *Coordinate) Node(node string, q *QueryOptions) ([]*CoordinateEntry, *Qu if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) diff --git a/vendor/github.com/hashicorp/consul/api/debug.go b/vendor/github.com/hashicorp/consul/api/debug.go index 23804685..56dcc9bc 100644 --- a/vendor/github.com/hashicorp/consul/api/debug.go +++ b/vendor/github.com/hashicorp/consul/api/debug.go @@ -27,7 +27,11 @@ func (d *Debug) Heap() ([]byte, error) { if err != nil { return nil, fmt.Errorf("error making request: %s", err) } - defer resp.Body.Close() + defer closeResponseBody(resp) + + if resp.StatusCode != 200 { + return nil, generateUnexpectedResponseCodeError(resp) + } // We return a raw response because we're just passing through a response // from the pprof handlers @@ -50,7 +54,11 @@ func (d *Debug) Profile(seconds int) ([]byte, error) { if err != nil { return nil, fmt.Errorf("error making request: %s", err) } - defer resp.Body.Close() + defer closeResponseBody(resp) + + if resp.StatusCode != 200 { + return nil, generateUnexpectedResponseCodeError(resp) + } // We return a raw response because we're just passing through a response // from the pprof handlers @@ -73,7 +81,11 @@ func (d *Debug) Trace(seconds int) ([]byte, error) { if err != nil { return nil, fmt.Errorf("error making request: %s", err) } - defer resp.Body.Close() + defer closeResponseBody(resp) + + if resp.StatusCode != 200 { + return nil, generateUnexpectedResponseCodeError(resp) + } // We return a raw response because we're just passing through a response // from the pprof handlers @@ -93,7 +105,11 @@ func (d *Debug) Goroutine() ([]byte, error) { if err != nil { return nil, fmt.Errorf("error making request: %s", err) } - defer resp.Body.Close() + defer closeResponseBody(resp) + + if resp.StatusCode != 200 { + return nil, generateUnexpectedResponseCodeError(resp) + } // We return a raw response because we're just passing through a response // from the pprof handlers diff --git a/vendor/github.com/hashicorp/consul/api/discovery_chain.go b/vendor/github.com/hashicorp/consul/api/discovery_chain.go index f67f881c..b78e6c3c 100644 --- a/vendor/github.com/hashicorp/consul/api/discovery_chain.go +++ b/vendor/github.com/hashicorp/consul/api/discovery_chain.go @@ -43,7 +43,7 @@ func (d *DiscoveryChain) Get(name string, opts *DiscoveryChainOptions, q *QueryO if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) diff --git a/vendor/github.com/hashicorp/consul/api/event.go b/vendor/github.com/hashicorp/consul/api/event.go index 85b5b069..1da41375 100644 --- a/vendor/github.com/hashicorp/consul/api/event.go +++ b/vendor/github.com/hashicorp/consul/api/event.go @@ -45,12 +45,13 @@ func (e *Event) Fire(params *UserEvent, q *WriteOptions) (string, *WriteMeta, er if params.Payload != nil { r.body = bytes.NewReader(params.Payload) } + r.header.Set("Content-Type", "application/octet-stream") rtt, resp, err := requireOK(e.c.doRequest(r)) if err != nil { return "", nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out UserEvent @@ -74,7 +75,7 @@ func (e *Event) List(name string, q *QueryOptions) ([]*UserEvent, *QueryMeta, er if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) diff --git a/vendor/github.com/hashicorp/consul/api/go.mod b/vendor/github.com/hashicorp/consul/api/go.mod index 89e6e0c9..348ad8a7 100644 --- a/vendor/github.com/hashicorp/consul/api/go.mod +++ b/vendor/github.com/hashicorp/consul/api/go.mod @@ -5,7 +5,7 @@ go 1.12 replace github.com/hashicorp/consul/sdk => ../sdk require ( - github.com/hashicorp/consul/sdk v0.7.0 + github.com/hashicorp/consul/sdk v0.8.0 github.com/hashicorp/go-cleanhttp v0.5.1 github.com/hashicorp/go-hclog v0.12.0 github.com/hashicorp/go-rootcerts v1.0.2 diff --git a/vendor/github.com/hashicorp/consul/api/go.sum b/vendor/github.com/hashicorp/consul/api/go.sum index 57ef5439..b95bd474 100644 --- a/vendor/github.com/hashicorp/consul/api/go.sum +++ b/vendor/github.com/hashicorp/consul/api/go.sum @@ -7,7 +7,6 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= @@ -23,7 +22,6 @@ github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxB github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3 h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI= github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= @@ -49,18 +47,15 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/miekg/dns v1.0.14 h1:9jZdLNd/P4+SfEJ0TNyxYpsK8N4GtfylBLqtbYN1sbA= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26 h1:gPxPSwALAeHJSjarOs00QjVdV9QoBvc1D2ujQUr5BzU= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= @@ -83,11 +78,11 @@ github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSg github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3 h1:KYQXGkl6vs02hK7pK4eIbw0NpNPedieTSTEiJ//bwGs= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392 h1:ACG4HJsFiNMf47Y4PeRoebLNy/2lXT9EtprMuTFWt1M= @@ -97,22 +92,18 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5 h1:x6r4Jo0KNzOOzYd8lbcRsqjuqEASK6ob3auvWYM4/8U= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be h1:QAcqgptGM8IQBC9K/RC4o+O9YmqEm0diQn9QmZw/0mU= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 h1:1/DFK4b7JH8DmkqhUk48onnSfrPzImPoVxuomtbT2nk= golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -121,11 +112,9 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/hashicorp/consul/api/health.go b/vendor/github.com/hashicorp/consul/api/health.go index 99b9ac25..0a3fd8dd 100644 --- a/vendor/github.com/hashicorp/consul/api/health.go +++ b/vendor/github.com/hashicorp/consul/api/health.go @@ -58,6 +58,7 @@ type HealthCheckDefinition struct { Header map[string][]string Method string Body string + TLSServerName string TLSSkipVerify bool TCP string IntervalDuration time.Duration `json:"-"` @@ -233,7 +234,7 @@ func (h *Health) Node(node string, q *QueryOptions) (HealthChecks, *QueryMeta, e if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -254,7 +255,7 @@ func (h *Health) Checks(service string, q *QueryOptions) (HealthChecks, *QueryMe if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -331,7 +332,7 @@ func (h *Health) service(service string, tags []string, passingOnly bool, q *Que if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -361,7 +362,7 @@ func (h *Health) State(state string, q *QueryOptions) (HealthChecks, *QueryMeta, if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) diff --git a/vendor/github.com/hashicorp/consul/api/kv.go b/vendor/github.com/hashicorp/consul/api/kv.go index 351d287d..1d5c1129 100644 --- a/vendor/github.com/hashicorp/consul/api/kv.go +++ b/vendor/github.com/hashicorp/consul/api/kv.go @@ -69,7 +69,7 @@ func (k *KV) Get(key string, q *QueryOptions) (*KVPair, *QueryMeta, error) { if resp == nil { return nil, qm, nil } - defer resp.Body.Close() + defer closeResponseBody(resp) var entries []*KVPair if err := decodeBody(resp, &entries); err != nil { @@ -90,7 +90,7 @@ func (k *KV) List(prefix string, q *QueryOptions) (KVPairs, *QueryMeta, error) { if resp == nil { return nil, qm, nil } - defer resp.Body.Close() + defer closeResponseBody(resp) var entries []*KVPair if err := decodeBody(resp, &entries); err != nil { @@ -113,7 +113,7 @@ func (k *KV) Keys(prefix, separator string, q *QueryOptions) ([]string, *QueryMe if resp == nil { return nil, qm, nil } - defer resp.Body.Close() + defer closeResponseBody(resp) var entries []string if err := decodeBody(resp, &entries); err != nil { @@ -138,10 +138,10 @@ func (k *KV) getInternal(key string, params map[string]string, q *QueryOptions) qm.RequestTime = rtt if resp.StatusCode == 404 { - resp.Body.Close() + closeResponseBody(resp) return nil, qm, nil } else if resp.StatusCode != 200 { - resp.Body.Close() + closeResponseBody(resp) return nil, nil, fmt.Errorf("Unexpected response code: %d", resp.StatusCode) } return resp, qm, nil @@ -205,11 +205,12 @@ func (k *KV) put(key string, params map[string]string, body []byte, q *WriteOpti r.params.Set(param, val) } r.body = bytes.NewReader(body) + r.header.Set("Content-Type", "application/octet-stream") rtt, resp, err := requireOK(k.c.doRequest(r)) if err != nil { return false, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &WriteMeta{} qm.RequestTime = rtt @@ -253,7 +254,7 @@ func (k *KV) deleteInternal(key string, params map[string]string, q *WriteOption if err != nil { return false, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &WriteMeta{} qm.RequestTime = rtt diff --git a/vendor/github.com/hashicorp/consul/api/namespace.go b/vendor/github.com/hashicorp/consul/api/namespace.go index 49782d2a..20f6c8d5 100644 --- a/vendor/github.com/hashicorp/consul/api/namespace.go +++ b/vendor/github.com/hashicorp/consul/api/namespace.go @@ -67,7 +67,7 @@ func (n *Namespaces) Create(ns *Namespace, q *WriteOptions) (*Namespace, *WriteM if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out Namespace @@ -90,7 +90,7 @@ func (n *Namespaces) Update(ns *Namespace, q *WriteOptions) (*Namespace, *WriteM if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} var out Namespace @@ -109,7 +109,7 @@ func (n *Namespaces) Read(name string, q *QueryOptions) (*Namespace, *QueryMeta, if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) @@ -132,7 +132,7 @@ func (n *Namespaces) Delete(name string, q *WriteOptions) (*WriteMeta, error) { if err != nil { return nil, err } - resp.Body.Close() + closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} return wm, nil @@ -146,7 +146,7 @@ func (n *Namespaces) List(q *QueryOptions) ([]*Namespace, *QueryMeta, error) { if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) diff --git a/vendor/github.com/hashicorp/consul/api/operator_area.go b/vendor/github.com/hashicorp/consul/api/operator_area.go index 5cf7e497..5476f5c5 100644 --- a/vendor/github.com/hashicorp/consul/api/operator_area.go +++ b/vendor/github.com/hashicorp/consul/api/operator_area.go @@ -93,7 +93,7 @@ func (op *Operator) AreaCreate(area *Area, q *WriteOptions) (string, *WriteMeta, if err != nil { return "", nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{} wm.RequestTime = rtt @@ -114,7 +114,7 @@ func (op *Operator) AreaUpdate(areaID string, area *Area, q *WriteOptions) (stri if err != nil { return "", nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{} wm.RequestTime = rtt @@ -154,7 +154,7 @@ func (op *Operator) AreaDelete(areaID string, q *WriteOptions) (*WriteMeta, erro if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{} wm.RequestTime = rtt @@ -171,7 +171,7 @@ func (op *Operator) AreaJoin(areaID string, addresses []string, q *WriteOptions) if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{} wm.RequestTime = rtt diff --git a/vendor/github.com/hashicorp/consul/api/operator_autopilot.go b/vendor/github.com/hashicorp/consul/api/operator_autopilot.go index 57876ee9..8175f513 100644 --- a/vendor/github.com/hashicorp/consul/api/operator_autopilot.go +++ b/vendor/github.com/hashicorp/consul/api/operator_autopilot.go @@ -284,7 +284,7 @@ func (op *Operator) AutopilotGetConfiguration(q *QueryOptions) (*AutopilotConfig if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var out AutopilotConfiguration if err := decodeBody(resp, &out); err != nil { @@ -303,7 +303,7 @@ func (op *Operator) AutopilotSetConfiguration(conf *AutopilotConfiguration, q *W if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -319,7 +319,7 @@ func (op *Operator) AutopilotCASConfiguration(conf *AutopilotConfiguration, q *W if err != nil { return false, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var buf bytes.Buffer if _, err := io.Copy(&buf, resp.Body); err != nil { @@ -334,11 +334,24 @@ func (op *Operator) AutopilotCASConfiguration(conf *AutopilotConfiguration, q *W func (op *Operator) AutopilotServerHealth(q *QueryOptions) (*OperatorHealthReply, error) { r := op.c.newRequest("GET", "/v1/operator/autopilot/health") r.setQueryOptions(q) - _, resp, err := requireOK(op.c.doRequest(r)) + + // we cannot just use requireOK because this endpoint might use a 429 status to indicate + // that unhealthiness + _, resp, err := op.c.doRequest(r) if err != nil { + if resp != nil { + closeResponseBody(resp) + } return nil, err } - defer resp.Body.Close() + + // these are the only 2 status codes that would indicate that we should + // expect the body to contain the right format. + if resp.StatusCode != 200 && resp.StatusCode != 429 { + return nil, generateUnexpectedResponseCodeError(resp) + } + + defer closeResponseBody(resp) var out OperatorHealthReply if err := decodeBody(resp, &out); err != nil { @@ -354,7 +367,7 @@ func (op *Operator) AutopilotState(q *QueryOptions) (*AutopilotState, error) { if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var out AutopilotState if err := decodeBody(resp, &out); err != nil { diff --git a/vendor/github.com/hashicorp/consul/api/operator_keyring.go b/vendor/github.com/hashicorp/consul/api/operator_keyring.go index 5b80f9f9..baad70ee 100644 --- a/vendor/github.com/hashicorp/consul/api/operator_keyring.go +++ b/vendor/github.com/hashicorp/consul/api/operator_keyring.go @@ -40,7 +40,7 @@ func (op *Operator) KeyringInstall(key string, q *WriteOptions) error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -52,7 +52,7 @@ func (op *Operator) KeyringList(q *QueryOptions) ([]*KeyringResponse, error) { if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var out []*KeyringResponse if err := decodeBody(resp, &out); err != nil { @@ -72,7 +72,7 @@ func (op *Operator) KeyringRemove(key string, q *WriteOptions) error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -87,6 +87,6 @@ func (op *Operator) KeyringUse(key string, q *WriteOptions) error { if err != nil { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } diff --git a/vendor/github.com/hashicorp/consul/api/operator_license.go b/vendor/github.com/hashicorp/consul/api/operator_license.go index 51b64cef..87904bd8 100644 --- a/vendor/github.com/hashicorp/consul/api/operator_license.go +++ b/vendor/github.com/hashicorp/consul/api/operator_license.go @@ -1,8 +1,8 @@ package api import ( + "fmt" "io/ioutil" - "strings" "time" ) @@ -66,7 +66,7 @@ func (op *Operator) LicenseGetSigned(q *QueryOptions) (string, error) { if err != nil { return "", err } - defer resp.Body.Close() + defer closeResponseBody(resp) data, err := ioutil.ReadAll(resp.Body) if err != nil { @@ -78,37 +78,17 @@ func (op *Operator) LicenseGetSigned(q *QueryOptions) (string, error) { // LicenseReset will reset the license to the builtin one if it is still valid. // If the builtin license is invalid, the current license stays active. -func (op *Operator) LicenseReset(opts *WriteOptions) (*LicenseReply, error) { - var reply LicenseReply - r := op.c.newRequest("DELETE", "/v1/operator/license") - r.setWriteOptions(opts) - _, resp, err := requireOK(op.c.doRequest(r)) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - if err := decodeBody(resp, &reply); err != nil { - return nil, err - } - - return &reply, nil +// +// DEPRECATED: Consul 1.10 removes the corresponding HTTP endpoint as licenses +// are now set via agent configuration instead of through the API +func (*Operator) LicenseReset(_ *WriteOptions) (*LicenseReply, error) { + return nil, fmt.Errorf("Consul 1.10 no longer supports API driven license management.") } -func (op *Operator) LicensePut(license string, opts *WriteOptions) (*LicenseReply, error) { - var reply LicenseReply - r := op.c.newRequest("PUT", "/v1/operator/license") - r.setWriteOptions(opts) - r.body = strings.NewReader(license) - _, resp, err := requireOK(op.c.doRequest(r)) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - if err := decodeBody(resp, &reply); err != nil { - return nil, err - } - - return &reply, nil +// LicensePut will configure the Consul Enterprise license for the target datacenter +// +// DEPRECATED: Consul 1.10 removes the corresponding HTTP endpoint as licenses +// are now set via agent configuration instead of through the API +func (*Operator) LicensePut(_ string, _ *WriteOptions) (*LicenseReply, error) { + return nil, fmt.Errorf("Consul 1.10 no longer supports API driven license management.") } diff --git a/vendor/github.com/hashicorp/consul/api/operator_raft.go b/vendor/github.com/hashicorp/consul/api/operator_raft.go index c6d7165d..0bfb85d0 100644 --- a/vendor/github.com/hashicorp/consul/api/operator_raft.go +++ b/vendor/github.com/hashicorp/consul/api/operator_raft.go @@ -44,7 +44,7 @@ func (op *Operator) RaftGetConfiguration(q *QueryOptions) (*RaftConfiguration, e if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var out RaftConfiguration if err := decodeBody(resp, &out); err != nil { @@ -67,7 +67,7 @@ func (op *Operator) RaftRemovePeerByAddress(address string, q *WriteOptions) err return err } - resp.Body.Close() + closeResponseBody(resp) return nil } @@ -84,6 +84,6 @@ func (op *Operator) RaftRemovePeerByID(id string, q *WriteOptions) error { return err } - resp.Body.Close() + closeResponseBody(resp) return nil } diff --git a/vendor/github.com/hashicorp/consul/api/prepared_query.go b/vendor/github.com/hashicorp/consul/api/prepared_query.go index 5ac2535c..5b2d5a5d 100644 --- a/vendor/github.com/hashicorp/consul/api/prepared_query.go +++ b/vendor/github.com/hashicorp/consul/api/prepared_query.go @@ -158,7 +158,7 @@ func (c *PreparedQuery) Create(query *PreparedQueryDefinition, q *WriteOptions) if err != nil { return "", nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{} wm.RequestTime = rtt @@ -204,7 +204,7 @@ func (c *PreparedQuery) Delete(queryID string, q *WriteOptions) (*WriteMeta, err if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{} wm.RequestTime = rtt diff --git a/vendor/github.com/hashicorp/consul/api/session.go b/vendor/github.com/hashicorp/consul/api/session.go index 157ad53f..3f61acfb 100644 --- a/vendor/github.com/hashicorp/consul/api/session.go +++ b/vendor/github.com/hashicorp/consul/api/session.go @@ -141,7 +141,7 @@ func (s *Session) Renew(id string, q *WriteOptions) (*SessionEntry, *WriteMeta, if err != nil { return nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) wm := &WriteMeta{RequestTime: rtt} diff --git a/vendor/github.com/hashicorp/consul/api/snapshot.go b/vendor/github.com/hashicorp/consul/api/snapshot.go index e902377d..0c8294f3 100644 --- a/vendor/github.com/hashicorp/consul/api/snapshot.go +++ b/vendor/github.com/hashicorp/consul/api/snapshot.go @@ -38,6 +38,7 @@ func (s *Snapshot) Save(q *QueryOptions) (io.ReadCloser, *QueryMeta, error) { func (s *Snapshot) Restore(q *WriteOptions, in io.Reader) error { r := s.c.newRequest("PUT", "/v1/snapshot") r.body = in + r.header.Set("Content-Type", "application/octet-stream") r.setWriteOptions(q) _, _, err := requireOK(s.c.doRequest(r)) if err != nil { diff --git a/vendor/github.com/hashicorp/consul/api/status.go b/vendor/github.com/hashicorp/consul/api/status.go index 57f379c7..2a81b9b5 100644 --- a/vendor/github.com/hashicorp/consul/api/status.go +++ b/vendor/github.com/hashicorp/consul/api/status.go @@ -22,7 +22,7 @@ func (s *Status) LeaderWithQueryOptions(q *QueryOptions) (string, error) { if err != nil { return "", err } - defer resp.Body.Close() + defer closeResponseBody(resp) var leader string if err := decodeBody(resp, &leader); err != nil { @@ -47,7 +47,7 @@ func (s *Status) PeersWithQueryOptions(q *QueryOptions) ([]string, error) { if err != nil { return nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) var peers []string if err := decodeBody(resp, &peers); err != nil { diff --git a/vendor/github.com/hashicorp/consul/api/txn.go b/vendor/github.com/hashicorp/consul/api/txn.go index ef06bcbf..55eb805f 100644 --- a/vendor/github.com/hashicorp/consul/api/txn.go +++ b/vendor/github.com/hashicorp/consul/api/txn.go @@ -221,7 +221,7 @@ func (c *Client) txn(txn TxnOps, q *QueryOptions) (bool, *TxnResponse, *QueryMet if err != nil { return false, nil, nil, err } - defer resp.Body.Close() + defer closeResponseBody(resp) qm := &QueryMeta{} parseQueryMeta(resp, qm) diff --git a/vendor/modules.txt b/vendor/modules.txt index 697e1ca5..f3770fd7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -18,7 +18,7 @@ github.com/go-redis/redis/v8/internal/pool github.com/go-redis/redis/v8/internal/proto github.com/go-redis/redis/v8/internal/rand github.com/go-redis/redis/v8/internal/util -# github.com/hashicorp/consul/api v1.8.1 +# github.com/hashicorp/consul/api v1.9.1 ## explicit github.com/hashicorp/consul/api github.com/hashicorp/consul/api/watch