Class BootBinding

java.lang.Object
io.karatelabs.core.BootBinding

public class BootBinding extends Object
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 of karate.env (CLI -e flag).
  • 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 the io.karatelabs.ext.<name>.<Name>Ext convention, fire its Ext.onBoot(Suite), register it with the Suite, and return the instance so the boot script can configure it.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BootBinding(Suite suite, String env)
    Production constructor — wires a live Suite for ext registration.
    BootBinding(Suite suite, Path workingDir, String env, Consumer<Ext> registrar)
    Explicit constructor for tests + advanced callers — decouples workingDir + listener registration from a fully-instantiated Suite.
  • Method Summary

    Modifier and Type
    Method
    Description
    ext(String name)
    boot.ext('name') — resolve + construct + register an ext.
    boot.env — JS sees this as a property, not a method.
     
    void
    log(Object msg)
    boot.log('...') — INFO log with [boot] prefix.
    Collected manifest array shape for SUITE_ENTER.data.exts[].
    read(String path)
    boot.read('path') — read text file relative to the Suite's workdir.
    sysenv(String name)
    boot.sysenv('NAME') — read an OS env var; null if unset.
    sysenv(String name, String defaultValue)
    boot.sysenv('NAME', 'default') — read an OS env var, falling back to defaultValue when unset or empty (shell ${VAR:-default} semantics).
    boot.sysprop('NAME') — read a JVM system property; null if unset.
    sysprop(String name, String defaultValue)
    boot.sysprop('NAME', 'default') — read a JVM system property, falling back to defaultValue when unset or empty.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BootBinding

      public BootBinding(Suite suite, String env)
      Production constructor — wires a live Suite for ext registration.
    • BootBinding

      public BootBinding(Suite suite, Path workingDir, String env, Consumer<Ext> registrar)
      Explicit constructor for tests + advanced callers — decouples workingDir + listener registration from a fully-instantiated Suite.
  • Method Details

    • getEnv

      public String getEnv()
      boot.env — JS sees this as a property, not a method.
    • sysenv

      public String sysenv(String name)
      boot.sysenv('NAME') — read an OS env var; null if unset.
    • sysenv

      public String sysenv(String name, String defaultValue)
      boot.sysenv('NAME', 'default') — read an OS env var, falling back to defaultValue when unset or empty (shell ${VAR:-default} semantics). Collapses the previous boot.sysenv('FOO') || 'default' idiom into a single call.
    • sysprop

      public String sysprop(String name)
      boot.sysprop('NAME') — read a JVM system property; null if unset.
    • sysprop

      public String sysprop(String name, String defaultValue)
      boot.sysprop('NAME', 'default') — read a JVM system property, falling back to defaultValue when unset or empty. Reads from the Suite's merged property map when available so Runner.Builder.systemProperties(...) injections are visible, otherwise falls back to System.getProperty(String).
    • read

      public String read(String path)
      boot.read('path') — read text file relative to the Suite's workdir.
    • log

      public void log(Object msg)
      boot.log('...') — INFO log with [boot] prefix.
    • ext

      public Ext ext(String name)
      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

      public Set<Ext> getExts()
    • manifests

      public List<Map<String,Object>> manifests()
      Collected manifest array shape for SUITE_ENTER.data.exts[].