Deprecate API driven licensing.

The two methods in the API client to Put or Reset a license will now always return an error.
This commit is contained in:
Matt Keeler 2021-05-10 10:15:35 -04:00 committed by Matt Keeler
parent 67756e70c5
commit 64359617b5
2 changed files with 15 additions and 32 deletions

3
.changelog/10211.txt Normal file
View File

@ -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.
```

View File

@ -1,8 +1,8 @@
package api package api
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"strings"
"time" "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. // 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. // If the builtin license is invalid, the current license stays active.
func (op *Operator) LicenseReset(opts *WriteOptions) (*LicenseReply, error) { //
var reply LicenseReply // DEPRECATED: Consul 1.10 removes the corresponding HTTP endpoint as licenses
r := op.c.newRequest("DELETE", "/v1/operator/license") // are now set via agent configuration instead of through the API
r.setWriteOptions(opts) func (*Operator) LicenseReset(_ *WriteOptions) (*LicenseReply, error) {
_, resp, err := requireOK(op.c.doRequest(r)) return nil, fmt.Errorf("Consul 1.10 no longer supports API driven license management.")
if err != nil {
return nil, err
}
defer resp.Body.Close()
if err := decodeBody(resp, &reply); err != nil {
return nil, err
}
return &reply, nil
} }
func (op *Operator) LicensePut(license string, opts *WriteOptions) (*LicenseReply, error) { // LicensePut will configure the Consul Enterprise license for the target datacenter
var reply LicenseReply //
r := op.c.newRequest("PUT", "/v1/operator/license") // DEPRECATED: Consul 1.10 removes the corresponding HTTP endpoint as licenses
r.setWriteOptions(opts) // are now set via agent configuration instead of through the API
r.body = strings.NewReader(license) func (*Operator) LicensePut(_ string, _ *WriteOptions) (*LicenseReply, error) {
_, resp, err := requireOK(op.c.doRequest(r)) return nil, fmt.Errorf("Consul 1.10 no longer supports API driven license management.")
if err != nil {
return nil, err
}
defer resp.Body.Close()
if err := decodeBody(resp, &reply); err != nil {
return nil, err
}
return &reply, nil
} }