Package io.karatelabs.core
Class BootBinding
java.lang.Object
io.karatelabs.core.BootBinding
Backing object for the
boot global exposed inside karate-boot.js.
karate-boot.js is ext-scripting only — its JS scope is discarded after the file evaluates, so variables defined there cannot leak into the feature-runtime scope. The only API surface is this class. See AGENT_KARATE.md K43.
boot.env— the value ofkarate.env(CLI-eflag).boot.sysenv(name)/boot.sysenv(name, default)— read an OS environment variable, optionally falling back to a default when unset or empty.boot.sysprop(name)/boot.sysprop(name, default)— read a JVM system property; reads from the Suite's merged property map when available.boot.read(path)— read a file (relative paths resolve against workdir).boot.log(msg)— INFO log line, prefixed[boot].boot.ext(name)— resolve + construct the named ext via theio.karatelabs.ext.<name>.<Name>Extconvention, fire itsExt.onBoot(Suite), register it with the Suite, and return the instance so the boot script can configure it.
-
Constructor Summary
ConstructorsConstructorDescriptionBootBinding(Suite suite, String env) Production constructor — wires a live Suite for ext registration.Explicit constructor for tests + advanced callers — decouples workingDir + listener registration from a fully-instantiated Suite. -
Method Summary
Modifier and TypeMethodDescriptionboot.ext('name')— resolve + construct + register an ext.getEnv()boot.env— JS sees this as a property, not a method.getExts()voidboot.log('...')— INFO log with [boot] prefix.Collected manifest array shape for SUITE_ENTER.data.exts[].boot.read('path')— read text file relative to the Suite's workdir.boot.sysenv('NAME')— read an OS env var; null if unset.boot.sysenv('NAME', 'default')— read an OS env var, falling back todefaultValuewhen unset or empty (shell${VAR:-default}semantics).boot.sysprop('NAME')— read a JVM system property; null if unset.boot.sysprop('NAME', 'default')— read a JVM system property, falling back todefaultValuewhen unset or empty.
-
Constructor Details
-
BootBinding
Production constructor — wires a live Suite for ext registration. -
BootBinding
Explicit constructor for tests + advanced callers — decouples workingDir + listener registration from a fully-instantiated Suite.
-
-
Method Details
-
getEnv
boot.env— JS sees this as a property, not a method. -
sysenv
boot.sysenv('NAME')— read an OS env var; null if unset. -
sysenv
boot.sysenv('NAME', 'default')— read an OS env var, falling back todefaultValuewhen unset or empty (shell${VAR:-default}semantics). Collapses the previousboot.sysenv('FOO') || 'default'idiom into a single call. -
sysprop
boot.sysprop('NAME')— read a JVM system property; null if unset. -
sysprop
boot.sysprop('NAME', 'default')— read a JVM system property, falling back todefaultValuewhen unset or empty. Reads from the Suite's merged property map when available soRunner.Builder.systemProperties(...)injections are visible, otherwise falls back toSystem.getProperty(String). -
read
boot.read('path')— read text file relative to the Suite's workdir. -
log
boot.log('...')— INFO log with [boot] prefix. -
ext
boot.ext('name')— resolve + construct + register an ext.Resolution by name convention:
'openapi'→io.karatelabs.ext.openapi.OpenapiExt. The class is loaded from the runtime classloader; missing ext → boot-time failure (suite fails loud).Same name twice returns the same singleton instance.
-
getExts
-
manifests
Collected manifest array shape for SUITE_ENTER.data.exts[].
-