Skip to content
This repository was archived by the owner on Feb 27, 2020. It is now read-only.
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
8 changes: 4 additions & 4 deletions engines/script/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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.`,
},
Expand Down Expand Up @@ -53,7 +53,7 @@ var configSchema = schematypes.Object{
},
},
Required: []string{
"script",
"command",
"schema",
"expiration",
},
Expand Down
2 changes: 1 addition & 1 deletion engines/script/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion engines/script/sandboxbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
52 changes: 52 additions & 0 deletions examples/script-config.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions examples/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python
import sys, json

payload = json.loads(sys.stdin.read())

print "Payload given:"
print payload