How can I access environment variables in a Canton bootstrap script?

I’m using a Canton bootstrap script to allocate parties/users and upload DARs at startup. I’d like to make this configurable in a Docker Compose setting. Is there a way I can access environment variables from within the script, or maybe there’s a different / better way how to parametrize the boostrap script?

Use something like the following:

val fullyQualfiedDomainId = sys.env.getOrElse(“ENV_VAR_NAME”, throw new IllegalStateException(“missing required environment variable ENV_VAR_NAME”))

1 Like

Here are some more examples, for my future self:

// provide default
val location = sys.env.getOrElse("DEMO_ROOT", "examples/demo")

// throw if missing
val host = sys.env.getOrElse("HOST_NAME",
   sys.error("missing required environment variable HOST_NAME"))

// with pattern matching
val namespace = sys.env.get("PARENT_TYPE") match {
  case None =>
    throw new IllegalArgumentException("missing PARENT_TYPE env var")
  case Some("Service") =>
  case _ =>