Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

docker-secreto

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docker-secreto - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

59

index.js
const fs = require('fs')
const secretos = (key, defaultValue) => new Promise((resolve, reject) => {
fs.readdir('/run/secrets', (err, files) => {
const secrets = files.map(file => {
const secretos = (key, defaultValue) => {
let files = [],
secrets
try {
files = fs.readdirSync('/run/secrets')
} catch (ex) {
// No /run/secrets directory
}
secrets = files.map(file => {
try {
const secret = fs.readFileSync(`/run/secrets/${file}`).toString()
return { file, secret }
})
} catch (ex) {
let secretObjects = {}
if (secrets.length > 0) {
if (!key) {
secrets.forEach(secret => {
secretObjects[secret.file] = secret.secret
})
} else {
let value = secrets[key] || defaultValue
secretObjects = value
}
resolve(secretObjects)
} else {
if (defaultValue) {
secretObjects = defaultValue
} else if (key && !defaultValue) {
secretObjects[key] = {}
}
resolve(secretObjects)
}
})
})
let secretObjects = {}
if (secrets.length > 0) {
if (!key) {
secrets.forEach(secret => {
secretObjects[secret.file] = secret.secret
})
} else
secretObjects = secrets[key] || defaultValue
return secretObjects
} else {
if (defaultValue)
secretObjects = defaultValue
else if (key && !defaultValue)
secretObjects[key] = {}
return secretObjects
}
}
module.exports = secretos
{
"name": "docker-secreto",
"version": "1.0.3",
"version": "1.1.0",
"description": "pull docker secrets into an object",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -12,7 +12,7 @@ # docker-secreto

```js
const secreto = require('docker-secreto')
const dockerSecreto = require('docker-secreto')
secreto()
.then(secretos => console.info(secretos))
.catch(err => console.error(err))
let values = dockerSecreto()
console.info(values)
```

@@ -30,7 +30,7 @@

```js
const secreto = require('docker-secreto')
const dockerSecreto = require('docker-secreto')
secreto('secret_name', 'Default Value')
.then(secretos => console.info(secretos))
.catch(err => console.error(err))
let values = dockerSecreto('secret_name', 'Default Value')
console.info(values)
```

@@ -45,7 +45,7 @@

```js
const secreto = require('docker-secreto')
const dockerSecreto = require('docker-secreto')
secreto('secret_name', 'Default Value')
.then(secretos => console.info(secretos))
.catch(err => console.error(err))
let values = dockerSecreto('secret_name', 'Default Value')
console.info(values)
```

@@ -52,0 +52,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc