Skip to content

Commit

Permalink
add travis yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
pckhoi committed Dec 28, 2019
1 parent 38a2722 commit 3261f2b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: go
go:
- 1.12.x
- 1.13.x
env:
- PG_CONN=postgresql://postgres:@localhost:5432/postgres?sslmode=disable
services:
- postgresql
scripts: go test github.com/casbin/casbin-pg-adapter
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,23 @@ Go-pg Adapter is the [Go-pg](https://github.com/go-pg/pg) adapter for [Casbin](h

## Installation

go get github.com/pckhoi/casbin-pg-adapter
go get github.com/casbin/casbin-pg-adapter

## Simple Postgres Example

```go
package main

import (
"os"

pgadapter "github.com/pckhoi/casbin-pg-adapter"
pgadapter "github.com/casbin/casbin-pg-adapter"
"github.com/casbin/casbin/v2"
)

func main() {
// Initialize a Go-pg adapter and use it in a Casbin enforcer:
// The adapter will use the Postgres database named "casbin".
// If it doesn't exist, the adapter will create it automatically.
a, _ := pgadapter.NewAdapter(os.Getenv("PG_CONN")) // Your driver and data source.
a, _ := pgadapter.NewAdapter("postgresql://username:password@postgres:5432/database?sslmode=disable") // Your driver and data source.
// Alternatively, you can construct an adapter instance with *pg.Options:
// a, _ := pgadapter.NewAdapter(&pg.Options{
// Database: "...",
Expand Down Expand Up @@ -59,14 +57,12 @@ You can [load a subset of policies](https://casbin.org/docs/en/policy-subset-loa
package main

import (
"os"

"github.com/casbin/casbin/v2"
pgadapter "github.com/pckhoi/casbin-pg-adapter"
pgadapter "github.com/casbin/casbin-pg-adapter"
)

func main() {
a, _ := pgadapter.NewAdapter(os.Getenv("PG_CONN"))
a, _ := pgadapter.NewAdapter("postgresql://username:password@postgres:5432/database?sslmode=disable")
e, _ := casbin.NewEnforcer("examples/rbac_model.conf", a)

e.LoadFilteredPolicy(&pgadapter.Filter{
Expand All @@ -83,7 +79,7 @@ func main() {

## Debug tests

docker-compose run --rm go dlv test github.com/pckhoi/casbin-pg-adapter
docker-compose run --rm go dlv test github.com/casbin/casbin-pg-adapter

## Getting Help

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
command:
- go
- test
- github.com/pckhoi/casbin-pg-adapter
- github.com/casbin/casbin-pg-adapter

volumes:
gopkg:
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/pckhoi/casbin-pg-adapter
module github.com/casbin/casbin-pg-adapter

go 1.12

Expand Down
6 changes: 2 additions & 4 deletions pgexample/main.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package main

import (
"os"

pgadapter "github.com/casbin/casbin-pg-adapter"
"github.com/casbin/casbin/v2"
pgadapter "github.com/pckhoi/casbin-pg-adapter"
)

func main() {
// Initialize a Go-pg adapter and use it in a Casbin enforcer:
// The adapter will use the Postgres database named "casbin".
// If it doesn't exist, the adapter will create it automatically.
a, _ := pgadapter.NewAdapter(os.Getenv("PG_CONN")) // Your driver and data source.
a, _ := pgadapter.NewAdapter("postgresql://postgres:password@postgres:5432/postgres?sslmode=disable") // Your driver and data source.
// Alternatively, you can construct an adapter instance with *pg.Options:
// a, _ := pgadapter.NewAdapter(&pg.Options{
// Database: "...",
Expand Down

0 comments on commit 3261f2b

Please sign in to comment.