MCPcopy
hub / github.com/hashicorp/memberlist / RemoveKey

Method RemoveKey

keyring.go:116–127  ·  view source on GitHub ↗

RemoveKey drops a key from the keyring. This will return an error if the key requested for removal is currently at position 0 (primary key).

(key []byte)

Source from the content-addressed store, hash-verified

114// RemoveKey drops a key from the keyring. This will return an error if the key
115// requested for removal is currently at position 0 (primary key).
116func (k *Keyring) RemoveKey(key []byte) error {
117 if bytes.Equal(key, k.keys[0]) {
118 return fmt.Errorf("removing the primary key is not allowed")
119 }
120 for i, installedKey := range k.keys {
121 if bytes.Equal(key, installedKey) {
122 keys := append(k.keys[:i], k.keys[i+1:]...)
123 k.installKeys(keys, k.keys[0])
124 }
125 }
126 return nil
127}
128
129// installKeys will take out a lock on the keyring, and replace the keys with a
130// new set of keys. The key indicated by primaryKey will be installed as the new

Callers 2

TestKeyring_AddRemoveUseFunction · 0.95

Calls 2

installKeysMethod · 0.95
ErrorfMethod · 0.80

Tested by 2

TestKeyring_AddRemoveUseFunction · 0.76