-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from closetool/master
feat: add implementation of Adapter
- Loading branch information
Showing
32 changed files
with
6,357 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Go | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
mysql: | ||
image: mysql:5.7 | ||
env: | ||
MYSQL_ALLOW_EMPTY_PASSWORD: yes | ||
MYSQL_DATABASE: casbin | ||
ports: | ||
- 3306:3306 | ||
postgres: | ||
image: postgres:10.16 | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: casbin | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432:5432 | ||
|
||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.14 | ||
|
||
- uses: actions/checkout@v2 | ||
- name: Run Unit tests | ||
run: go test -v -coverprofile=./profile.cov ./... | ||
|
||
semantic-release: | ||
needs: [test] | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
- name: Run semantic-release | ||
if: github.repository == 'casbin/ent-adapter' && github.event_name == 'push' | ||
run: | | ||
npm install --save-dev [email protected] | ||
npx semantic-release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"debug": true, | ||
"branches": [ | ||
"+([0-9])?(.{+([0-9]),x}).x", | ||
"master", | ||
{ | ||
"name": "beta", | ||
"prerelease": true | ||
} | ||
], | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/github" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,35 @@ | ||
# ent-adapter | ||
Ent-Adapter | ||
=== | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/casbin/gorm-adapter)](https://goreportcard.com/report/github.com/casbin/ent-adapter) | ||
[![Go](https://github.com/casbin/ent-adapter/actions/workflows/ci.yml/badge.svg)](https://github.com/casbin/ent-adapter/actions/workflows/ci.yml) | ||
[![Coverage Status](https://coveralls.io/repos/github/casbin/ent-adapter/badge.svg?branch=master)](https://coveralls.io/github/casbin/ent-adapter?branch=master) | ||
|
||
Ent Adapter is the [ent](https://github.com/ent/ent) adapter for [Casbin](https://github.com/casbin/casbin). With this library, Casbin can load policy from PostgresSQL/Mysql or save policy to it. | ||
|
||
## Installation | ||
|
||
go get github.com/casbin/ent-adapter | ||
|
||
|
||
## Usage | ||
|
||
```go | ||
a, err := NewAdapter("mysql", "root:@tcp(127.0.0.1:3306)/casbin") | ||
//a, err := NewAdapter("postgres", "user=postgres password=postgres host=127.0.0.1 port=5432 dbname=casbin") | ||
if err != nil { | ||
panic(err) | ||
} | ||
e, err := casbin.NewEnforcer("/path/to/model",a) | ||
``` | ||
|
||
## Notification | ||
|
||
The database used in adapter(like casbin) should be created manually before NewAdapter calling. | ||
|
||
## Getting Help | ||
|
||
- [Casbin](https://github.com/casbin/casbin) | ||
|
||
## License | ||
|
||
This project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text. |
Oops, something went wrong.