Skip to content

Commit 60ce724

Browse files
committed
Initial commit
0 parents  commit 60ce724

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+6230
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: gomod
4+
directory: /
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10
8+
9+
- package-ecosystem: "github-actions"
10+
directory: /
11+
schedule:
12+
interval: daily
13+
open-pull-requests-limit: 10
14+

.github/workflows/ci.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: CI
2+
on: pull_request
3+
4+
jobs:
5+
golangci-lint:
6+
name: runner / golangci-lint
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Check out code into the Go module directory
10+
uses: actions/checkout@v2
11+
- name: golangci-lint
12+
uses: reviewdog/action-golangci-lint@v2
13+
14+
yamllint:
15+
name: runner / yamllint
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v2
19+
- uses: reviewdog/action-yamllint@v1
20+
with:
21+
fail_on_error: true
22+
reporter: github-pr-review
23+
yamllint_flags: '-d "{extends: default, rules: {truthy: disable}}" .'
24+
25+
hadolint:
26+
name: runner / hadolint
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v2
30+
- uses: reviewdog/action-hadolint@v1
31+
with:
32+
fail_on_error: true
33+
reporter: github-pr-review
34+
35+
dotenv-linter:
36+
name: runner / dotenv-linter
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v2
40+
- uses: dotenv-linter/action-dotenv-linter@v2
41+
with:
42+
reporter: github-pr-review
43+
44+
check-dependencies:
45+
name: runner / check-dependencies
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v2
49+
- uses: actions/setup-go@v2
50+
- name: WriteGoList
51+
run: go list -json -m all > go.list
52+
- name: Nancy
53+
uses: sonatype-nexus-community/nancy-github-action@main
54+
continue-on-error: true
55+
56+
tests:
57+
name: runner / tests
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v2
61+
- uses: actions/setup-go@v2
62+
with:
63+
go-version: 1.17
64+
65+
- name: Unit Tests
66+
run: "go test \
67+
-v \
68+
-race \
69+
-covermode atomic \
70+
-coverprofile=coverage.txt \
71+
./internal/..."
72+
- name: Upload coverage report
73+
run: bash <(curl -s https://codecov.io/bash)
74+
75+
- name: Integration tests
76+
run: "docker-compose up \
77+
--build \
78+
--abort-on-container-exit \
79+
--exit-code-from integration"

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# IDE
2+
.idea
3+
.vscode
4+
5+
# Config
6+
.env
7+
8+
# Binaries for programs and plugins
9+
*.exe
10+
*.exe~
11+
*.dll
12+
*.so
13+
*.dylib
14+
15+
# Test binary, built with `go test -c`
16+
*.test
17+
18+
# Output of the go coverage tool, specifically when used with LiteIDE
19+
*.out
20+
21+
# Dependency directories (remove the comment below to include it)
22+
vendor/

.golangci.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
linters-settings:
2+
gci:
3+
local-prefixes: github.com/Permify/permify
4+
dupl:
5+
threshold: 100
6+
errorlint:
7+
errorf: true
8+
errcheck:
9+
check-type-assertions: true
10+
check-blank: true
11+
exhaustive:
12+
check-generated: false
13+
default-signifies-exhaustive: false
14+
funlen:
15+
lines: 65
16+
statements: 40
17+
gocognit:
18+
min-complexity: 15
19+
gocyclo:
20+
min-complexity: 10
21+
goconst:
22+
min-len: 2
23+
min-occurrences: 2
24+
gocritic:
25+
enabled-tags:
26+
- diagnostic
27+
- experimental
28+
- opinionated
29+
- performance
30+
- style
31+
disabled-checks:
32+
- dupImport
33+
- unnecessaryBlock
34+
gofumpt:
35+
extra-rules: true
36+
gomnd:
37+
settings:
38+
mnd:
39+
checks:
40+
- argument
41+
- case
42+
- condition
43+
- operation
44+
- return
45+
govet:
46+
check-shadowing: true
47+
misspell:
48+
locale: US
49+
nestif:
50+
min-complexity: 4
51+
nolintlint:
52+
require-explanation: true
53+
require-specific: true
54+
55+
linters:
56+
disable-all: true
57+
enable:
58+
- asciicheck
59+
- bodyclose
60+
- cyclop
61+
- deadcode
62+
- depguard
63+
- dogsled
64+
- dupl
65+
- durationcheck
66+
- errcheck
67+
- errorlint
68+
- exhaustive
69+
- exportloopref
70+
- forbidigo
71+
- funlen
72+
- gci
73+
- gochecknoglobals
74+
- gochecknoinits
75+
- gocognit
76+
- goconst
77+
- gocritic
78+
- gocyclo
79+
- godot
80+
- godox
81+
- goerr113
82+
- gofmt
83+
- gofumpt
84+
- goimports
85+
- gomnd
86+
- gomodguard
87+
- goprintffuncname
88+
- gosec
89+
- gosimple
90+
- govet
91+
- ineffassign
92+
- makezero
93+
- misspell
94+
- nakedret
95+
- nestif
96+
- nlreturn
97+
- noctx
98+
- nolintlint
99+
- paralleltest
100+
- predeclared
101+
- revive
102+
- rowserrcheck
103+
- sqlclosecheck
104+
- staticcheck
105+
- structcheck
106+
- stylecheck
107+
- tparallel
108+
- thelper
109+
- typecheck
110+
- unconvert
111+
- unparam
112+
- unused
113+
- varcheck
114+
- wsl
115+
- whitespace
116+
117+
# disable:
118+
# - exhaustivestruct
119+
# - ifshort
120+
# - goheader
121+
# - prealloc
122+
# - testpackage
123+
# - wrapcheck
124+
125+
issues:
126+
exclude-rules:
127+
- path: integration-test
128+
linters:
129+
- paralleltest
130+
- godot
131+
- path: internal/controllers/http
132+
linters:
133+
- godot
134+
135+
run:
136+
skip-dirs:
137+
- docs

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Step 1: Modules caching
2+
FROM golang:1.17.1-alpine3.14 as modules
3+
COPY go.mod go.sum /modules/
4+
WORKDIR /modules
5+
RUN go mod download
6+
7+
# Step 2: Builder
8+
FROM golang:1.17.1-alpine3.14 as builder
9+
COPY --from=modules /go/pkg /go/pkg
10+
COPY . /app
11+
WORKDIR /app
12+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
13+
go build -o /bin/app ./cmd/app
14+
15+
# Step 3: Final
16+
FROM scratch
17+
EXPOSE 8080 8080
18+
COPY --from=builder /app/default.config.yaml /default.config.yaml
19+
COPY --from=builder /app/default.schema.perm /default.schema.perm
20+
COPY --from=builder /bin/app /app
21+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
22+
CMD ["/app"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Tolga Özen
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
export
2+
3+
# HELP =================================================================================================================
4+
# This will output the help for each task
5+
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
6+
.PHONY: help
7+
8+
help: ## Display this help screen
9+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
10+
11+
swag-v1: ### swag init
12+
swag init -g internal/controllers/http/v1/router.go
13+
.PHONY: swag-v1
14+
15+
run: swag-v1 ### swag run
16+
go mod tidy && go mod download && \
17+
DISABLE_SWAGGER_HTTP_HANDLER='' CGO_ENABLED=0 go run ./cmd/app
18+
.PHONY: run
19+
20+
linter-golangci: ### check by golangci linter
21+
golangci-lint run
22+
.PHONY: linter-golangci
23+
24+
linter-hadolint: ### check by hadolint linter
25+
git ls-files --exclude='Dockerfile*' --ignored | xargs hadolint
26+
.PHONY: linter-hadolint
27+
28+
linter-dotenv: ### check by dotenv linter
29+
dotenv-linter
30+
.PHONY: linter-dotenv
31+
32+
test: ### run test
33+
go test -v -cover -race ./internal/...
34+
.PHONY: test
35+
36+
integration-test: ### run integration-test
37+
go clean -testcache && go test -v ./integration-test/...
38+
.PHONY: integration-test
39+
40+
mock: ### run mockery
41+
mockery --all -r --case snake
42+
.PHONY: mock

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
# Permify
3+
4+
Permify is an open-source authorization service for syncing authorization data, and building fine-grained permissions.
5+
You can run Permify with docker, and it works on a Rest API.
6+
7+
8+
9+

cmd/app/main.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package main
2+
3+
import (
4+
"log"
5+
6+
"github.com/Permify/permify/internal/app"
7+
"github.com/Permify/permify/internal/config"
8+
)
9+
10+
func main() {
11+
// Configuration
12+
cfg, err := config.NewConfig()
13+
if err != nil {
14+
log.Fatalf("Config error: %s", err)
15+
}
16+
17+
// Run
18+
app.Run(cfg)
19+
}

0 commit comments

Comments
 (0)