From 08eb600ee5e4eacfeef8223fc217973eeecdc692 Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Mon, 10 May 2021 10:15:35 -0400 Subject: [PATCH] Deprecate API driven licensing. The two methods in the API client to Put or Reset a license will now always return an error. --- .changelog/10211.txt | 3 +++ api/operator_license.go | 44 +++++++++++------------------------------ 2 files changed, 15 insertions(+), 32 deletions(-) create mode 100644 .changelog/10211.txt diff --git a/.changelog/10211.txt b/.changelog/10211.txt new file mode 100644 index 0000000000..1a5b801472 --- /dev/null +++ b/.changelog/10211.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +licensing: **(Enterprise Only)** Consul Enterprise 1.10 has removed API driven licensing of servers in favor of license loading via configuration. The `PUT` and `DELETE` methods on the `/v1/operator/license` endpoint will now return 405s, the `consul license put` and `consul license reset` CLI commands have been removed and the `LicensePut` and `LicenseReset` methods in the API client have been altered to always return an error. +``` \ No newline at end of file diff --git a/api/operator_license.go b/api/operator_license.go index 51b64cef48..2264148a8a 100644 --- a/api/operator_license.go +++ b/api/operator_license.go @@ -1,8 +1,8 @@ package api import ( + "fmt" "io/ioutil" - "strings" "time" ) @@ -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.") }