Skip to content

Commit

Permalink
fix: devices use unique connections now
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdmike committed Jul 15, 2024
1 parent 2d3bc4f commit 2da7203
Show file tree
Hide file tree
Showing 34 changed files with 4,502 additions and 3,929 deletions.
184 changes: 94 additions & 90 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,90 +1,94 @@
include .env
export

LOCAL_BIN:=$(CURDIR)/bin
PATH:=$(LOCAL_BIN):$(PATH)

# HELP =================================================================================================================
# This will output the help for each task
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help

help: ## Display this help screen
@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)

compose-up: ### Run docker compose
docker compose up --build -d postgres && docker compose logs -f
.PHONY: compose-up

compose-up-integration-test: ### Run docker compose with integration test
docker compose up --build --abort-on-container-exit --exit-code-from integration
.PHONY: compose-up-integration-test

compose-down: ### Down docker compose
docker compose down --remove-orphans
.PHONY: compose-down

swag-v1: ### swag init
swag init -g internal/controller/http/v1/router.go
.PHONY: swag-v1

run: ### run app
go mod tidy && go mod download && \
DISABLE_SWAGGER_HTTP_HANDLER='' GIN_MODE=debug CGO_ENABLED=0 go run ./cmd/app
.PHONY: run

docker-rm-volume: ### remove docker volume
docker volume rm go-clean-template_pg-data
.PHONY: docker-rm-volume

linter-golangci: ### check by golangci linter
golangci-lint run
.PHONY: linter-golangci

linter-hadolint: ### check by hadolint linter
git ls-files --exclude='Dockerfile*' --ignored | xargs hadolint
.PHONY: linter-hadolint

linter-dotenv: ### check by dotenv linter
dotenv-linter
.PHONY: linter-dotenv

test: ### run test
go test -v -cover -race ./internal/...
.PHONY: test

integration-test: ### run integration-test
go clean -testcache && go test -v ./integration-test/...
.PHONY: integration-test

mock: ### run mockgen
mockgen -source ./internal/usecase/ciraconfigs/interfaces.go -package ciraconfigs_test > ./internal/usecase/ciraconfigs/mocks_test.go
mockgen -source ./internal/usecase/ciraconfigs/interfaces.go -package v1 -mock_names Repository=MockCIRAConfigsRepository,Feature=MockCIRAConfigsFeature > ./internal/controller/http/v1/ciraconfigs_mocks_test.go
mockgen -source ./internal/usecase/devices/interfaces.go -package devices_test > ./internal/usecase/devices/mocks_test.go
mockgen -source ./internal/usecase/devices/interfaces.go -package v1 -mock_names Repository=MockDeviceManagementRepository,Feature=MockDeviceManagementFeature > ./internal/controller/http/v1/devicemanagement_mocks_test.go
mockgen -source ./internal/usecase/domains/interfaces.go -package domains_test > ./internal/usecase/domains/mocks_test.go
mockgen -source ./internal/usecase/domains/interfaces.go -package v1 -mock_names Repository=MockDomainsRepository,Feature=MockDomainsFeature > ./internal/controller/http/v1/domains_mocks_test.go
mockgen -source ./internal/usecase/ieee8021xconfigs/interfaces.go -package ieee8021xconfigs_test > ./internal/usecase/ieee8021xconfigs/mocks_test.go
mockgen -source ./internal/usecase/ieee8021xconfigs/interfaces.go -package v1 -mock_names Repository=MockIEEE8021xConfigsRepository,Feature=MockIEEE8021xConfigsFeature > ./internal/controller/http/v1/ieee8021xconfigs_mocks_test.go
mockgen -source ./internal/usecase/profiles/interfaces.go -package v1 -mock_names Repository=MockProfilesRepository,Feature=MockProfilesFeature > ./internal/controller/http/v1/profiles_mocks_test.go
mockgen -source ./internal/usecase/profiles/interfaces.go -package profiles_test > ./internal/usecase/profiles/mocks_test.go
mockgen -source ./internal/usecase/wificonfigs/interfaces.go -package profiles_test -mock_names Repository=MockwificonfigsRepository,Feature=MockwificonfigsFeature > ./internal/usecase/profiles/wificonfigs_mocks_test.go
mockgen -source ./internal/usecase/profilewificonfigs/interfaces.go -package profiles_test -mock_names Repository=MockProfileWiFiConfigsRepository,Feature=MockProfileWiFiConfigsFeature > ./internal/usecase/profiles/profileswificonfigs_mocks_test.go
mockgen -source ./internal/usecase/ieee8021xconfigs/interfaces.go -package profiles_test -mock_names Repository=MockIEEERepository,Feature=MockIEEEFeature > ./internal/usecase/profiles/ieee_mocks_test.go
mockgen -source ./internal/usecase/wificonfigs/interfaces.go -package wificonfigs_test > ./internal/usecase/wificonfigs/mocks_test.go
mockgen -source ./internal/usecase/profilewificonfigs/interfaces.go -package wificonfigs_test -mock_names Repository=MockProfileWiFiConfigsRepository,Feature=MockProfileWiFiConfigsFeature > ./internal/usecase/wificonfigs/profileswificonfigs_mocks_test.go
mockgen -source ./internal/usecase/wificonfigs/interfaces.go -package v1 -mock_names Repository=MockWiFiConfigsRepository,Feature=MockWiFiConfigsFeature > ./internal/controller/http/v1/wificonfigs_mocks_test.go
mockgen -source ./internal/usecase/profilewificonfigs/interfaces.go -package profilewificonfigs_test > ./internal/usecase/profilewificonfigs/mocks_test.go
.PHONY: mock

