⚙️ JSONNET RUNE DIFFICULTY: Apprentice Creational

The Prototype of Jsonnet

Cloning and overriding configurations by inheritance.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Prototype
ARCANUM SCHOOL: Illusion // Cloning
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// JSONNET PATTERN //
local BaseConfig = {
  timeout: 30,
  retries: 3,
  debug: false
};

local ProdConfig = BaseConfig {
  retries: 5
};

local DevConfig = BaseConfig {
  debug: true,
  timeout: 120
};

{
  prod: ProdConfig,
  dev: DevConfig
}

In Jsonnet, the Prototype pattern is a native spell. Every object can act as a prototype, and extending it via + or {} creates a cloned construct with its own unique traits.

Runic Tags: #creational #prototype #jsonnet