Node.js, Python and Ruby clients
If you can run clavis run, do: it needs no code changes. When you can't install the CLI (a serverless function, a slim container), these single-file clients fetch an environment's secrets at start-up. All have no dependencies.
You need a token with the secrets:read-values permission for the environment, for example a machine identity limited to it:
clavis identities create web-prod --type machine --project web-app --identity-env productionSet CLAVIS_SERVER, CLAVIS_TOKEN, CLAVIS_ORG, CLAVIS_PROJECT and CLAVIS_ENV (default dev) in the host's settings.
Node.js (18 or later)
npm install @dumhouse/clavis-clientOr copy sdk/node/clavis.mjs into your project and import ./clavis.mjs instead.
import { loadSecrets } from '@dumhouse/clavis-client'
await loadSecrets() // fills process.env; values already set winfetchSecrets() returns the values as an object instead, and both accept server, token, org, project, env and timeoutMs options.
Python (3.8 or later)
pip install clavis-clientOr copy sdk/python/clavis_client.py into your project; the import is the same.
import clavis_client
clavis_client.load_secrets() # fills os.environ; values already set winfetch_secrets() returns a dict, and both functions accept server, token, org, project, env and timeout.
Ruby (3.1 or later)
Copy sdk/ruby/clavis_client.rb into your project and require it:
require_relative "clavis_client"
Clavis.load_secrets # fills ENV; values already set winfetch_secrets returns a hash instead, and both methods accept server, token, org, project, env and timeout keyword arguments.
Things to know
- Every fetch is a read of the environment's values and is recorded in the audit log.
- Nothing is cached: if the server is down at start-up, the call raises an error. Handle it, or fail the start-up on purpose.
- These clients do not mask output. Do not log what they return.