Skip to content

Commit

Permalink
Working CWL files
Browse files Browse the repository at this point in the history
Refs #4
  • Loading branch information
sverhoeven committed Feb 8, 2017
1 parent 0cd28f9 commit 921dcec
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 50 deletions.
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
# Using `./gradlew docker` to build image
FROM openjdk:jre-alpine
MAINTAINER Stefan Verhoeven <[email protected]>
COPY bin /app/bin
COPY lib /app/lib
WORKDIR /app
ENTRYPOINT ["/app/bin/xenon"]
CMD ["--help"]
COPY bin /usr/bin
COPY lib /usr/lib
CMD ["/usr/bin/xenon", "--help"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ xenon --adaptor ssh --json list --location localhost /etc
xenon --adaptor ssh --json upload --source /etc/passwd --location localhost --path /tmp/copy-of-passwd
```

To keep password or passphrase invisible in process list put the password in a text file (eg. 'password.txt') and then use '@password.txt' as argument.
For example:
```
xenon --username $USER --password @password.txt sftp --location localhost list $PWD/src
```

# Build

```
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/nl/esciencecenter/xenon/cli/CopyCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected void copy(Files files, CopyInput source, CopyInput target, Boolean rec
if (!target.path.startsWith("/") && !target.path.equals("-")) {
// Path is relative to working directory, make it absolute
RelativePath workingDirectory = new RelativePath(System.getProperty("user.dir"));
sourcePath = files.newPath(sourceFS, workingDirectory.resolve(target.path));
targetPath = files.newPath(targetFS, workingDirectory.resolve(target.path));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Subparser buildArgumentParser(Subparsers subparsers) {
.description("Download source file to local file");
subparser.addArgument("source").help("Local source path").required(true);
subparser.addArgument("target")
.type(Arguments.fileType().acceptSystemIn().verifyCanWriteParent())
.type(Arguments.fileType().acceptSystemIn())
.help("Target path, use '-' for stdout")
.required(true);
subparser.addArgument("--recursive").help("Copy directories recursively").action(Arguments.storeTrue());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/nl/esciencecenter/xenon/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void main(String[] args) throws Exception {
Main main = new Main();
ArgumentParser parser = main.buildArgumentParser();
Namespace res = parser.parseArgsOrFail(args);
LOGGER.warn(res.toString());
LOGGER.debug(res.toString());
ICommand subcommand = res.get("command");
Xenon xenon = XenonFactory.newXenon(buildXenonProperties(res));
subcommand.run(res, xenon);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/nl/esciencecenter/xenon/cli/UploadOutput.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package nl.esciencecenter.xenon.cli;

public class UploadOutput {
public CwlFile source;
public String source;
public String location;
public String path;

public UploadOutput(CopyInput source, CopyInput target) {
this.source = new CwlFile(source.path);
this.source = source.path;
location = target.location;
path = target.path;
}
Expand Down
69 changes: 55 additions & 14 deletions xenon-download.cwl
Original file line number Diff line number Diff line change
@@ -1,40 +1,81 @@
#!/usr/bin/env cwl-runner
# Native:
# xenon --format cwljson sftp --location localhost download $PWD/README.md copy-of-README.md
# Using cwl-runnner:
# ./xenon-download.cwl --certfile ~/.ssh/id_rsa --scheme sftp --location [email protected] --source $PWD/README.md --target copy-of-README.md
cwlVersion: v1.0
class: CommandLineTool
doc: Download file from remote storage
requirements:
hints:
- class: DockerRequirement
# xenon-cli Docker container needs to be manually build before
dockerImageId: nlesc/xenon-cli
baseCommand: xenon
arguments:
- --json
- download
- prefix: --format
valueFrom: cwljson
position: 0
- valueFrom: download
position: 3
inputs:
scheme:
type: string
inputBinding:
prefix: --scheme
position: -1
certfile:
type: File?
doc: Certificate file
inputBinding:
prefix: --certfile
position: -1
location:
position: 0
username:
type: string?
inputBinding:
position: 1
path:
prefix: --username
position: 0
password:
type: string?
doc: Password, watch out do not use on systems with untrusted users
inputBinding:
prefix: --password
position: 0
scheme:
type: string
doc: Scheme, eg. file, sftp, ftp
inputBinding:
position: 1
location:
type: string?
doc: List contents of path at location
inputBinding:
prefix: --location
position: 2
# TODO prop should be optional, atm is must be set
# prop:
# doc: Xenon adaptor properties
# type:
# type: array
# items: string
# inputBinding:
# prefix: --prop
# inputBinding:
# position: 2
overwrite:
type: boolean
inputBinding:
prefix: --overwrite
position: 4
ignore:
type: boolean
inputBinding:
prefix: --ignore
position: 4
source:
type: string
inputBinding:
position: 5
target:
type: string
inputBinding:
position: 3
position: 6
outputs:
target:
type: File
outputBinding:
glob: $(inputs.target)
# stdout: cwl.output.json
61 changes: 50 additions & 11 deletions xenon-ls.cwl
Original file line number Diff line number Diff line change
@@ -1,33 +1,72 @@
#!/usr/bin/env cwl-runner
# Native:
# xenon --format cwljson sftp --location localhost list $PWD/
# Using cwl-runnner:
# ./xenon-ls.cwl --scheme sftp --location [email protected] --path $PWD --certfile ~/.ssh/id_rsa
cwlVersion: v1.0
class: CommandLineTool
doc: List objects on remote storage
requirements:
hints:
- class: DockerRequirement
# xenon-cli Docker container needs to be manually build before
dockerImageId: nlesc/xenon-cli
baseCommand: xenon
arguments:
- --json
- list
- prefix: --format
valueFrom: cwljson
position: 0
- valueFrom: list
position: 3
inputs:
scheme:
type: string
inputBinding:
prefix: --scheme
position: -1
certfile:
type: File?
doc: Certificate file
inputBinding:
prefix: --certfile
position: -1
location:
position: 0
username:
type: string?
inputBinding:
prefix: --username
position: 0
password:
type: string?
doc: Password, watch out do not use on systems with untrusted users
inputBinding:
prefix: --password
position: 0
scheme:
type: string
doc: Scheme, eg. file, sftp, ftp
inputBinding:
position: 1
location:
type: string?
doc: List contents of path at location
inputBinding:
prefix: --location
position: 2
# TODO prop should be optional, atm is must be set
# prop:
# doc: Xenon adaptor properties
# type:
# type: array
# items: string
# inputBinding:
# prefix: --prop
# inputBinding:
# position: 2
recursive:
doc: List directories recursively
type: boolean?
inputBinding:
prefix: --recursive
position: 4
path:
type: string
doc: List contents of path at location
inputBinding:
position: 2
position: 5
outputs:
objects:
type:
Expand Down
71 changes: 56 additions & 15 deletions xenon-upload.cwl
Original file line number Diff line number Diff line change
@@ -1,37 +1,78 @@
#!/usr/bin/env cwl-runner
# Native:
# xenon --format cwljson sftp --location localhost upload README.md $PWD/copy-of-README.md
# Using cwl-runnner:
# ./xenon-upload.cwl --certfile ~/.ssh/id_rsa --scheme sftp --location [email protected] --source README.md --target $PWD/copy-of-README.md
cwlVersion: v1.0
class: CommandLineTool
doc: Upload file to remote storage
requirements:
hints:
- class: DockerRequirement
# xenon-cli Docker container needs to be manually build before
dockerImageId: nlesc/xenon-cli
baseCommand: xenon
arguments:
- --json
- upload
- prefix: --format
valueFrom: cwljson
position: 0
- valueFrom: upload
position: 3
inputs:
scheme:
type: string
inputBinding:
prefix: --scheme
position: -1
certfile:
type: File?
doc: Certificate file
inputBinding:
prefix: --certfile
position: -1
source:
type: File
position: 0
username:
type: string?
inputBinding:
prefix: --username
position: 0
password:
type: string?
doc: Password, watch out do not use on systems with untrusted users
inputBinding:
prefix: --password
position: 0
scheme:
type: string
doc: Scheme, eg. file, sftp, ftp
inputBinding:
position: 1
location:
type: string?
doc: List contents of path at location
inputBinding:
prefix: --location
position: 2
path:
# TODO prop should be optional, atm is must be set
# prop:
# doc: Xenon adaptor properties
# type:
# type: array
# items: string
# inputBinding:
# prefix: --prop
# inputBinding:
# position: 2
overwrite:
type: boolean
inputBinding:
prefix: --overwrite
position: 4
ignore:
type: boolean
inputBinding:
prefix: --ignore
position: 4
source:
type: File
inputBinding:
position: 5
target:
type: string
inputBinding:
position: 3
outputs:
path: File
position: 6
outputs: []
stdout: cwl.output.json

0 comments on commit 921dcec

Please sign in to comment.