migrate-create: ### create new migration
migrate create -ext sql -dir /internal/app/migrations 'migrate_name'
.PHONY: migrate-create

migrate-up: ### migration up
migrate -path /internal/app/migrations -database '$(DB_URL)?sslmode=disable' up
.PHONY: migrate-up

bin-deps:
GOBIN=$(LOCAL_BIN) go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
GOBIN=$(LOCAL_BIN) go install go.uber.org/mock/mockgen@latest
include .env
export

LOCAL_BIN:=$(CURDIR)/bin
PATH:=$(LOCAL_BIN):$(PATH)

# HELP =================================================================================================================
# This will output the help for each task
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help

help: ## Display this help screen
@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)

compose-up: ### Run docker compose
docker compose up --build -d postgres && docker compose logs -f
.PHONY: compose-up

compose-up-integration-test: ### Run docker compose with integration test
docker compose up --build --abort-on-container-exit --exit-code-from integration
.PHONY: compose-up-integration-test

compose-down: ### Down docker compose
docker compose down --remove-orphans
.PHONY: compose-down

swag-v1: ### swag init
swag init -g internal/controller/http/v1/router.go
.PHONY: swag-v1

run: ### run app
go mod tidy && go mod download && \
DISABLE_SWAGGER_HTTP_HANDLER='' GIN_MODE=debug CGO_ENABLED=0 go run ./cmd/app
.PHONY: run

docker-rm-volume: ### remove docker volume
docker volume rm go-clean-template_pg-data
.PHONY: docker-rm-volume

linter-golangci: ### check by golangci linter
golangci-lint run
.PHONY: linter-golangci

linter-hadolint: ### check by hadolint linter
git ls-files --exclude='Dockerfile*' --ignored | xargs hadolint
.PHONY: linter-hadolint

linter-dotenv: ### check by dotenv linter
dotenv-linter
.PHONY: linter-dotenv

test: ### run test
go test -v -cover -race ./internal/...
.PHONY: test

integration-test: ### run integration-test
go clean -testcache && go test -v ./integration-test/...
.PHONY: integration-test

