@strong-roots-capital/docker-secrets
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

docker-secrets Build status npm version codecov

FP loading of docker secrets, falling back on env vars

Install

npm install @strong-roots-capital/docker-secrets

Use

import { secrets } from '@strong-roots-capital/docker-secrets'

async function main() {

    console.log((await secrets.get('user')).orDefault('Ishmael'))
    console.log(secrets.getSync('PWD'))

    const getFromRoot = secrets.getFrom('/root/super-secrets-do-not-share')

    console.log(await getFromRoot('launch-codes'))
    console.log(secrets.getFromSync ('/home/gob') ('illusions'))
}

main()

Related

API

Functions


Functions

get

get(secret: string): Promise<Maybe<string>>

Defined in docker-secrets.ts:100

Get a secret asynchronously, first checking /run/secrets and then falling-back to environment variables.

Parameters:

Name Type
secret string

Returns: Promise<Maybe<string>>


getSync

getSync(secret: string): Maybe<string>

Defined in docker-secrets.ts:116

Get a secret synchronously, first checking /run/secrets and then falling-back to environment variables.

Parameters:

Name Type
secret string

Returns: Maybe<string>


getFrom

getFrom(directory: string): (secret: string) => Promise<Maybe<string>>

Defined in docker-secrets.ts:108

Get a secret asynchronously, first checking directory and then falling-back to environment variables.

Parameters:

Name Type
directory string

Returns: (secret: string) => Promise<Maybe<string>>


getFromSync

getFromSync(directory: string): (secret: string) => Maybe<string>

Defined in docker-secrets.ts:124

Get a secret synchronously, first checking directory and then falling-back to environment variables.

Parameters:

Name Type
directory string

Returns: (secret: string) => Maybe<string>


Dependencies (4)

Dev Dependencies (13)

Package Sidebar

Install

npm i @strong-roots-capital/docker-secrets

Weekly Downloads

1

Version

2.0.0

License

ISC

Unpacked Size

16.5 kB

Total Files

6

Last publish

Collaborators

  • amchelle
  • hamroctopus