MCPcopy Create free account
hub / github.com/actiontech/dtle / GetRole

Method GetRole

driver/common/store.go:549–568  ·  view source on GitHub ↗
(tenant, name string)

Source from the content-addressed store, hash-verified

547}
548
549func (sm *StoreManager) GetRole(tenant, name string) (*Role, bool, error) {
550 key := fmt.Sprintf("dtleRole/%s/%s", tenant, name)
551 exists, err := sm.consulStore.Exists(key)
552 if err != nil {
553 return nil, exists, err
554 } else if !exists {
555 return nil, exists, nil
556 }
557
558 kp, err := sm.consulStore.Get(key)
559 if nil != err {
560 return nil, false, err
561 }
562 role := new(Role)
563 err = json.Unmarshal(kp.Value, role)
564 if err != nil {
565 return nil, false, fmt.Errorf("get %v from consul, unmarshal err : %v", key, err)
566 }
567 return role, true, nil
568}
569
570func (sm *StoreManager) SaveRole(role *Role) error {
571 key := fmt.Sprintf("dtleRole/%v/%v", role.Tenant, role.Name)

Callers 5

AuthFilterFunction · 0.95
UpdateRoleInfoFunction · 0.95
createUserFunction · 0.95
ListActionV2Function · 0.95
userHasAccessFunction · 0.80

Calls 2

GetMethod · 0.80
UnmarshalMethod · 0.65

Tested by

no test coverage detected