How graceinfra/grace works
Project type and purpose
• From the README (“grace – Declarative workflow orchestration for the mainframe and hybrid cloud”) and the presence of a Go‐based CLI (cmd/*.go) with subcommands (deck, init, run, submit), this is a command‐line orchestration tool. It reads declarative workflow definitions (grace.yml), applies templates (JCL, YAML), and drives mainframe or cloud deployments via external automation layers (e.g., Zowe).
File structure
• Top‐level files
• main.go – entry point that wires the CLI.
• go.mod / go.sum – dependency management.
• cmd/ – each *.go is a subcommand (root, init, init_tui, deck, run, submit) likely using Cobra or a similar framework.
• internal/templates/ – holds Go code + JCL/YML templates for generating deployment artifacts.
• utils/ – cross‐command utilities: execution wrappers, logging, type definitions, Zowe integration.
• No GUI or web frontend; purely CLI + templating + external service calls.
Components & Interactions
a. Main Components
1. CLI Frontend (cmd/*) – parses user commands & flags
2. Command Dispatcher – route to appropriate handler (deck, init, run, submit)
3. Core Engine
– Template Manager (internal/templates)
– Workflow Definition Loader (reads grace.yml)
– Execution Coordinator (utils/exec.go)
4. Utilities
– Logging (utils/log.go)
– Type definitions (utils/types.go)
– Zowe Integration (utils/zowe.go)
5. External Services
– Zowe REST API / CLI → Mainframe (z/OS)
– (Optional) Cloud orchestration endpoint (k8s, CI/CD, etc.)
b. Relationships / Data Flows
• User invokes CLI → Command Dispatcher
• Dispatcher loads workflow (grace.yml) → passes to Template Manager
• Template Manager renders JCL/YAML artifacts → saves locally or streams
• Execution Coordinator uses utils/exec or utils/zowe to submit jobs to mainframe or cloud
• Responses / job statuses piped back to CLI → formatted and logged
c. Architectural patterns / principles
• Layered architecture: Presentation (CLI) → Application Logic (dispatcher + core) → Infrastructure (templates + external calls)
• Single Responsibility for each subcommand
• Dependency injection via Go interfaces (e.g., execRunner, zoweClient)
• Templating pattern for artifact generation
d. Key technologies / libraries
• Go Modules
• Cobra (or equivalent) for CLI commands
• Go’s text/template for JCL/YAML generation
• Zowe SDK or CLI (utils/zowe.go) for mainframe interactions