mirror of
https://github.com/netbirdio/dex.git
synced 2026-05-22 18:43:53 -07:00
feat: Bump dependencies and Makefile refactoring
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
This commit is contained in:
+10
-10
@@ -64,22 +64,26 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.19
|
||||
go-version: "1.20"
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Download tool dependencies
|
||||
run: make deps
|
||||
|
||||
# Ensure that generated files were committed.
|
||||
- name: Verify
|
||||
run: make verify
|
||||
|
||||
- name: Start services
|
||||
run: docker-compose -f docker-compose.test.yaml up -d
|
||||
|
||||
- name: Create kind cluster
|
||||
uses: helm/kind-action@v1.5.0
|
||||
with:
|
||||
version: v0.11.1
|
||||
node_image: kindest/node:v1.19.11@sha256:07db187ae84b4b7de440a73886f008cf903fcf5764ba8106a9fd5243d6f32729
|
||||
|
||||
- name: Download tool dependencies
|
||||
run: make deps
|
||||
version: "v0.17.0"
|
||||
node_image: "kindest/node:v1.25.3@sha256:cd248d1438192f7814fbca8fede13cfe5b9918746dfa12583976158a834fd5c5"
|
||||
|
||||
- name: Test
|
||||
run: make testall
|
||||
@@ -123,7 +127,3 @@ jobs:
|
||||
|
||||
- name: Lint
|
||||
run: make lint
|
||||
|
||||
# Ensure that generated files were committed.
|
||||
- name: Verify
|
||||
run: make verify
|
||||
|
||||
+8
-4
@@ -1,5 +1,7 @@
|
||||
run:
|
||||
timeout: 4m
|
||||
skip-dirs:
|
||||
- storage/ent/db # generated ent code
|
||||
|
||||
linters-settings:
|
||||
depguard:
|
||||
@@ -18,7 +20,6 @@ linters-settings:
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- bodyclose
|
||||
- depguard
|
||||
- dogsled
|
||||
- exhaustive
|
||||
@@ -38,16 +39,19 @@ linters:
|
||||
- nolintlint
|
||||
- prealloc
|
||||
- revive
|
||||
- rowserrcheck
|
||||
- sqlclosecheck
|
||||
- staticcheck
|
||||
- stylecheck
|
||||
- tparallel
|
||||
- unconvert
|
||||
- unparam
|
||||
- unused
|
||||
- whitespace
|
||||
|
||||
# Disable temporarily until everything works with Go 1.20
|
||||
# - bodyclose
|
||||
# - rowserrcheck
|
||||
# - tparallel
|
||||
# - unparam
|
||||
|
||||
# Disable temporarily until everything works with Go 1.18
|
||||
- typecheck
|
||||
|
||||
|
||||
@@ -1,48 +1,49 @@
|
||||
OS = $(shell uname | tr A-Z a-z)
|
||||
|
||||
export PATH := $(abspath bin/protoc/bin/):$(abspath bin/):${PATH}
|
||||
|
||||
PROJ=dex
|
||||
ORG_PATH=github.com/dexidp
|
||||
REPO_PATH=$(ORG_PATH)/$(PROJ)
|
||||
|
||||
VERSION ?= $(shell ./scripts/git-version)
|
||||
|
||||
DOCKER_REPO=quay.io/dexidp/dex
|
||||
DOCKER_IMAGE=$(DOCKER_REPO):$(VERSION)
|
||||
|
||||
$( shell mkdir -p bin )
|
||||
|
||||
user=$(shell id -u -n)
|
||||
group=$(shell id -g -n)
|
||||
|
||||
export GOBIN=$(PWD)/bin
|
||||
$( shell mkdir -p bin )
|
||||
|
||||
PROJ = dex
|
||||
ORG_PATH = github.com/dexidp
|
||||
REPO_PATH = $(ORG_PATH)/$(PROJ)
|
||||
VERSION ?= $(shell ./scripts/git-version)
|
||||
|
||||
|
||||
export GOBIN=$(PWD)/bin
|
||||
LD_FLAGS="-w -X main.version=$(VERSION)"
|
||||
|
||||
# Dependency versions
|
||||
GOLANGCI_VERSION = 1.51.2
|
||||
GOTESTSUM_VERSION ?= 1.7.0
|
||||
|
||||
KIND_NODE_IMAGE = "kindest/node:v1.19.11@sha256:07db187ae84b4b7de440a73886f008cf903fcf5764ba8106a9fd5243d6f32729"
|
||||
KIND_TMP_DIR = "$(PWD)/bin/test/dex-kind-kubeconfig"
|
||||
PROTOC_VERSION = 3.15.6
|
||||
PROTOC_GEN_GO_VERSION = 1.26.0
|
||||
PROTOC_GEN_GO_GRPC_VERSION = 1.1.0
|
||||
|
||||
build: bin/dex
|
||||
KIND_VERSION = 0.17.0
|
||||
KIND_NODE_IMAGE = "kindest/node:v1.25.3@sha256:cd248d1438192f7814fbca8fede13cfe5b9918746dfa12583976158a834fd5c5"
|
||||
KIND_TMP_DIR = "$(PWD)/bin/test/dex-kind-kubeconfig"
|
||||
|
||||
verify: verify-proto verify-ent
|
||||
|
||||
##@ Build
|
||||
|
||||
build: bin/dex ## Build Dex binaries.
|
||||
|
||||
examples: bin/grpc-client bin/example-app ## Build example app.
|
||||
|
||||
.PHONY: release-binary
|
||||
release-binary: LD_FLAGS = "-w -X main.version=$(VERSION) -extldflags \"-static\""
|
||||
release-binary: ## Build release binaries (used to build a final container image).
|
||||
@go build -o /go/bin/dex -v -ldflags $(LD_FLAGS) $(REPO_PATH)/cmd/dex
|
||||
@go build -o /go/bin/docker-entrypoint -v -ldflags $(LD_FLAGS) $(REPO_PATH)/cmd/docker-entrypoint
|
||||
|
||||
bin/dex:
|
||||
@mkdir -p bin/
|
||||
@go install -v -ldflags $(LD_FLAGS) $(REPO_PATH)/cmd/dex
|
||||
|
||||
.PHONY: ent-generate
|
||||
ent-generate:
|
||||
@go generate $(REPO_PATH)/storage/ent/
|
||||
|
||||
.PHONY: verify-ent
|
||||
verify-ent: ent-generate
|
||||
@./scripts/git-diff
|
||||
|
||||
examples: bin/grpc-client bin/example-app
|
||||
|
||||
bin/grpc-client:
|
||||
@mkdir -p bin/
|
||||
@cd examples/ && go install -v -ldflags $(LD_FLAGS) $(REPO_PATH)/examples/grpc-client
|
||||
@@ -51,95 +52,29 @@ bin/example-app:
|
||||
@mkdir -p bin/
|
||||
@cd examples/ && go install -v -ldflags $(LD_FLAGS) $(REPO_PATH)/examples/example-app
|
||||
|
||||
.PHONY: release-binary
|
||||
release-binary: LD_FLAGS = "-w -X main.version=$(VERSION) -extldflags \"-static\""
|
||||
release-binary:
|
||||
@go build -o /go/bin/dex -v -ldflags $(LD_FLAGS) $(REPO_PATH)/cmd/dex
|
||||
@go build -o /go/bin/docker-entrypoint -v -ldflags $(LD_FLAGS) $(REPO_PATH)/cmd/docker-entrypoint
|
||||
|
||||
docker-compose.override.yaml:
|
||||
cp docker-compose.override.yaml.dist docker-compose.override.yaml
|
||||
##@ Generate
|
||||
|
||||
.PHONY: up
|
||||
up: docker-compose.override.yaml ## Launch the development environment
|
||||
@ if [ docker-compose.override.yaml -ot docker-compose.override.yaml.dist ]; then diff -u docker-compose.override.yaml docker-compose.override.yaml.dist || (echo "!!! The distributed docker-compose.override.yaml example changed. Please update your file accordingly (or at least touch it). !!!" && false); fi
|
||||
docker-compose up -d
|
||||
.PHONY: generate
|
||||
generate: go-mod-tidy generate-proto generate-proto-internal generate-ent ## Run all generators.
|
||||
|
||||
.PHONY: down
|
||||
down: clear ## Destroy the development environment
|
||||
docker-compose down --volumes --remove-orphans --rmi local
|
||||
.PHONY: generate-ent
|
||||
generate-ent: ## Generate code for database ORM.
|
||||
@go generate $(REPO_PATH)/storage/ent/
|
||||
|
||||
test:
|
||||
@go test -v ./...
|
||||
|
||||
testrace:
|
||||
@go test -v --race ./...
|
||||
|
||||
.PHONY: kind-up kind-down kind-tests
|
||||
kind-up:
|
||||
@mkdir -p bin/test
|
||||
@kind create cluster --image ${KIND_NODE_IMAGE} --kubeconfig ${KIND_TMP_DIR}
|
||||
|
||||
kind-down:
|
||||
@kind delete cluster
|
||||
rm ${KIND_TMP_DIR}
|
||||
|
||||
kind-tests: export DEX_KUBERNETES_CONFIG_PATH=${KIND_TMP_DIR}
|
||||
kind-tests: testall
|
||||
|
||||
.PHONY: lint lint-fix
|
||||
lint: ## Run linter
|
||||
golangci-lint run
|
||||
|
||||
.PHONY: fix
|
||||
fix: ## Fix lint violations
|
||||
golangci-lint run --fix
|
||||
|
||||
.PHONY: docker-image
|
||||
docker-image:
|
||||
@sudo docker build -t $(DOCKER_IMAGE) .
|
||||
|
||||
.PHONY: verify-proto
|
||||
verify-proto: proto
|
||||
@./scripts/git-diff
|
||||
|
||||
clean:
|
||||
@rm -rf bin/
|
||||
|
||||
testall: testrace
|
||||
|
||||
FORCE:
|
||||
|
||||
.PHONY: test testrace testall
|
||||
|
||||
.PHONY: proto
|
||||
proto:
|
||||
.PHONY: generate-proto
|
||||
generate-proto: ## Generate the Dex client's protobuf code.
|
||||
@protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. api/v2/*.proto
|
||||
@protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. api/*.proto
|
||||
#@cp api/v2/*.proto api/
|
||||
|
||||
.PHONY: proto-internal
|
||||
proto-internal:
|
||||
.PHONY: generate-proto-internal
|
||||
generate-proto-internal: ## Generate protobuf code for token encoding.
|
||||
@protoc --go_out=paths=source_relative:. server/internal/*.proto
|
||||
|
||||
# Dependency versions
|
||||
GOLANGCI_VERSION = 1.50.1
|
||||
GOTESTSUM_VERSION ?= 1.7.0
|
||||
PROTOC_VERSION = 3.15.6
|
||||
PROTOC_GEN_GO_VERSION = 1.26.0
|
||||
PROTOC_GEN_GO_GRPC_VERSION = 1.1.0
|
||||
KIND_VERSION = 0.11.1
|
||||
|
||||
deps: bin/gotestsum bin/golangci-lint bin/protoc bin/protoc-gen-go bin/protoc-gen-go-grpc bin/kind
|
||||
|
||||
bin/gotestsum:
|
||||
@mkdir -p bin
|
||||
curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_$(shell uname | tr A-Z a-z)_amd64.tar.gz | tar -zOxf - gotestsum > ./bin/gotestsum
|
||||
@chmod +x ./bin/gotestsum
|
||||
|
||||
bin/golangci-lint:
|
||||
@mkdir -p bin
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | BINARY=golangci-lint bash -s -- v${GOLANGCI_VERSION}
|
||||
go-mod-tidy: ## Run go mod tidy for all targets.
|
||||
@go mod tidy
|
||||
@cd examples/ && go mod tidy
|
||||
@cd api/v2/ && go mod tidy
|
||||
|
||||
bin/protoc:
|
||||
@mkdir -p bin/protoc
|
||||
@@ -162,7 +97,112 @@ bin/protoc-gen-go-grpc:
|
||||
curl -L https://github.com/grpc/grpc-go/releases/download/cmd/protoc-gen-go-grpc/v${PROTOC_GEN_GO_GRPC_VERSION}/protoc-gen-go-grpc.v${PROTOC_GEN_GO_GRPC_VERSION}.$(shell uname | tr A-Z a-z).amd64.tar.gz | tar -zOxf - ./protoc-gen-go-grpc > ./bin/protoc-gen-go-grpc
|
||||
@chmod +x ./bin/protoc-gen-go-grpc
|
||||
|
||||
##@ Verify
|
||||
|
||||
verify: generate ## Verify that all the code was generated and committed to repository.
|
||||
@./scripts/git-diff
|
||||
|
||||
.PHONY: verify-proto
|
||||
verify-proto: generate-proto ## Verify that the Dex client's protobuf code was generated.
|
||||
@./scripts/git-diff
|
||||
|
||||
.PHONY: verify-proto
|
||||
verify-proto-internal: generate-proto-internal ## Verify internal protobuf code for token encoding was generated.
|
||||
@./scripts/git-diff
|
||||
|
||||
.PHONY: verify-ent
|
||||
verify-ent: generate-ent ## Verify code for database ORM was generated.
|
||||
@./scripts/git-diff
|
||||
|
||||
.PHONY: verify-go-mod
|
||||
verify-go-mod: go-mod-tidy ## Check that go.mod and go.sum formatted according to the changes.
|
||||
@./scripts/git-diff
|
||||
|
||||
##@ Test and Lint
|
||||
|
||||
deps: bin/gotestsum bin/golangci-lint bin/protoc bin/protoc-gen-go bin/protoc-gen-go-grpc bin/kind ## Install dev dependencies.
|
||||
|
||||
.PHONY: test testrace testall
|
||||
test: ## Test go code.
|
||||
@go test -v ./...
|
||||
|
||||
testrace: ## Test go code and check for possible race conditions.
|
||||
@go test -v --race ./...
|
||||
|
||||
testall: testrace ## Run all tests for go code.
|
||||
|
||||
.PHONY: lint lint-fix
|
||||
lint: ## Run linter.
|
||||
@golangci-lint version
|
||||
@golangci-lint run
|
||||
|
||||
.PHONY: fix
|
||||
fix: ## Fix lint violations.
|
||||
@golangci-lint version
|
||||
@golangci-lint run --fix
|
||||
|
||||
docker-compose.override.yaml:
|
||||
cp docker-compose.override.yaml.dist docker-compose.override.yaml
|
||||
|
||||
.PHONY: up
|
||||
up: docker-compose.override.yaml ## Launch the development environment.
|
||||
@ if [ docker-compose.override.yaml -ot docker-compose.override.yaml.dist ]; then diff -u docker-compose.override.yaml docker-compose.override.yaml.dist || (echo "!!! The distributed docker-compose.override.yaml example changed. Please update your file accordingly (or at least touch it). !!!" && false); fi
|
||||
docker-compose up -d
|
||||
|
||||
.PHONY: down
|
||||
down: clear ## Destroy the development environment.
|
||||
docker-compose down --volumes --remove-orphans --rmi local
|
||||
|
||||
.PHONY: kind-up kind-down kind-tests
|
||||
kind-up: ## Create a kind cluster.
|
||||
@mkdir -p bin/test
|
||||
@kind create cluster --image ${KIND_NODE_IMAGE} --kubeconfig ${KIND_TMP_DIR} --name dex-tests
|
||||
|
||||
kind-tests: export DEX_KUBERNETES_CONFIG_PATH=${KIND_TMP_DIR}
|
||||
kind-tests: testall ## Run test on kind cluster (kind cluster must be created).
|
||||
|
||||
kind-down: ## Delete the kind cluster.
|
||||
@kind delete cluster --name dex-tests
|
||||
rm ${KIND_TMP_DIR}
|
||||
|
||||
bin/golangci-lint:
|
||||
@mkdir -p bin
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | BINARY=golangci-lint bash -s -- v${GOLANGCI_VERSION}
|
||||
|
||||
bin/gotestsum:
|
||||
@mkdir -p bin
|
||||
curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_$(shell uname | tr A-Z a-z)_amd64.tar.gz | tar -zOxf - gotestsum > ./bin/gotestsum
|
||||
@chmod +x ./bin/gotestsum
|
||||
|
||||
bin/kind:
|
||||
@mkdir -p bin
|
||||
curl -L https://github.com/kubernetes-sigs/kind/releases/download/v${KIND_VERSION}/kind-$(shell uname | tr A-Z a-z)-amd64 > ./bin/kind
|
||||
@chmod +x ./bin/kind
|
||||
|
||||
##@ Clean
|
||||
clean: ## Delete all builds and downloaded dependencies.
|
||||
@rm -rf bin/
|
||||
|
||||
|
||||
FORMATTING_BEGIN_YELLOW = \033[0;33m
|
||||
FORMATTING_BEGIN_BLUE = \033[36m
|
||||
FORMATTING_END = \033[0m
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
@printf -- "${FORMATTING_BEGIN_BLUE}%s${FORMATTING_END}\n" \
|
||||
"" \
|
||||
" ___ " \
|
||||
" / _ \_____ __ " \
|
||||
" / // / -_) \ / " \
|
||||
" /____/\__/_\_\ " \
|
||||
"" \
|
||||
"-----------------------" \
|
||||
""
|
||||
@awk 'BEGIN {\
|
||||
FS = ":.*##"; \
|
||||
printf "Usage: ${FORMATTING_BEGIN_BLUE}OPTION${FORMATTING_END}=<value> make ${FORMATTING_BEGIN_YELLOW}<target>${FORMATTING_END}\n"\
|
||||
} \
|
||||
/^[a-zA-Z0-9_-]+:.*?##/ { printf " ${FORMATTING_BEGIN_BLUE}%-46s${FORMATTING_END} %s\n", $$1, $$2 } \
|
||||
/^.?.?##~/ { printf " %-46s${FORMATTING_BEGIN_YELLOW}%-46s${FORMATTING_END}\n", "", substr($$1, 6) } \
|
||||
/^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
||||
|
||||
@@ -85,6 +85,10 @@ func (c *Config) OpenWithHTTPClient(id string, logger log.Logger,
|
||||
|
||||
wellKnownURL := strings.TrimSuffix(c.Issuer, "/") + wellKnownURLPath
|
||||
req, err := http.NewRequest(http.MethodGet, wellKnownURL, nil)
|
||||
if err != nil {
|
||||
cancel()
|
||||
return nil, fmt.Errorf("failed to create a request to OpenShift endpoint %w", err)
|
||||
}
|
||||
|
||||
openshiftConnector := openshiftConnector{
|
||||
apiURL: c.Issuer,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
module github.com/dexidp/dex
|
||||
|
||||
go 1.19
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
entgo.io/ent v0.11.8
|
||||
entgo.io/ent v0.11.9
|
||||
github.com/AppsFlyer/go-sundheit v0.5.0
|
||||
github.com/Masterminds/semver v1.5.0
|
||||
github.com/Masterminds/sprig/v3 v3.2.3
|
||||
@@ -27,7 +27,7 @@ require (
|
||||
github.com/russellhaering/goxmldsig v1.2.0
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
github.com/spf13/cobra v1.6.1
|
||||
github.com/stretchr/testify v1.8.1
|
||||
github.com/stretchr/testify v1.8.2
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.7
|
||||
go.etcd.io/etcd/client/v3 v3.5.7
|
||||
golang.org/x/crypto v0.6.0
|
||||
@@ -41,7 +41,7 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
ariga.io/atlas v0.9.1-0.20230119145809-92243f7c55cb // indirect
|
||||
ariga.io/atlas v0.9.1 // indirect
|
||||
cloud.google.com/go/compute v1.14.0 // indirect
|
||||
cloud.google.com/go/compute/metadata v0.2.3 // indirect
|
||||
github.com/Azure/go-ntlmssp v0.0.0-20220621081337-cb9428e4ac1e // indirect
|
||||
@@ -86,7 +86,7 @@ require (
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
go.uber.org/multierr v1.6.0 // indirect
|
||||
go.uber.org/zap v1.17.0 // indirect
|
||||
golang.org/x/mod v0.7.0 // indirect
|
||||
golang.org/x/mod v0.8.0 // indirect
|
||||
golang.org/x/sys v0.5.0 // indirect
|
||||
golang.org/x/text v0.7.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
ariga.io/atlas v0.9.1-0.20230119145809-92243f7c55cb h1:mbsFtavDqGdYwdDpP50LGOOZ2hgyGoJcZeOpbgKMyu4=
|
||||
ariga.io/atlas v0.9.1-0.20230119145809-92243f7c55cb/go.mod h1:T230JFcENj4ZZzMkZrXFDSkv+2kXkUgpJ5FQQ5hMcKU=
|
||||
ariga.io/atlas v0.9.1 h1:EpoPMnwsQG0vn9c0sYExpwSYtr7bvuSUXzQclU2pMjc=
|
||||
ariga.io/atlas v0.9.1/go.mod h1:T230JFcENj4ZZzMkZrXFDSkv+2kXkUgpJ5FQQ5hMcKU=
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||
@@ -40,8 +40,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
|
||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
entgo.io/ent v0.11.8 h1:M/M0QL1CYCUSdqGRXUrXhFYSDRJPsOOrr+RLEej/gyQ=
|
||||
entgo.io/ent v0.11.8/go.mod h1:ericBi6Q8l3wBH1wEIDfKxw7rcQEuRPyBfbIzjtxJ18=
|
||||
entgo.io/ent v0.11.9 h1:dbbCkAiPVTRBIJwoZctiSYjB7zxQIBOzVSU5H9VYIQI=
|
||||
entgo.io/ent v0.11.9/go.mod h1:KWHOcDZn1xk3mz3ipWdKrQpMvwqa/9B69TUuAPP9W6g=
|
||||
github.com/AppsFlyer/go-sundheit v0.5.0 h1:/VxpyigCfJrq1r97mn9HPiAB2qrhcTFHwNIIDr15CZM=
|
||||
github.com/AppsFlyer/go-sundheit v0.5.0/go.mod h1:2ZM0BnfqT/mljBQO224VbL5XH06TgWuQ6Cn+cTtCpTY=
|
||||
github.com/Azure/go-ntlmssp v0.0.0-20220621081337-cb9428e4ac1e h1:NeAW1fUYUEWhft7pkxDf6WoUvEZJ/uOKsvtpjLnn8MU=
|
||||
@@ -334,8 +334,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
|
||||
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
@@ -409,8 +410,8 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
|
||||
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -581,7 +582,7 @@ golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.3.1-0.20221202221704-aa9f4b2f3d57 h1:/X0t/E4VxbZE7MLS7auvE7YICHeVvbIa9vkOVvYW/24=
|
||||
golang.org/x/tools v0.6.1-0.20230222164832-25d2519c8696 h1:8985/C5IvACpd9DDXckSnjSBLKDgbxXiyODgi94zOPM=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
+76
-23
@@ -10,6 +10,9 @@ import (
|
||||
|
||||
"github.com/dexidp/dex/storage/ent/db/migrate"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/dexidp/dex/storage/ent/db/authcode"
|
||||
"github.com/dexidp/dex/storage/ent/db/authrequest"
|
||||
"github.com/dexidp/dex/storage/ent/db/connector"
|
||||
@@ -20,9 +23,6 @@ import (
|
||||
"github.com/dexidp/dex/storage/ent/db/offlinesession"
|
||||
"github.com/dexidp/dex/storage/ent/db/password"
|
||||
"github.com/dexidp/dex/storage/ent/db/refreshtoken"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Client is the client that holds all ent builders.
|
||||
@@ -75,6 +75,55 @@ func (c *Client) init() {
|
||||
c.RefreshToken = NewRefreshTokenClient(c.config)
|
||||
}
|
||||
|
||||
type (
|
||||
// config is the configuration for the client and its builder.
|
||||
config struct {
|
||||
// driver used for executing database requests.
|
||||
driver dialect.Driver
|
||||
// debug enable a debug logging.
|
||||
debug bool
|
||||
// log used for logging on debug mode.
|
||||
log func(...any)
|
||||
// hooks to execute on mutations.
|
||||
hooks *hooks
|
||||
// interceptors to execute on queries.
|
||||
inters *inters
|
||||
}
|
||||
// Option function to configure the client.
|
||||
Option func(*config)
|
||||
)
|
||||
|
||||
// options applies the options on the config object.
|
||||
func (c *config) options(opts ...Option) {
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
if c.debug {
|
||||
c.driver = dialect.Debug(c.driver, c.log)
|
||||
}
|
||||
}
|
||||
|
||||
// Debug enables debug logging on the ent.Driver.
|
||||
func Debug() Option {
|
||||
return func(c *config) {
|
||||
c.debug = true
|
||||
}
|
||||
}
|
||||
|
||||
// Log sets the logging function for debug mode.
|
||||
func Log(fn func(...any)) Option {
|
||||
return func(c *config) {
|
||||
c.log = fn
|
||||
}
|
||||
}
|
||||
|
||||
// Driver configures the client driver.
|
||||
func Driver(driver dialect.Driver) Option {
|
||||
return func(c *config) {
|
||||
c.driver = driver
|
||||
}
|
||||
}
|
||||
|
||||
// Open opens a database/sql.DB specified by the driver name and
|
||||
// the data source name, and returns a new client attached to it.
|
||||
// Optional parameters can be added for configuring the client.
|
||||
@@ -173,31 +222,23 @@ func (c *Client) Close() error {
|
||||
// Use adds the mutation hooks to all the entity clients.
|
||||
// In order to add hooks to a specific client, call: `client.Node.Use(...)`.
|
||||
func (c *Client) Use(hooks ...Hook) {
|
||||
c.AuthCode.Use(hooks...)
|
||||
c.AuthRequest.Use(hooks...)
|
||||
c.Connector.Use(hooks...)
|
||||
c.DeviceRequest.Use(hooks...)
|
||||
c.DeviceToken.Use(hooks...)
|
||||
c.Keys.Use(hooks...)
|
||||
c.OAuth2Client.Use(hooks...)
|
||||
c.OfflineSession.Use(hooks...)
|
||||
c.Password.Use(hooks...)
|
||||
c.RefreshToken.Use(hooks...)
|
||||
for _, n := range []interface{ Use(...Hook) }{
|
||||
c.AuthCode, c.AuthRequest, c.Connector, c.DeviceRequest, c.DeviceToken, c.Keys,
|
||||
c.OAuth2Client, c.OfflineSession, c.Password, c.RefreshToken,
|
||||
} {
|
||||
n.Use(hooks...)
|
||||
}
|
||||
}
|
||||
|
||||
// Intercept adds the query interceptors to all the entity clients.
|
||||
// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
|
||||
func (c *Client) Intercept(interceptors ...Interceptor) {
|
||||
c.AuthCode.Intercept(interceptors...)
|
||||
c.AuthRequest.Intercept(interceptors...)
|
||||
c.Connector.Intercept(interceptors...)
|
||||
c.DeviceRequest.Intercept(interceptors...)
|
||||
c.DeviceToken.Intercept(interceptors...)
|
||||
c.Keys.Intercept(interceptors...)
|
||||
c.OAuth2Client.Intercept(interceptors...)
|
||||
c.OfflineSession.Intercept(interceptors...)
|
||||
c.Password.Intercept(interceptors...)
|
||||
c.RefreshToken.Intercept(interceptors...)
|
||||
for _, n := range []interface{ Intercept(...Interceptor) }{
|
||||
c.AuthCode, c.AuthRequest, c.Connector, c.DeviceRequest, c.DeviceToken, c.Keys,
|
||||
c.OAuth2Client, c.OfflineSession, c.Password, c.RefreshToken,
|
||||
} {
|
||||
n.Intercept(interceptors...)
|
||||
}
|
||||
}
|
||||
|
||||
// Mutate implements the ent.Mutator interface.
|
||||
@@ -1407,3 +1448,15 @@ func (c *RefreshTokenClient) mutate(ctx context.Context, m *RefreshTokenMutation
|
||||
return nil, fmt.Errorf("db: unknown RefreshToken mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// hooks and interceptors per client, for fast access.
|
||||
type (
|
||||
hooks struct {
|
||||
AuthCode, AuthRequest, Connector, DeviceRequest, DeviceToken, Keys,
|
||||
OAuth2Client, OfflineSession, Password, RefreshToken []ent.Hook
|
||||
}
|
||||
inters struct {
|
||||
AuthCode, AuthRequest, Connector, DeviceRequest, DeviceToken, Keys,
|
||||
OAuth2Client, OfflineSession, Password, RefreshToken []ent.Interceptor
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
)
|
||||
|
||||
// Option function to configure the client.
|
||||
type Option func(*config)
|
||||
|
||||
// Config is the configuration for the client and its builder.
|
||||
type config struct {
|
||||
// driver used for executing database requests.
|
||||
driver dialect.Driver
|
||||
// debug enable a debug logging.
|
||||
debug bool
|
||||
// log used for logging on debug mode.
|
||||
log func(...any)
|
||||
// hooks to execute on mutations.
|
||||
hooks *hooks
|
||||
// interceptors to execute on queries.
|
||||
inters *inters
|
||||
}
|
||||
|
||||
// hooks and interceptors per client, for fast access.
|
||||
type (
|
||||
hooks struct {
|
||||
AuthCode []ent.Hook
|
||||
AuthRequest []ent.Hook
|
||||
Connector []ent.Hook
|
||||
DeviceRequest []ent.Hook
|
||||
DeviceToken []ent.Hook
|
||||
Keys []ent.Hook
|
||||
OAuth2Client []ent.Hook
|
||||
OfflineSession []ent.Hook
|
||||
Password []ent.Hook
|
||||
RefreshToken []ent.Hook
|
||||
}
|
||||
inters struct {
|
||||
AuthCode []ent.Interceptor
|
||||
AuthRequest []ent.Interceptor
|
||||
Connector []ent.Interceptor
|
||||
DeviceRequest []ent.Interceptor
|
||||
DeviceToken []ent.Interceptor
|
||||
Keys []ent.Interceptor
|
||||
OAuth2Client []ent.Interceptor
|
||||
OfflineSession []ent.Interceptor
|
||||
Password []ent.Interceptor
|
||||
RefreshToken []ent.Interceptor
|
||||
}
|
||||
)
|
||||
|
||||
// Options applies the options on the config object.
|
||||
func (c *config) options(opts ...Option) {
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
if c.debug {
|
||||
c.driver = dialect.Debug(c.driver, c.log)
|
||||
}
|
||||
}
|
||||
|
||||
// Debug enables debug logging on the ent.Driver.
|
||||
func Debug() Option {
|
||||
return func(c *config) {
|
||||
c.debug = true
|
||||
}
|
||||
}
|
||||
|
||||
// Log sets the logging function for debug mode.
|
||||
func Log(fn func(...any)) Option {
|
||||
return func(c *config) {
|
||||
c.log = fn
|
||||
}
|
||||
}
|
||||
|
||||
// Driver configures the client driver.
|
||||
func Driver(driver dialect.Driver) Option {
|
||||
return func(c *config) {
|
||||
c.driver = driver
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type clientCtxKey struct{}
|
||||
|
||||
// FromContext returns a Client stored inside a context, or nil if there isn't one.
|
||||
func FromContext(ctx context.Context) *Client {
|
||||
c, _ := ctx.Value(clientCtxKey{}).(*Client)
|
||||
return c
|
||||
}
|
||||
|
||||
// NewContext returns a new context with the given Client attached.
|
||||
func NewContext(parent context.Context, c *Client) context.Context {
|
||||
return context.WithValue(parent, clientCtxKey{}, c)
|
||||
}
|
||||
|
||||
type txCtxKey struct{}
|
||||
|
||||
// TxFromContext returns a Tx stored inside a context, or nil if there isn't one.
|
||||
func TxFromContext(ctx context.Context) *Tx {
|
||||
tx, _ := ctx.Value(txCtxKey{}).(*Tx)
|
||||
return tx
|
||||
}
|
||||
|
||||
// NewTxContext returns a new context with the given Tx attached.
|
||||
func NewTxContext(parent context.Context, tx *Tx) context.Context {
|
||||
return context.WithValue(parent, txCtxKey{}, tx)
|
||||
}
|
||||
@@ -42,6 +42,32 @@ type (
|
||||
MutateFunc = ent.MutateFunc
|
||||
)
|
||||
|
||||
type clientCtxKey struct{}
|
||||
|
||||
// FromContext returns a Client stored inside a context, or nil if there isn't one.
|
||||
func FromContext(ctx context.Context) *Client {
|
||||
c, _ := ctx.Value(clientCtxKey{}).(*Client)
|
||||
return c
|
||||
}
|
||||
|
||||
// NewContext returns a new context with the given Client attached.
|
||||
func NewContext(parent context.Context, c *Client) context.Context {
|
||||
return context.WithValue(parent, clientCtxKey{}, c)
|
||||
}
|
||||
|
||||
type txCtxKey struct{}
|
||||
|
||||
// TxFromContext returns a Tx stored inside a context, or nil if there isn't one.
|
||||
func TxFromContext(ctx context.Context) *Tx {
|
||||
tx, _ := ctx.Value(txCtxKey{}).(*Tx)
|
||||
return tx
|
||||
}
|
||||
|
||||
// NewTxContext returns a new context with the given Tx attached.
|
||||
func NewTxContext(parent context.Context, tx *Tx) context.Context {
|
||||
return context.WithValue(parent, txCtxKey{}, tx)
|
||||
}
|
||||
|
||||
// OrderFunc applies an ordering on the sql selector.
|
||||
type OrderFunc func(*sql.Selector)
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/dexidp/dex/storage"
|
||||
"github.com/dexidp/dex/storage/ent/db/authcode"
|
||||
"github.com/dexidp/dex/storage/ent/db/authrequest"
|
||||
@@ -22,9 +24,6 @@ import (
|
||||
"github.com/dexidp/dex/storage/ent/db/predicate"
|
||||
"github.com/dexidp/dex/storage/ent/db/refreshtoken"
|
||||
jose "gopkg.in/square/go-jose.v2"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -5,6 +5,6 @@ package runtime
|
||||
// The schema-stitching logic is generated in github.com/dexidp/dex/storage/ent/db/runtime.go
|
||||
|
||||
const (
|
||||
Version = "v0.11.8" // Version of ent codegen.
|
||||
Sum = "h1:M/M0QL1CYCUSdqGRXUrXhFYSDRJPsOOrr+RLEej/gyQ=" // Sum of ent codegen.
|
||||
Version = "v0.11.9" // Version of ent codegen.
|
||||
Sum = "h1:dbbCkAiPVTRBIJwoZctiSYjB7zxQIBOzVSU5H9VYIQI=" // Sum of ent codegen.
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user