How redhat-data-and-ai/naysayer works
Project Type and Purpose
• NAYSAYER is a standalone backend service written in Go. It implements a GitLab webhook endpoint that automatically approves merge requests when warehouse sizes decrease in dataproduct YAML configurations. It does not include a UI; it’s a single-purpose automation/microservice.
Key Architectural Components (to represent
a. HTTP/Webhook Layer
• POST /webhook endpoint (cmd/main.go → Fiber router)
• GET /health endpoint for Kubernetes/OpenShift readiness and liveness checks
b. Configuration & Deployment
• config/*.yaml (deployment.yaml, route.yaml, serviceaccount.yaml, secrets.yaml.example)
• Environment variables (GITLAB_TOKEN, GITLAB_BASE_URL, PORT)
c. GitLab Client
• internal/gitlab/client.go: fetch MR changes via GitLab API
• internal/gitlab/file_content.go: retrieve individual file contents if needed
d. Rules Engine
• internal/rules/manager.go: orchestrates rule evaluation
• internal/rules/registry.go: holds available rules
• internal/rules/warehouse/analyzer.go + rule.go: implements warehouse-size-change logic
• shared types and utils (internal/rules/shared)
e. Logging
• internal/logging/logger.go: structured logging, log levels
f. Core Flow
• HTTP receives webhook → Configuration loaded → GitLab client fetches diffs → Rules manager analyzes diffs → Decision (approve or require manual review) → If auto-approve, GitLab client posts MR approval comment via API → Respond to webhook.
Relationships and Data Flow
• External System: GitLab sends merge request events → NAYSAYER /webhook
• HTTP handler decodes JSON payload → extracts project ID + MR IID
• Rules manager calls GitLab client to fetch MR changes
• Warehouse analyzer parses diff hunks for “warehouses:” blocks → computes up/down transitions
• Decision module determines auto-approve or deny → if approve, GitLab client POSTs an approval comment
• NAYSAYER returns JSON summary to caller
• Health endpoint always returns 200 if running
Architectural Patterns and Design Principles
• Layered design: Transport (HTTP) → Application (rules manager) → Infrastructure (GitLab API client)
• Single Responsibility: each package (logging, config, gitlab, rules, webhook) has one focus
• Dependency Injection via constructor functions in packages
• Test coverage: almost every package has accompanying _test.go
Technologies and Frameworks
• Go (1.23+)
• GoFiber for HTTP routing
• Kubernetes/OpenShift deployment manifests
• GitLab REST API v4
• YAML parsing (gopkg.in/yaml.v3 or similar)
• Makefile for build tasks, Dockerfile for container image