(key: string): any
(all: boolean): any
(arguments: {
all?: boolean,
key?: string,
default?: any
}): any
The _secret
operator gets a value from the secret
object. The secrets
is a data object that contains sensitive information like passwords or API keys. The _secret
operator can only be used in connections
and requests
. Secrets are read from environment variables on the server that start with LOWDEFY_SECRET_
, (i.e. LOWDEFY_SECRET_SECRET_NAME
). The name of the secret is the part after LOWDEFY_SECRET_
. Since environment variables can only be strings, secrets can be JSON encoded, and parsed using the _json.parse
method.
Arguments
string
If the _secret
operator is called with a string argument, the value of the key in the secrets
object is returned. If the value is not found, null
is returned.
boolean
If the _secret
operator is called with boolean argument true
, the entire secrets
object is returned.
object
all: boolean
: Ifall
is set totrue
, the entiresecrets
object is returned. One ofall
orkey
are required.key: string
: The value of the key in thesecrets
object is returned. If the value is not found,null
, or the specified default value is returned. One ofall
orkey
are required.default: any
: A value to return if thekey
is not found insecrets
. By default,null
is returned if a value is not found.
Examples
Get the value of MY_SECRET
from secrets
:
_secret: MY_SECRET
_secret:
key: MY_SECRET
Returns: The value of MY_SECRET
in secrets
.
Get the entire secret
object:
_secret: true
_secret:
all: true
Returns: The entire secrets
object.
Return a default value if the value is not found:
_secret:
key: MY_SECRET
default: Not so secret
Returns: The value of MY_SECRET
, or "Not so secret"
.