Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not propagate default tvm url config #393

Merged
merged 2 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/lib/config-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ module.exports = () => {
config.ow.package = `${config.app.name}-${config.app.version}`
// S3 static files deployment config
config.s3.folder = config.ow.namespace // this becomes the root only /
config.s3.tvmUrl = userConfig.app.tvmurl || defaultTvmUrl
// Legacy applications set the defaultTvmUrl in .env, so we need to ignore it to not
// consider it as custom. The default will be set downstream by aio-lib-core-tvm.
if (userConfig.app.tvmurl !== defaultTvmUrl) {
config.s3.tvmUrl = userConfig.app.tvmurl
}
// set hostname for backend actions && UI
config.app.defaultHostname = defaultAppHostname
config.app.hostname = userConfig.app.hostname || defaultAppHostname
Expand Down
31 changes: 31 additions & 0 deletions test/commands/lib/config-loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const loadConfig = require('../../../src/lib/config-loader')
const mockAIOConfig = require('@adobe/aio-lib-core-config')
const yaml = require('js-yaml')
const chalk = require('chalk')
const defaults = require('../../../src/lib/defaults')

jest.mock('@adobe/aio-lib-core-logging')
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:config-loader', { provider: 'debug' })
Expand Down Expand Up @@ -101,4 +102,34 @@ describe('load config', () => {
expect(config.ow.defaultApihost).toEqual('https://adobeioruntime.net')
expect(config.app.defaultHostname).toEqual('adobeio-static.net')
})

test('Tvm url config', () => {
// custom
mockAIOConfig.get.mockReturnValue({
...global.fakeConfig.creds,
app: {
tvmurl: 'custom'
}
})
config = loadConfig()
expect(config.s3.tvmUrl).toEqual('custom')
// empty
mockAIOConfig.get.mockReturnValue({
...global.fakeConfig.creds,
app: {
tvmurl: undefined
}
})
config = loadConfig()
expect(config.s3.tvmUrl).toEqual(undefined)
// default (should not set it)
mockAIOConfig.get.mockReturnValue({
...global.fakeConfig.creds,
app: {
tvmurl: defaults.defaultTvmUrl
}
})
config = loadConfig()
expect(config.s3.tvmUrl).toEqual(undefined)
})
})