-
Notifications
You must be signed in to change notification settings - Fork 0
/
getDockerConfig.cwl
67 lines (58 loc) · 2 KB
/
getDockerConfig.cwl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env cwl-runner
#
# Since the Synapse Docker registry has the same password as Synapse
# Extract the Synapse credentials and format into Docker config
#
cwlVersion: v1.0
class: CommandLineTool
baseCommand: python
inputs:
- id: synapseConfig
type: File
arguments:
- valueFrom: getDockerConfig.py
- valueFrom: $(inputs.synapseConfig.path)
prefix: -c
- valueFrom: results.json
prefix: -r
requirements:
- class: InlineJavascriptRequirement
- class: InitialWorkDirRequirement
listing:
- entryname: getDockerConfig.py
entry: |
#!/usr/bin/env python
import synapseclient
import argparse
import json
import base64
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--results", required=True, help="validation results")
parser.add_argument("-c", "--synapseConfig", required=True, help="credentials file")
args = parser.parse_args()
#Must read in credentials (username and password)
config = synapseclient.Synapse().getConfigFile(configPath=args.synapseConfig)
authen = dict(config.items("authentication"))
if authen.get("username") is None and authen.get("password") is None:
raise Exception('Config file must have username and password')
dockerAuth = base64.encodestring("%s:%s" % (authen['username'],authen['password']))
result = {'dockerAuth':dockerAuth,'dockerRegistry':'https://docker.synapse.org'}
with open(args.results, 'w') as o:
o.write(json.dumps(result))
outputs:
- id: results
type: File
outputBinding:
glob: results.json
- id: dockerRegistry
type: string
outputBinding:
glob: results.json
loadContents: true
outputEval: $(JSON.parse(self[0].contents)['dockerRegistry'])
- id: dockerAuth
type: string
outputBinding:
glob: results.json
loadContents: true
outputEval: $(JSON.parse(self[0].contents)['dockerAuth'])