diff --git a/engines/script/config.go b/engines/script/config.go index 6074f2a9..b8517a8f 100644 --- a/engines/script/config.go +++ b/engines/script/config.go @@ -3,7 +3,7 @@ package scriptengine import schematypes "github.com/taskcluster/go-schematypes" type configType struct { - Script []string `json:"script"` + Command []string `json:"command"` Expiration int `json:"expiration"` Schema struct { Type string `json:"type"` @@ -18,9 +18,9 @@ var configSchema = schematypes.Object{ Description: `Configuration properties for the 'scriptengine'.`, }, Properties: schematypes.Properties{ - "script": schematypes.Array{ + "command": schematypes.Array{ MetaData: schematypes.MetaData{ - Title: "Script to Execute", + Title: "Command to Execute", Description: `Script and arguments to execute. This script will be fed a JSON string that matches the schema configured over stdin.`, }, @@ -53,7 +53,7 @@ var configSchema = schematypes.Object{ }, }, Required: []string{ - "script", + "command", "schema", "expiration", }, diff --git a/engines/script/engine_test.go b/engines/script/engine_test.go index 74c2e95c..ef94d459 100644 --- a/engines/script/engine_test.go +++ b/engines/script/engine_test.go @@ -9,7 +9,7 @@ import ( var provider = &enginetest.EngineProvider{ Engine: "script", Config: `{ - "script": ["bash", "-ec", "v=$(cat); echo \"$v\"; echo \"$v\" | grep success"], + "command": ["bash", "-ec", "v=$(cat); echo \"$v\"; echo \"$v\" | grep success"], "schema": { "type": "object", "properties": { diff --git a/engines/script/sandboxbuilder.go b/engines/script/sandboxbuilder.go index 308a34e9..b83c73ed 100644 --- a/engines/script/sandboxbuilder.go +++ b/engines/script/sandboxbuilder.go @@ -18,7 +18,7 @@ type sandboxBuilder struct { } func (b *sandboxBuilder) StartSandbox() (engines.Sandbox, error) { - script := b.engine.config.Script + script := b.engine.config.Command cmd := exec.Command(script[0], script[1:]...) folder, err := b.engine.environment.TemporaryStorage.NewFolder() if err != nil { diff --git a/examples/script-config.yml b/examples/script-config.yml new file mode 100644 index 00000000..cf00fcb2 --- /dev/null +++ b/examples/script-config.yml @@ -0,0 +1,52 @@ +# Example configuration file for script engine deployment on hardware. +transforms: + - abs + - env + - secrets +config: + capacity: 1 + credentials: + # Taskcluster credentials with scopes like: + # - assume:project:taskcluster:worker-test-scopes + clientId: {$env: TASKCLUSTER_CLIENT_ID} + accessToken: {$env: TASKCLUSTER_ACCESS_TOKEN} + provisionerId: {$env: PROVISIONER_ID} # test-dummy-provisioner + workerType: {$env: WORKER_TYPE} # dummy-worker-* + workerGroup: {$env: WORKER_GROUP} # test-dummy-workers + workerId: {$env: WORKER_ID} # dummy-worker-* + engine: script + engines: + script: + # Command should: + # - Read JSON payload from stdin, + # - Read TASK_ID and RUN_ID environment variables (if it wants them), + # - Print log to stdout + # - Write artifacts to working directory (a temporary folder is given) + # - Exit zero to indicate successful task completetion + command: ['python', {$abs: 'examples/script.py'}] + schema: # schema for task.payload passed to command over stdin + type: object + properties: + buildUrl: {type: string} + required: + - buildUrl + expiration: 14 # artifact expiration in days + logLevel: debug + plugins: + disabled: + - interactive + - artifacts + - env + pollingInterval: 5 + queueBaseUrl: https://queue.taskcluster.net/v1 + reclaimOffset: 120 + temporaryFolder: /tmp/tc-worker/ + serverIp: 127.0.0.1 + serverPort: 8080 + tlsCertificiate: '' + tlsKey: '' + statelessDNSSecret: '' + statelessDNSDomain: 'localhost.local' # livelog won't work with this + maxLifeCycle: 3600 # 1 hour + minimumDiskSpace: 10000000 # 10 GB + minimumMemory: 1000000 # 1 GB diff --git a/examples/script.py b/examples/script.py new file mode 100755 index 00000000..f0cf6539 --- /dev/null +++ b/examples/script.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python +import sys, json + +payload = json.loads(sys.stdin.read()) + +print "Payload given:" +print payload