**Phase 1: State Management & Leader Election** * **Goal**: A functional embedded etcd and leader election mechanism. * **Tasks**: 1. Implement the `StateStore` interface (RFC 5.1) with an etcd backend (`internal/store/etcd.go`). 2. Integrate embedded etcd server into `kat-agent` (RFC 2.2, 5.2), configurable via `cluster.kat` parameters. 3. Implement leader election using `go.etcd.io/etcd/client/v3/concurrency` (RFC 5.3). 4. Basic `kat-agent init` functionality: * Parse `cluster.kat`. * Start single-node embedded etcd. * Campaign for and become leader. * Store initial cluster configuration (UID, CIDRs from `cluster.kat`) in etcd. * **Milestone**: * A single `kat-agent init --config cluster.kat` process starts, initializes etcd, and logs that it has become the leader. * The cluster configuration from `cluster.kat` can be verified in etcd using an etcd client. * `StateStore` interface methods (`Put`, `Get`, `Delete`, `List`) are testable against the embedded etcd. Reviewed-on: #1
52 lines
1.2 KiB
Makefile
52 lines
1.2 KiB
Makefile
# File: Makefile
|
|
.PHONY: all generate clean test test-unit test-integration build lint
|
|
|
|
# Variables
|
|
GOLANGCI_LINT_VERSION := v1.55.2
|
|
|
|
all: generate test build
|
|
|
|
generate:
|
|
@echo "Generating Go code from Protobuf definitions..."
|
|
@./scripts/gen-proto.sh
|
|
|
|
clean:
|
|
@echo "Cleaning up generated files and build artifacts..."
|
|
@rm -f ./api/v1alpha1/*.pb.go
|
|
@rm -f kat-agent katcall
|
|
|
|
# Run all tests
|
|
test: generate
|
|
@echo "Running all tests..."
|
|
@go test -count=1 ./...
|
|
|
|
# Run unit tests only (faster, no integration tests)
|
|
test-unit:
|
|
@echo "Running unit tests..."
|
|
@go test -count=1 -short ./...
|
|
|
|
# Run integration tests only
|
|
test-integration:
|
|
@echo "Running integration tests..."
|
|
@go test -count=1 -run Integration ./...
|
|
|
|
# Run tests for a specific package
|
|
test-package:
|
|
@echo "Running tests for package $(PACKAGE)..."
|
|
@go test -v ./$(PACKAGE)
|
|
|
|
kat-agent:
|
|
@echo "Building kat-agent..."
|
|
@go build -o kat-agent ./cmd/kat-agent/main.go
|
|
|
|
build: generate kat-agent
|
|
@echo "Building all binaries..."
|
|
|
|
lint:
|
|
@echo "Running linter..."
|
|
@if ! command -v golangci-lint &> /dev/null; then \
|
|
echo "golangci-lint not found. Installing..."; \
|
|
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION); \
|
|
fi
|
|
@golangci-lint run
|