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

Method FindRoleList

driver/common/store.go:530–547  ·  view source on GitHub ↗
(tenant string)

Source from the content-addressed store, hash-verified

528}
529
530func (sm *StoreManager) FindRoleList(tenant string) ([]*Role, error) {
531 key := fmt.Sprintf("%s/%s", "dtleRole", tenant)
532 storeUsers, err := sm.consulStore.List(key)
533 if nil != err && err != store.ErrKeyNotFound {
534 return nil, fmt.Errorf("get %v value from consul failed: %v", key, err)
535 }
536 roleList := make([]*Role, 0)
537 for _, storeUser := range storeUsers {
538 role := new(Role)
539 err = json.Unmarshal(storeUser.Value, role)
540 if err != nil {
541 return nil, fmt.Errorf("get %v from consul, unmarshal err : %v", storeUser, err)
542 }
543 roleList = append(roleList, role)
544 }
545
546 return roleList, nil
547}
548
549func (sm *StoreManager) GetRole(tenant, name string) (*Role, bool, error) {
550 key := fmt.Sprintf("dtleRole/%s/%s", tenant, name)

Callers 1

RoleListV2Function · 0.95

Calls 1

UnmarshalMethod · 0.65

Tested by

no test coverage detected