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
22 changes: 13 additions & 9 deletions src/runtime-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,21 +348,25 @@ function checkWebFlags (flag) {

function createActionObject (thisAction, objAction) {
if (thisAction['function'].endsWith('.zip')) {
if (!thisAction['runtime']) {
if (!thisAction['runtime'] && !thisAction['docker']) {
throw (new Error(`Invalid or missing property "runtime" in the manifest for this action: ${objAction.name}`))
}
objAction.action = fs.readFileSync(thisAction['function'])
} else {
objAction.action = fs.readFileSync(thisAction['function'], { encoding: 'utf8' })
}

if (thisAction['runtime']) {
// thisAction['runtime'] = thisAction['runtime'].replace('@', ':') - Conflict in documentation
objAction['kind'] = thisAction['runtime']
}

if (thisAction['main']) {
objAction['exec'] = { main: thisAction['main'] }
if (thisAction.main || thisAction.docker || thisAction.runtime) {
objAction.exec = {}
if (thisAction.main) {
objAction.exec.main = thisAction.main
}
if (thisAction.docker) {
objAction.exec.kind = 'blackbox'
objAction.exec.image = thisAction.docker
} else if (thisAction.runtime) {
objAction.exec.kind = thisAction.runtime
}
}

if (thisAction.limits) {
Expand Down Expand Up @@ -600,7 +604,7 @@ async function deployPackage (entities, ow, logger) {
logger(`Info: package [${pkg.name}] has been successfully deployed.\n`)
}
for (const action of entities.actions) {
if (action['exec'] && action['exec']['kind']) {
if (action['exec'] && action['exec']['kind'] === 'sequence') {
action['exec']['components'] = action['exec']['components'].map(sequence => {
/*
Input => Output
Expand Down
13 changes: 13 additions & 0 deletions test/__fixtures__/deploy/manifest_docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements; and to You under the Apache License, Version 2.0.

# Example: Blackbox action with a custom docker image
packages:
demo_package:
actions:
sampleAction:
function: /deploy/main.js
main: split
web: false
docker: my/docker-image:1.0.0

24 changes: 24 additions & 0 deletions test/commands/runtime/deploy/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe('instance methods', () => {
'deploy/manifest_api.yaml': fixtureFile('deploy/manifest_api.yaml'),
'deploy/manifest_main.yaml': fixtureFile('deploy/manifest_main.yaml'),
'deploy/manifest_final.yaml': fixtureFile('deploy/manifest_final.yaml'),
'deploy/manifest_docker.yaml': fixtureFile('deploy/manifest_docker.yaml'),
'deploy/manifest_api_incorrect.yaml': fixtureFile('deploy/manifest_api_incorrect.yaml'),
'deploy/deployment_syncMissingAction.yaml': fixtureFile('deploy/deployment_syncMissingAction.yaml'),
'deploy/manifest_multiple_packages.yaml': fixtureFile('deploy/manifest_multiple_packages.yaml'),
Expand Down Expand Up @@ -359,6 +360,29 @@ describe('instance methods', () => {
})
})

test('deploys actions with docker image', () => {
const cmd = ow.mockResolved(owAction, '')
const mainAction = fixtureFile('deploy/main.js')
command.argv = ['-m', '/deploy/manifest_docker.yaml']
return command.run()
.then(() => {
expect(cmd).toHaveBeenCalledWith({
name: 'demo_package/sampleAction',
action: mainAction,
annotations: {
'raw-http': false,
'web-export': false
},
exec: {
image: 'my/docker-image:1.0.0',
kind: 'blackbox',
main: 'split'
}
})
expect(stdout.output).toMatch('')
})
})

test('deploys actions with manifest inputs when no actions present in deployment file', () => {
const cmd = ow.mockResolved(owAction, '')
command.argv = ['-m', '/deploy/manifest_dep.yaml', '--deployment', '/deploy/deployment_wrongTrigger.yaml']
Expand Down