✨ Features: - Simple dependency inversion following SOLID principles - Clean constructor injection without complex DI containers - Proper hexagonal architecture with driving/driven separation - Presentation layer moved to cmd/cli for correct application structure 🏗️ Architecture Changes: - Driving Adapters (Inbound): internal/adapters/driving/cli/ - Driven Adapters (Outbound): internal/adapters/driven/edgeconnect/ - Core Services: Dependency-injected via interface parameters - main.go relocated from root to cmd/cli/main.go 📦 Application Flow: 1. cmd/cli/main.go - Entry point and dependency wiring └── Creates EdgeConnect client based on environment └── Instantiates services with injected repositories └── Executes CLI with properly wired dependencies 2. internal/adapters/driving/cli/ - User interface layer └── Receives user commands and input validation └── Delegates to core services via driving ports └── Handles presentation logic and output formatting 3. internal/core/services/ - Business logic layer └── NewAppService(appRepo, instanceRepo) - Constructor injection └── NewAppInstanceService(instanceRepo) - Interface dependencies └── NewCloudletService(cloudletRepo) - Clean separation 4. internal/adapters/driven/edgeconnect/ - Infrastructure layer └── Implements repository interfaces for external API └── Handles HTTP communication and data persistence └── Provides concrete implementations of driven ports 🔧 Build & Deployment: - CLI Binary: make build → bin/edge-connect-cli - Usage: ./bin/edge-connect-cli --help - Tests: make test (all passing) - Clean: make clean (updated paths) 💡 Benefits: - Simple and maintainable dependency management - Testable architecture with clear boundaries - SOLID principles compliance without overengineering - Proper separation of concerns in hexagonal structure
37 lines
871 B
Makefile
37 lines
871 B
Makefile
# ABOUTME: Build automation and code generation for EdgeXR SDK
|
|
# ABOUTME: Provides targets for generating types, testing, and building the CLI
|
|
|
|
.PHONY: test build clean install-tools
|
|
|
|
# Install required tools
|
|
install-tools:
|
|
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
|
|
|
|
# Run tests
|
|
test:
|
|
go test -v ./...
|
|
|
|
# Run tests with coverage
|
|
test-coverage:
|
|
GOTOOLCHAIN=go1.25.1 go test -v -coverprofile=coverage.out ./...
|
|
GOTOOLCHAIN=go1.25.1 go tool cover -html=coverage.out -o coverage.html
|
|
|
|
# Build the CLI
|
|
build:
|
|
go build -o bin/edge-connect-cli ./cmd/cli
|
|
|
|
# Clean generated files and build artifacts
|
|
clean:
|
|
rm -f sdk/client/types_generated.go
|
|
rm -f bin/edge-connect-cli
|
|
rm -f coverage.out coverage.html
|
|
|
|
# Lint the code
|
|
lint:
|
|
golangci-lint run
|
|
|
|
# Run all checks (generate, test, lint)
|
|
check: test lint
|
|
|
|
# Default target
|
|
all: check build
|