MCPcopy
hub / github.com/cubefs/cubefs / DeleteKey

Method DeleteKey

authnode/cluster.go:119–142  ·  view source on GitHub ↗

DeleteKey delete a key from the keystore

(id string)

Source from the content-addressed store, hash-verified

117
118// DeleteKey delete a key from the keystore
119func (c *Cluster) DeleteKey(id string) (res *keystore.KeyInfo, err error) {
120 c.fsm.opKeyMutex.Lock()
121 defer c.fsm.opKeyMutex.Unlock()
122 akInfo := new(keystore.AccessKeyInfo)
123 if res, err = c.fsm.GetKey(id); err != nil {
124 err = proto.ErrKeyNotExists
125 goto errHandler
126 }
127 if err = c.syncDeleteKey(res); err != nil {
128 goto errHandler
129 }
130 akInfo.AccessKey = res.AccessKey
131 akInfo.ID = res.ID
132 if err = c.syncDeleteAccessKey(akInfo); err != nil {
133 goto errHandler
134 }
135 c.fsm.DeleteKey(id)
136 c.fsm.DeleteAKInfo(akInfo.AccessKey)
137 return
138errHandler:
139 err = fmt.Errorf("action[DeleteKey], clusterID[%v] ID:%v, err:%v ", c.Name, id, err.Error())
140 log.LogError(errors.Stack(err))
141 return
142}
143
144// GetKey get a key from the keystore
145func (c *Cluster) GetKey(id string) (res *keystore.KeyInfo, err error) {

Callers 1

handleDeleteKeyMethod · 0.45

Calls 10

syncDeleteKeyMethod · 0.95
syncDeleteAccessKeyMethod · 0.95
LogErrorFunction · 0.92
StackFunction · 0.92
LockMethod · 0.80
DeleteAKInfoMethod · 0.80
ErrorfMethod · 0.65
ErrorMethod · 0.65
UnlockMethod · 0.45
GetKeyMethod · 0.45

Tested by

no test coverage detected