mock: ### run mockgen
mockgen -source ./internal/usecase/ciraconfigs/interfaces.go -package ciraconfigs_test > ./internal/usecase/ciraconfigs/mocks_test.go
mockgen -source ./internal/usecase/ciraconfigs/interfaces.go -package v1 -mock_names Repository=MockCIRAConfigsRepository,Feature=MockCIRAConfigsFeature > ./internal/controller/http/v1/ciraconfigs_mocks_test.go
mockgen -source ./internal/usecase/devices/interfaces.go -package devices_test > ./internal/usecase/devices/mocks_test.go
mockgen -source ./internal/usecase/devices/interfaces.go -package v1 -mock_names Repository=MockDeviceManagementRepository,Feature=MockDeviceManagementFeature > ./internal/controller/http/v1/devicemanagement_mocks_test.go
mockgen -source ./internal/usecase/amtexplorer/interfaces.go -package v1 -mock_names Repository=MockAMTExplorerRepository,Feature=MockAMTExplorerFeature,WSMAN=MockAMTExplorerWSMAN > ./internal/controller/http/v1/amtexplorer_mocks_test.go
mockgen -source ./internal/usecase/amtexplorer/interfaces.go -package amtexplorer_test > ./internal/usecase/amtexplorer/mocks_test.go
mockgen -source ./internal/usecase/devices/wsman/interfaces.go -package v1 > ./internal/controller/http/v1/devicemanagement2_mocks_test.go
mockgen -source ./internal/usecase/devices/wsman/interfaces.go -package devices_test > ./internal/usecase/devices/devicemanagement2_mocks_test.go
mockgen -source ./internal/usecase/domains/interfaces.go -package domains_test > ./internal/usecase/domains/mocks_test.go
mockgen -source ./internal/usecase/domains/interfaces.go -package v1 -mock_names Repository=MockDomainsRepository,Feature=MockDomainsFeature > ./internal/controller/http/v1/domains_mocks_test.go
mockgen -source ./internal/usecase/ieee8021xconfigs/interfaces.go -package ieee8021xconfigs_test > ./internal/usecase/ieee8021xconfigs/mocks_test.go
mockgen -source ./internal/usecase/ieee8021xconfigs/interfaces.go -package v1 -mock_names Repository=MockIEEE8021xConfigsRepository,Feature=MockIEEE8021xConfigsFeature > ./internal/controller/http/v1/ieee8021xconfigs_mocks_test.go
mockgen -source ./internal/usecase/profiles/interfaces.go -package v1 -mock_names Repository=MockProfilesRepository,Feature=MockProfilesFeature > ./internal/controller/http/v1/profiles_mocks_test.go
mockgen -source ./internal/usecase/profiles/interfaces.go -package profiles_test > ./internal/usecase/profiles/mocks_test.go
mockgen -source ./internal/usecase/wificonfigs/interfaces.go -package profiles_test -mock_names Repository=MockwificonfigsRepository,Feature=MockwificonfigsFeature > ./internal/usecase/profiles/wificonfigs_mocks_test.go
mockgen -source ./internal/usecase/profilewificonfigs/interfaces.go -package profiles_test -mock_names Repository=MockProfileWiFiConfigsRepository,Feature=MockProfileWiFiConfigsFeature > ./internal/usecase/profiles/profileswificonfigs_mocks_test.go
mockgen -source ./internal/usecase/ieee8021xconfigs/interfaces.go -package profiles_test -mock_names Repository=MockIEEERepository,Feature=MockIEEEFeature > ./internal/usecase/profiles/ieee_mocks_test.go
mockgen -source ./internal/usecase/wificonfigs/interfaces.go -package wificonfigs_test > ./internal/usecase/wificonfigs/mocks_test.go
mockgen -source ./internal/usecase/profilewificonfigs/interfaces.go -package wificonfigs_test -mock_names Repository=MockProfileWiFiConfigsRepository,Feature=MockProfileWiFiConfigsFeature > ./internal/usecase/wificonfigs/profileswificonfigs_mocks_test.go
mockgen -source ./internal/usecase/wificonfigs/interfaces.go -package v1 -mock_names Repository=MockWiFiConfigsRepository,Feature=MockWiFiConfigsFeature > ./internal/controller/http/v1/wificonfigs_mocks_test.go
mockgen -source ./internal/usecase/profilewificonfigs/interfaces.go -package profilewificonfigs_test > ./internal/usecase/profilewificonfigs/mocks_test.go
.PHONY: mock

migrate-create: ### create new migration
migrate create -ext sql -dir /internal/app/migrations 'migrate_name'
.PHONY: migrate-create

migrate-up: ### migration up
migrate -path /internal/app/migrations -database '$(DB_URL)?sslmode=disable' up
.PHONY: migrate-up

bin-deps:
GOBIN=$(LOCAL_BIN) go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
GOBIN=$(LOCAL_BIN) go install go.uber.org/mock/mockgen@latest
2 changes: 1 addition & 1 deletion internal/controller/http/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func NewRouter(handler *gin.Engine, l logger.Interface, t usecase.Usecases, cfg
h2 := handler.Group("/api/v1")
{
v1.NewDeviceRoutes(h2, t.Devices, l)
v1.NewAmtRoutes(h2, t.Devices, l)
v1.NewAmtRoutes(h2, t.Devices, t.AMTExplorer, l)

Check warning on line 77 in internal/controller/http/router.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/http/router.go#L77

Added line #L77 was not covered by tests
}

h := handler.Group("/api/v1/admin")
Expand Down
Loading

0 comments on commit 2da7203

Please sign in to comment.