$ show Kong/deck
decK is a CLI tool for declarative configuration management of Kong API Gateway and Konnect SaaS. It enables users to manage Kong entities (services, routes, plugins, consumers, certificates, etc.) via YAML/JSON state files, supporting sync, diff, dump, apply, reset, and validate operations. The architecture is a single binary with multiple subcommands organized under `gateway`, `file`, `ai`, and `konnect` namespaces, built on top of Kong's go-database-reconciler library for state reconciliation. Key entry points include `main.go` (signal handling), `cmd/root.go` (Cobra CLI), and command handlers in `cmd/gateway_*.go`, `cmd/file_*.go`, and `cmd/ai_*.go`. Data flows involve reading declarative state files, fetching current state from Kong Admin API or Konnect, computing diffs, and applying CRUD operations. External dependencies include Kong Gateway (>=1.x), Kong Enterprise, Konnect, and various Go libraries for Kubernetes, Terraform, and AI Gateway integrations. The repository also includes converters for generating Kubernetes Ingress Controller manifests (`kong2kic`), Terraform resources (`kong2tf`), and version migration rulesets (`convert/`).
The LLM identified 4 files worth highlighting for reuse:
Implements a reflection-based traversal that recursively walks arbitrary state structs to hash sensitive fields (passwords, keys, certificates, IPs) for safe dump output. Uses dynamic exemption maps built from Kong schemas, making it adaptable to different entity types without hardcoding field paths. This pattern is reusable for any configuration sanitization task where sensitive values must be masked before sharing.
Orchestrates version conversion pipelines for Kong declarative configs (e.g., 2.8→3.4, 3.4→3.10, 3.10→3.14). Uses embedded rulesets (JSON Schema-based linting rules) to validate and transform plugin configs, route fields, and service definitions. The ruleset pattern with `given`, `message`, `severity`, and `then` functions is a reusable validation framework that can be applied to any config migration scenario.
Implements a Director-based builder pattern to convert Kong declarative state into Kubernetes Ingress Controller manifests (KongIngress, KongClusterPlugin, Secrets, etc.). Supports both v2/v3 Gateway API and Ingress API outputs. The builder abstraction allows adding new output formats without modifying core conversion logic, making it reusable for generating any Kubernetes resources from a declarative state.
Implements a builder pattern to generate Terraform HCL resources for Konnect Gateway entities (services, routes, plugins, consumers, etc.). Uses formulaic generation with `generateResource`, `generateRelationship`, `outputHash`, and `outputList` functions. The pattern is reusable for converting any structured configuration into Terraform resource blocks, with support for imports and relationship references.