mirror of https://github.com/status-im/consul.git
agent: squash some more common keyring semantics
This commit is contained in:
parent
25845a39d3
commit
1f9d13dc73
|
@ -73,6 +73,10 @@ func (a *Agent) keyringProcess(
|
||||||
method string,
|
method string,
|
||||||
args *structs.KeyringRequest) (*structs.KeyringResponses, error) {
|
args *structs.KeyringRequest) (*structs.KeyringResponses, error) {
|
||||||
|
|
||||||
|
// Allow any server to handle the request, since this is
|
||||||
|
// done over the gossip protocol.
|
||||||
|
args.AllowStale = true
|
||||||
|
|
||||||
var reply structs.KeyringResponses
|
var reply structs.KeyringResponses
|
||||||
if a.server == nil {
|
if a.server == nil {
|
||||||
return nil, fmt.Errorf("keyring operations must run against a server node")
|
return nil, fmt.Errorf("keyring operations must run against a server node")
|
||||||
|
@ -87,32 +91,24 @@ func (a *Agent) keyringProcess(
|
||||||
// ListKeys lists out all keys installed on the collective Consul cluster. This
|
// ListKeys lists out all keys installed on the collective Consul cluster. This
|
||||||
// includes both servers and clients in all DC's.
|
// includes both servers and clients in all DC's.
|
||||||
func (a *Agent) ListKeys() (*structs.KeyringResponses, error) {
|
func (a *Agent) ListKeys() (*structs.KeyringResponses, error) {
|
||||||
args := structs.KeyringRequest{}
|
args := structs.KeyringRequest{Operation: structs.KeyringList}
|
||||||
args.AllowStale = true
|
|
||||||
args.Operation = structs.KeyringList
|
|
||||||
return a.keyringProcess("Internal.KeyringOperation", &args)
|
return a.keyringProcess("Internal.KeyringOperation", &args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// InstallKey installs a new gossip encryption key
|
// InstallKey installs a new gossip encryption key
|
||||||
func (a *Agent) InstallKey(key string) (*structs.KeyringResponses, error) {
|
func (a *Agent) InstallKey(key string) (*structs.KeyringResponses, error) {
|
||||||
args := structs.KeyringRequest{Key: key}
|
args := structs.KeyringRequest{Key: key, Operation: structs.KeyringInstall}
|
||||||
args.AllowStale = true
|
|
||||||
args.Operation = structs.KeyringInstall
|
|
||||||
return a.keyringProcess("Internal.KeyringOperation", &args)
|
return a.keyringProcess("Internal.KeyringOperation", &args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseKey changes the primary encryption key used to encrypt messages
|
// UseKey changes the primary encryption key used to encrypt messages
|
||||||
func (a *Agent) UseKey(key string) (*structs.KeyringResponses, error) {
|
func (a *Agent) UseKey(key string) (*structs.KeyringResponses, error) {
|
||||||
args := structs.KeyringRequest{Key: key}
|
args := structs.KeyringRequest{Key: key, Operation: structs.KeyringUse}
|
||||||
args.AllowStale = true
|
|
||||||
args.Operation = structs.KeyringUse
|
|
||||||
return a.keyringProcess("Internal.KeyringOperation", &args)
|
return a.keyringProcess("Internal.KeyringOperation", &args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveKey will remove a gossip encryption key from the keyring
|
// RemoveKey will remove a gossip encryption key from the keyring
|
||||||
func (a *Agent) RemoveKey(key string) (*structs.KeyringResponses, error) {
|
func (a *Agent) RemoveKey(key string) (*structs.KeyringResponses, error) {
|
||||||
args := structs.KeyringRequest{Key: key}
|
args := structs.KeyringRequest{Key: key, Operation: structs.KeyringRemove}
|
||||||
args.AllowStale = true
|
|
||||||
args.Operation = structs.KeyringRemove
|
|
||||||
return a.keyringProcess("Internal.KeyringOperation", &args)
|
return a.keyringProcess("Internal.KeyringOperation", &args)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,15 +12,6 @@ type Internal struct {
|
||||||
srv *Server
|
srv *Server
|
||||||
}
|
}
|
||||||
|
|
||||||
type KeyringOperation uint8
|
|
||||||
|
|
||||||
const (
|
|
||||||
listKeysOperation KeyringOperation = iota
|
|
||||||
installKeyOperation
|
|
||||||
useKeyOperation
|
|
||||||
removeKeyOperation
|
|
||||||
)
|
|
||||||
|
|
||||||
// ChecksInState is used to get all the checks in a given state
|
// ChecksInState is used to get all the checks in a given state
|
||||||
func (m *Internal) NodeInfo(args *structs.NodeSpecificRequest,
|
func (m *Internal) NodeInfo(args *structs.NodeSpecificRequest,
|
||||||
reply *structs.IndexedNodeDump) error {
|
reply *structs.IndexedNodeDump) error {
|
||||||
|
|
Loading…
Reference in New Issue