How harness/harness-schema works
Project Type & Purpose
• This is an open-source “schema store” and generation tool for Harness NextGen Pipeline YAML.
• It provides JSON/YAML schema definitions (v0/v1) for pipelines, templates, triggers, events, etc., and a bundler to generate pipeline.json and template.json.
• Consumers include:
• Harness Pipeline Service & Template Service (prod/QA/local)
• IDEs/Text editors (VS Code, Sublime) via YAML extension
• Devspaces environment (fetches remote schema)
File Structure Analysis
• Top-level:
• bundler/ – Java code & Bazel rules to assemble schema modules (SchemaBundleTool, SchemaBundlerRegistrar).
• v0/, v1/ – Versioned schema directories containing:
– pipeline.json, template.json (root schemas)
– pipeline/, template/, trigger/, steps/, etc. subdirectories of YAML schema definitions.
• cdevents/ – Conformance templates and event examples.
• scripts/ – Node.js scripts for generating Markdown docs or aiding bundler.
• Build config: WORKSPACE, BUILD.bazel, .bazelversion, plus bundler/tools/bazel macros.
README Insights
• Explains how to embed schemas in VS Code/Sublime via remote URLs.
• Describes a runtime flag (USE_SCHEMA_FROM_HARNESS_SCHEMA_REPO) to toggle between local and remote schema consumption.
• Defines the Bazel command to regenerate schemas:
bazel run bundler/schema_store:module
a. Main Components
• Schema Generation Pipeline
• Bundler Module (Java + Bazel)
• Input: YAML schema source files (v*/.../*.yaml)
• Output: v*/pipeline.json, v*/template.json
• Schema Store Repositories
• GitHub harness-schema repo with versioned folders
• Consumers
• Harness Pipeline Service & Template Service (microservices)
• IDE/Text Editor Plugins (YAML extension in VS Code/Sublime)
• Devspaces/CI environments
b. Relationships & Interactions
• Bundler → Schema Store: on commit, Bazel build triggers Java tool to produce JSON schemas under v0/, v1/.
• Harness Services (Pipeline/Template) load schema:
• If USE_SCHEMA_FROM_HARNESS_SCHEMA_REPO=false, read v*/pipeline.json locally.
• If USE_SCHEMA_FROM_HARNESS_SCHEMA_REPO=true, fetch remote JSON from GitHub.
• IDEs consume remote URLs directly for auto-intelliSense.
c. Architectural Patterns & Principles
• Code-generation pipeline: source YAML → Java tool → JSON Schema artifacts.
• Versioned API schema: v0/v1 directories to support backward compatibility.
• Flag-driven configuration for flexibility (local vs remote schema).
• Clear separation of concerns: schema definition vs schema consumption.
d. Key Technologies & Frameworks
• Bazel build system & custom Starlark macros
• Java (bundler code) + Maven metadata (main_maven_install.json)
• JSON Schema & YAML definitions
• Node.js scripts (Markdown generation)
• cdevents specification files for event conformance
Detailed Coverage
• Bundler’s internal flow: Java classes → registration → module output.
• Versioning folder structure and that both v0 and v1 are maintained in parallel.
• Where cdevents and scripts fit in (optional extensions).