⚙️ JSONNET RUNE DIFFICULTY: Apprentice Creational

The Singleton of Jsonnet

A single source of truth for global configurations.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Singleton
ARCANUM SCHOOL: Abjuration // Isolation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// JSONNET PATTERN //
local GlobalSettings = {
  appName: "ArcaneApp",
  version: "1.0.0",
  maxConnections: 100
};

local ModuleA = {
  settings: GlobalSettings,
  name: "ModuleA"
};

local ModuleB = {
  settings: GlobalSettings,
  name: "ModuleB"
};

{
  a: ModuleA,
  b: ModuleB
}

Jsonnet enforces referential transparency. A global object declared as a local variable acts as a Singleton, weaving an identical thread of configuration across multiple constructs.

Runic Tags: #creational #singleton #jsonnet