Skip to content
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
3 changes: 2 additions & 1 deletion schema/app.config.yaml.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"type": "object",
"properties": {
"license": { "type": "string" },
"inputs": { "$ref": "#/definitions/inputs" },
"actions": { "$ref": "#/definitions/actions" }
}
},
Expand Down Expand Up @@ -147,7 +148,7 @@
"type": "object",
"patternProperties": {
"^[^\n]+$": {
"type": ["string", "boolean", "object"]
"type": ["string", "boolean", "number", "array", "object", "null"]
}
},
"additionalProperties": false
Expand Down
2 changes: 2 additions & 0 deletions test/__fixtures__/app-exc-nui/app.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ application:
runtime: 'nodejs:14'
inputs:
LOG_LEVEL: 'debug'
TAGS: ['tag1', 'tag2']
MAX_ITEMS: 100
SOMETHING:
type: string
description: this is about something
Expand Down
2 changes: 2 additions & 0 deletions test/__fixtures__/app/app.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ application:
runtime: 'nodejs:14'
inputs:
LOG_LEVEL: 'debug'
TAGS: ['tag1', 'tag2']
MAX_ITEMS: 100
SOMETHING:
type: string
description: this is about something
Expand Down
2 changes: 2 additions & 0 deletions test/__fixtures__/legacy-app/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ packages:
runtime: 'nodejs:14'
inputs:
LOG_LEVEL: 'debug'
TAGS: ['tag1', 'tag2']
MAX_ITEMS: 100
SOMETHING:
type: string
description: this is about something
Expand Down
32 changes: 32 additions & 0 deletions test/data-mocks/config-loader-include-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,22 @@ const appIncludeIndex = {
file: 'app.config.yaml',
key: 'application.runtimeManifest.packages.my-app-package.actions.action.inputs.LOG_LEVEL'
},
'application.runtimeManifest.packages.my-app-package.actions.action.inputs.MAX_ITEMS': {
file: 'app.config.yaml',
key: 'application.runtimeManifest.packages.my-app-package.actions.action.inputs.MAX_ITEMS'
},
'application.runtimeManifest.packages.my-app-package.actions.action.inputs.TAGS': {
file: 'app.config.yaml',
key: 'application.runtimeManifest.packages.my-app-package.actions.action.inputs.TAGS'
},
'application.runtimeManifest.packages.my-app-package.actions.action.inputs.TAGS.0': {
file: 'app.config.yaml',
key: 'application.runtimeManifest.packages.my-app-package.actions.action.inputs.TAGS.0'
},
'application.runtimeManifest.packages.my-app-package.actions.action.inputs.TAGS.1': {
file: 'app.config.yaml',
key: 'application.runtimeManifest.packages.my-app-package.actions.action.inputs.TAGS.1'
},
'application.runtimeManifest.packages.my-app-package.actions.action.inputs.SOMETHING': {
file: 'app.config.yaml',
key: 'application.runtimeManifest.packages.my-app-package.actions.action.inputs.SOMETHING'
Expand Down Expand Up @@ -638,6 +654,22 @@ const legacyIncludeIndex = {
file: 'manifest.yml',
key: 'packages.__APP_PACKAGE__.actions.action.inputs.LOG_LEVEL'
},
'application.runtimeManifest.packages.__APP_PACKAGE__.actions.action.inputs.MAX_ITEMS': {
file: 'manifest.yml',
key: 'packages.__APP_PACKAGE__.actions.action.inputs.MAX_ITEMS'
},
'application.runtimeManifest.packages.__APP_PACKAGE__.actions.action.inputs.TAGS': {
file: 'manifest.yml',
key: 'packages.__APP_PACKAGE__.actions.action.inputs.TAGS'
},
'application.runtimeManifest.packages.__APP_PACKAGE__.actions.action.inputs.TAGS.0': {
file: 'manifest.yml',
key: 'packages.__APP_PACKAGE__.actions.action.inputs.TAGS.0'
},
'application.runtimeManifest.packages.__APP_PACKAGE__.actions.action.inputs.TAGS.1': {
file: 'manifest.yml',
key: 'packages.__APP_PACKAGE__.actions.action.inputs.TAGS.1'
},
'application.runtimeManifest.packages.__APP_PACKAGE__.actions.action.inputs.SOMETHING': {
file: 'manifest.yml',
key: 'packages.__APP_PACKAGE__.actions.action.inputs.SOMETHING'
Expand Down
7 changes: 7 additions & 0 deletions test/data-mocks/config-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ function fullFakeRuntimeManifest (pathToActionFolder, pkgName1) {
runtime: 'nodejs:14',
inputs: {
LOG_LEVEL: 'debug',
TAGS: ['tag1', 'tag2'],
MAX_ITEMS: 100,
SOMETHING: {
type: 'string',
description: 'this is about something',
Expand Down Expand Up @@ -434,6 +436,11 @@ module.exports = (appFixtureName, mockedAIOConfig, rewriteMockConfig = {}) => {
}
if (mockedAIOConfig && mockedAIOConfig.project && mockedAIOConfig.project.org) {
config.all[k].imsOrgId = mockedAIOConfig.project.org.ims_org_id
} else {
config.all[k].imsOrgId = config.all[k].imsOrgId ?? undefined
}
if (config.all[k].app.hasFrontend && config.all[k].s3) {
config.all[k].s3.tvmUrl = config.all[k].s3.tvmUrl ?? undefined
}
config.all[k].ow.package = `${config.packagejson.name}-${config.packagejson.version}`
config.all[k].app.name = config.packagejson.name
Expand Down
137 changes: 137 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,143 @@ application:
await expect(appConfig.load({})).rejects.toThrow('Missing or invalid keys in app.config.yaml')
})

test('valid schema: action inputs support array (OpenWhisk spec)', async () => {
global.fakeFileSystem.addJson(
{
'/package.json': '{}',
'/app.config.yaml': `
application:
runtimeManifest:
packages:
pkg:
actions:
myaction:
function: actions/test.js
inputs:
TAGS: ['tag1', 'tag2', 'tag3']
EMPTY: []
`
}
)
const config = await appConfig.load({})
const inputs = config.all.application.manifest.full.packages.pkg.actions.myaction.inputs
expect(inputs.TAGS).toEqual(['tag1', 'tag2', 'tag3'])
expect(Array.isArray(inputs.TAGS)).toBe(true)
expect(inputs.EMPTY).toEqual([])
})

test('valid schema: action inputs support number (OpenWhisk spec)', async () => {
global.fakeFileSystem.addJson(
{
'/package.json': '{}',
'/app.config.yaml': `
application:
runtimeManifest:
packages:
pkg:
actions:
myaction:
function: actions/test.js
inputs:
COUNT: 42
NEGATIVE: -531
FLOAT: 432.43
`
}
)
const config = await appConfig.load({})
const inputs = config.all.application.manifest.full.packages.pkg.actions.myaction.inputs
expect(inputs.COUNT).toBe(42)
expect(inputs.NEGATIVE).toBe(-531)
expect(inputs.FLOAT).toBe(432.43)
})

test('valid schema: action inputs support null (OpenWhisk spec)', async () => {
global.fakeFileSystem.addJson(
{
'/package.json': '{}',
'/app.config.yaml': `
application:
runtimeManifest:
packages:
pkg:
actions:
myaction:
function: actions/test.js
inputs:
OPTIONAL: null
`
}
)
const config = await appConfig.load({})
const inputs = config.all.application.manifest.full.packages.pkg.actions.myaction.inputs
expect(inputs.OPTIONAL).toBeNull()
})

test('valid schema: action inputs support mixed types (OpenWhisk spec)', async () => {
global.fakeFileSystem.addJson(
{
'/package.json': '{}',
'/app.config.yaml': `
application:
runtimeManifest:
packages:
pkg:
actions:
myaction:
function: actions/test.js
inputs:
STR: hello
NUM: 1
FLAG: true
ARR: [a, b]
OBJ:
type: string
default: ''
NIL: null
`
}
)
const config = await appConfig.load({})
const inputs = config.all.application.manifest.full.packages.pkg.actions.myaction.inputs
expect(inputs.STR).toBe('hello')
expect(inputs.NUM).toBe(1)
expect(inputs.FLAG).toBe(true)
expect(inputs.ARR).toEqual(['a', 'b'])
expect(inputs.OBJ).toEqual({ type: 'string', default: '' })
expect(inputs.NIL).toBeNull()
})

test('valid schema: package-level inputs (same constraints as action inputs)', async () => {
global.fakeFileSystem.addJson(
{
'/package.json': '{}',
'/app.config.yaml': `
application:
runtimeManifest:
packages:
pkg:
license: Apache-2.0
inputs:
PKG_LEVEL: pkg-default
PKG_TAGS: ['a', 'b']
PKG_COUNT: 10
actions:
myaction:
function: actions/test.js
inputs:
ACTION_INPUT: action-value
`
}
)
const config = await appConfig.load({})
const pkg = config.all.application.manifest.full.packages.pkg
expect(pkg.inputs.PKG_LEVEL).toBe('pkg-default')
expect(pkg.inputs.PKG_TAGS).toEqual(['a', 'b'])
expect(pkg.inputs.PKG_COUNT).toBe(10)
expect(pkg.actions.myaction.inputs.ACTION_INPUT).toBe('action-value')
})

test('valid schema with productDependencies', async () => {
global.fakeFileSystem.addJson(
{
Expand Down