示例#1
0
func readableServices(t auth.Token) ([]service.Service, error) {
	teams := []string{}
	serviceNames := []string{}
	contexts := permission.ContextsForPermission(t, permission.PermServiceRead)
	for _, c := range contexts {
		if c.CtxType == permission.CtxGlobal {
			teams = nil
			serviceNames = nil
			break
		}
		switch c.CtxType {
		case permission.CtxService:
			serviceNames = append(serviceNames, c.Value)
		case permission.CtxTeam:
			teams = append(teams, c.Value)
		}
	}
	return service.GetServicesByTeamsAndServices(teams, serviceNames)
}
示例#2
0
func readableServices(t auth.Token, contexts []permission.PermissionContext) ([]service.Service, error) {
	teams, serviceNames := filtersForServiceList(t, contexts)
	return service.GetServicesByTeamsAndServices(teams, serviceNames)
}