From 3261f2b6ebf267ff688198c1f8364b232742b90e Mon Sep 17 00:00:00 2001 From: khoipham Date: Sat, 28 Dec 2019 09:37:27 +0700 Subject: [PATCH] add travis yaml --- .travis.yml | 9 +++++++++ README.md | 16 ++++++---------- docker-compose.yml | 2 +- go.mod | 2 +- pgexample/main.go | 6 ++---- 5 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..446d850 --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/README.md b/README.md index 589a06b..5c5df3a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ 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 @@ -12,9 +12,7 @@ Go-pg Adapter is the [Go-pg](https://github.com/go-pg/pg) adapter for [Casbin](h package main import ( - "os" - - pgadapter "github.com/pckhoi/casbin-pg-adapter" + pgadapter "github.com/casbin/casbin-pg-adapter" "github.com/casbin/casbin/v2" ) @@ -22,7 +20,7 @@ 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: "...", @@ -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{ @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index a0387b5..c92aaa3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,7 +22,7 @@ services: command: - go - test - - github.com/pckhoi/casbin-pg-adapter + - github.com/casbin/casbin-pg-adapter volumes: gopkg: diff --git a/go.mod b/go.mod index a7b62c4..31723f2 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/pckhoi/casbin-pg-adapter +module github.com/casbin/casbin-pg-adapter go 1.12 diff --git a/pgexample/main.go b/pgexample/main.go index 244b46b..73bd359 100644 --- a/pgexample/main.go +++ b/pgexample/main.go @@ -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: "...",