aio-cli-plugin-runtime
aio-cli-plugin-runtime copied to clipboard
ACNA-335 - Env variables in manifest yaml with ${*} syntax break deploy
Describe the bug
Relates to #21
Accessing an environment variable in the manifest yaml with ${*}
syntax breaks the runtime deploy
cmd.
As a comparison, this syntax works with wskdeploy
Environment variable accessed with $*
work fine
JIRA issue created: https://jira.corp.adobe.com/browse/ACNA-335
Also, the format $* is supported only for "inputs". It should be supported for all attribute values. Further, this means we cannot dynamically change the names of packages/actions. wskdeploy doesnt seem to support this but serverless does this using a "name" attribute under package/action. We can consider that.
@moritzraho Can you elaborate more on this? I am unclear on what you are trying to accomplish. A failing test would be awesome!!!
@purplecabbage sorry for the confusing bug description and thanks for looking into this 😄
This is about accessing environment variables in the manifest file. When there are accessed using the ${MY_ENV}
syntax, the deployment breaks, while the $MY_ENV
syntax works fine. But both work in wskdeploy so I would except the ${MY_ENV}
syntax to work here as well or some documentation somewhere on how to access env vars.
I think @Himavanth point is about accessing variables declared in the manifest file. We should probably file this in a separate issue.
Btw I couldn't see any test for deploy with env vars in manifest (not even for the working $ENV syntax). I have smthg like this in mind:
Fixture /deploy/manifest_withEnvVars.yaml
packages:
testEnv:
version: 1.0
license: Apache-2.0
actions:
actionWithEnvInput:
function: /deploy/hello.js
inputs:
fakeTestEnv: $FAKE_TEST_ENV
fakeTestEnvCurly: ${FAKE_TEST_ENV_CURLY}
Test in deploy/index.test.js
:
test('deploys actions with env vars as inputs in manifest', () => {
let cmd = ow.mockResolved(owAction, '')
command.argv = ['-m', '/deploy/manifest_withEnvVars.yaml']
process.env['FAKE_TEST_ENV'] = 'fake-test-env'
process.env['FAKE_TEST_ENV_CURLY'] = 'fake-test-env-curly'
return command.run()
.then(() => {
expect(cmd).toHaveBeenCalledWith({
name: 'testEnv/actionWithEnvInput',
action: hello,
params: { fakeTestEnv: 'fake-test-env', fakeTestEnvCurly: 'fake-test-env-curly' },
})
expect(stdout.output).toMatch('')
})
})
The syntax doesn't break the runtime deploy
anymore, but the variable doesn't get parsed.
We should handle the parsing for both $ENV and ${ENV} to stay aligned with wskdeploy.