Skip to content

Commit 104d923

Browse files
authored
fix reading env var (#18)
1 parent 435ba11 commit 104d923

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ npm install @adobe/aio-lib-state
3838
// init
3939
// init sdk using OpenWhisk credentials
4040
const state = await stateLib.init({ ow: { namespace, auth } })
41-
// init when env vars __OW_AUTH and __OW_NAMESPACE are set (e.g. when running in an OpenWhisk action)
41+
// init when env vars __OW_API_KEY and __OW_NAMESPACE are set (e.g. when running in an OpenWhisk action)
4242
const state = await stateLib.init()
4343
// or if you want to use your own cloud DB account
4444
const state = await stateLib.init({ cosmos: { endpoint, masterKey, databaseId, containerId, partitionKey } })

doc/api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<a href="#module_types..OpenWhiskCredentials">OpenWhisk credentials</a> in
2323
<code>config.ow</code> or your own
2424
<a href="#module_types..AzureCosmosMasterCredentials">Azure Cosmos credentials</a> in <code>config.cosmos</code>.</p>
25-
<p>OpenWhisk credentials can also be read from environment variables <code>__OW_NAMESPACE</code> and <code>__OW_AUTH</code>.</p>
25+
<p>OpenWhisk credentials can also be read from environment variables <code>__OW_NAMESPACE</code> and <code>__OW_API_KEY</code>.</p>
2626
</dd>
2727
</dl>
2828

@@ -187,15 +187,15 @@ To use the SDK you must either provide your
187187
`config.ow` or your own
188188
[Azure Cosmos credentials](#module_types..AzureCosmosMasterCredentials) in `config.cosmos`.
189189

190-
OpenWhisk credentials can also be read from environment variables `__OW_NAMESPACE` and `__OW_AUTH`.
190+
OpenWhisk credentials can also be read from environment variables `__OW_NAMESPACE` and `__OW_API_KEY`.
191191

192192
**Kind**: global function
193193
**Returns**: [<code>Promise.&lt;StateStore&gt;</code>](#StateStore) - A StateStore instance
194194

195195
| Param | Type | Default | Description |
196196
| --- | --- | --- | --- |
197197
| [config] | <code>object</code> | <code>{}</code> | used to init the sdk |
198-
| [config.ow] | [<code>OpenWhiskCredentials</code>](#module_types..OpenWhiskCredentials) | | [OpenWhiskCredentials](#module_types..OpenWhiskCredentials). Set those if you want to use ootb credentials to access the state management service. OpenWhisk namespace and auth can also be passed through environment variables: `__OW_NAMESPACE` and `__OW_AUTH` |
198+
| [config.ow] | [<code>OpenWhiskCredentials</code>](#module_types..OpenWhiskCredentials) | | [OpenWhiskCredentials](#module_types..OpenWhiskCredentials). Set those if you want to use ootb credentials to access the state management service. OpenWhisk namespace and auth can also be passed through environment variables: `__OW_NAMESPACE` and `__OW_API_KEY` |
199199
| [config.cosmos] | [<code>AzureCosmosMasterCredentials</code>](#module_types..AzureCosmosMasterCredentials) \| [<code>AzureCosmosPartitionResourceCredentials</code>](#module_types..AzureCosmosPartitionResourceCredentials) | | [Azure Cosmos resource credentials](#module_types..AzureCosmosPartitionResourceCredentials) or [Azure Cosmos account credentials](#module_types..AzureCosmosMasterCredentials) |
200200
| [config.tvm] | <code>object</code> | | tvm configuration, applies only when passing OpenWhisk credentials |
201201
| [config.tvm.apiUrl] | <code>string</code> | | alternative tvm api url. |

e2e/e2e.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ beforeEach(() => {
2424
})
2525

2626
const initStateEnv = async (n = 1) => {
27-
delete process.env.__OW_AUTH
27+
delete process.env.__OW_API_KEY
2828
delete process.env.__OW_NAMESPACE
29-
process.env.__OW_AUTH = process.env[`TEST_AUTH_${n}`]
29+
process.env.__OW_API_KEY = process.env[`TEST_AUTH_${n}`]
3030
process.env.__OW_NAMESPACE = process.env[`TEST_NAMESPACE_${n}`]
3131
// 1. init will fetch credentials from the tvm using ow creds
3232
const state = await stateLib.init() // { tvm: { cacheFile: false } } // keep cache for better perf?
@@ -39,9 +39,9 @@ const waitFor = (ms) => new Promise(resolve => setTimeout(resolve, ms))
3939

4040
describe('e2e tests using OpenWhisk credentials (as env vars)', () => {
4141
test('error bad credentials test: auth is ok but namespace is not', async () => {
42-
delete process.env.__OW_AUTH
42+
delete process.env.__OW_API_KEY
4343
delete process.env.__OW_NAMESPACE
44-
process.env.__OW_AUTH = process.env.TEST_AUTH_1
44+
process.env.__OW_API_KEY = process.env.TEST_AUTH_1
4545
process.env.__OW_NAMESPACE = process.env.TEST_NAMESPACE_1 + 'bad'
4646

4747
try {

lib/init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ async function wrapTVMRequest (promise, params) {
3737
* `config.ow` or your own
3838
* [Azure Cosmos credentials]{@link module:types~AzureCosmosMasterCredentials} in `config.cosmos`.
3939
*
40-
* OpenWhisk credentials can also be read from environment variables `__OW_NAMESPACE` and `__OW_AUTH`.
40+
* OpenWhisk credentials can also be read from environment variables `__OW_NAMESPACE` and `__OW_API_KEY`.
4141
*
4242
* @param {object} [config={}] used to init the sdk
4343
*
4444
* @param {module:types~OpenWhiskCredentials} [config.ow]
4545
* {@link module:types~OpenWhiskCredentials}. Set those if you want
4646
* to use ootb credentials to access the state management service. OpenWhisk
4747
* namespace and auth can also be passed through environment variables:
48-
* `__OW_NAMESPACE` and `__OW_AUTH`
48+
* `__OW_NAMESPACE` and `__OW_API_KEY`
4949
*
5050
* @param {module:types~AzureCosmosMasterCredentials|module:types~AzureCosmosPartitionResourceCredentials} [config.cosmos]
5151
* [Azure Cosmos resource credentials]{@link module:types~AzureCosmosPartitionResourceCredentials} or

0 commit comments

Comments
 (0)