A web service and CLI tool for validating Hedgehog Open Network Fabric (ONF) configuration files using the hhfab
utility.
The Validator service provides a simple way to validate ONF configuration files without requiring users to install and configure the hhfab
utility locally. It supports two validation use cases:
- UC1: Validate wiring diagram only (generates default fab.yaml)
- UC2: Validate both wiring diagram and custom fab.yaml
# Build and run the service
make docker-run
# Service will be available at http://localhost:8080
# Build CLI tool
make build-cli
# Validate wiring diagram only
./cmd/validator -w path/to/wiring.yaml
# Validate both wiring and fab files
./cmd/validator -w path/to/wiring.yaml -f path/to/fab.yaml
# Use custom server URL
./cmd/validator -w wiring.yaml -s http://remote-server:8080
# Verbose output
./cmd/validator -w wiring.yaml -v
- Go 1.21 or later
- Docker (for containerized deployment)
# Clone the repository
git clone <repository-url>
cd validator
# Install dependencies
make deps
# Build all components
make build
# Run tests
make test
POST /validate
Content-Type: multipart/form-data
# Required:
wiring: <wiring-diagram-file>
# Optional:
fab: <fabricator-config-file>
Example with curl:
# UC1: Wiring only
curl -X POST http://localhost:8080/validate \
-F "[email protected]"
# UC2: Wiring + Fab
curl -X POST http://localhost:8080/validate \
-F "[email protected]" \
-F "[email protected]"
GET /health
GET /
{
"success": true,
"message": "Fabricator config and wiring are valid",
"output": "06:37:39 INF Hedgehog Fabricator version=v0.40.0...",
"use_case": "uc1"
}
PORT
: Server port (default: 8080)GIN_MODE
: Gin mode (default: release)
-w, --wiring
: Path to wiring diagram file (required)-f, --fab
: Path to fabricator config file (optional)-s, --server
: Server URL (default: http://localhost:8080)-v, --verbose
: Enable verbose output-t, --timeout
: Request timeout in seconds (default: 30)
validator/
├── cmd/ # CLI client
├── server/ # Web service
├── tests/ # Test files
├── docs/project/ # Project documentation
├── scripts/ # Build and deployment scripts
├── Dockerfile # Container definition
├── Makefile # Build automation
└── README.md # This file
- Make changes to code
- Run tests:
make test
- Build binaries:
make build
- Test Docker build:
make docker-build
- Commit with conventional commit format
# Run unit tests
make test
# Test CLI functionality
make test-cli
# Test server locally
make run-server
# Build image
make docker-build
# Run container
sudo docker run -p 8080:8080 validator:1.0.0
# Build server binary
make build-server
# Run server
./server/validator-server
apiVersion: wiring.githedgehog.com/v1beta1
kind: VLANNamespace
metadata:
name: default
spec:
ranges:
- from: 1000
to: 2999
---
apiVersion: wiring.githedgehog.com/v1beta1
kind: Switch
metadata:
name: spine-1
spec:
role: spine
apiVersion: fabricator.githedgehog.com/v1beta1
kind: Fabricator
metadata:
name: default
namespace: fab
spec:
config:
fabric:
mode: spine-leaf
-
"hhfab utility not available"
- Ensure Docker image is built correctly
- Check that hhfab is installed in container
-
"Request timeout"
- Increase timeout with
-t
flag - Check server logs for processing delays
- Increase timeout with
-
"File too large"
- Files must be under 10MB each
- Check file size and content
- Check the API documentation
- Review development guidelines
- Check architecture documentation