Add -f FILE flag support for session and service commands
All 38+ implementations now support: - session -f FILE: Upload files to /tmp/ in session container - service -f FILE: Upload files to /tmp/ in service container - service --bootstrap-file FILE: Read bootstrap script from file
This commit is contained in:
parent
a5a4f23594
commit
c6813e5a18
40 changed files with 2506 additions and 329 deletions
44
un.groovy
44
un.groovy
|
|
@ -79,6 +79,7 @@ class Args {
|
|||
String servicePorts = null
|
||||
String serviceType = null
|
||||
String serviceBootstrap = null
|
||||
String serviceBootstrapFile = null
|
||||
String serviceInfo = null
|
||||
String serviceLogs = null
|
||||
String serviceTail = null
|
||||
|
|
@ -307,6 +308,21 @@ def cmdSession(args) {
|
|||
if (args.vcpu > 0) {
|
||||
json += ""","vcpu":${args.vcpu}"""
|
||||
}
|
||||
|
||||
// Add input files
|
||||
if (args.files) {
|
||||
def filesJson = args.files.collect { filepath ->
|
||||
def f = new File(filepath)
|
||||
if (!f.exists()) {
|
||||
System.err.println("${RED}Error: Input file not found: ${filepath}${RESET}")
|
||||
System.exit(1)
|
||||
}
|
||||
def content = f.bytes.encodeBase64().toString()
|
||||
return """{"filename":"${f.name}","content_base64":"${content}"}"""
|
||||
}.join(',')
|
||||
json += ""","input_files":[${filesJson}]"""
|
||||
}
|
||||
|
||||
json += '}'
|
||||
|
||||
println("${YELLOW}Creating session...${RESET}")
|
||||
|
|
@ -539,12 +555,37 @@ def cmdService(args) {
|
|||
def escaped = args.serviceBootstrap.replace('\\', '\\\\').replace('"', '\\"')
|
||||
json += ""","bootstrap":"${escaped}""""
|
||||
}
|
||||
if (args.serviceBootstrapFile) {
|
||||
def file = new File(args.serviceBootstrapFile)
|
||||
if (file.exists()) {
|
||||
def content = file.text.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n').replace('\r', '\\r').replace('\t', '\\t')
|
||||
json += ""","bootstrap_content":"${content}""""
|
||||
} else {
|
||||
System.err.println("${RED}Error: Bootstrap file not found: ${args.serviceBootstrapFile}${RESET}")
|
||||
System.exit(1)
|
||||
}
|
||||
}
|
||||
if (args.network) {
|
||||
json += ""","network":"${args.network}""""
|
||||
}
|
||||
if (args.vcpu > 0) {
|
||||
json += ""","vcpu":${args.vcpu}"""
|
||||
}
|
||||
|
||||
// Add input files
|
||||
if (args.files) {
|
||||
def filesJson = args.files.collect { filepath ->
|
||||
def f = new File(filepath)
|
||||
if (!f.exists()) {
|
||||
System.err.println("${RED}Error: Input file not found: ${filepath}${RESET}")
|
||||
System.exit(1)
|
||||
}
|
||||
def content = f.bytes.encodeBase64().toString()
|
||||
return """{"filename":"${f.name}","content_base64":"${content}"}"""
|
||||
}.join(',')
|
||||
json += ""","input_files":[${filesJson}]"""
|
||||
}
|
||||
|
||||
json += '}'
|
||||
|
||||
def output = apiRequest('/services', 'POST', json, publicKey, secretKey)
|
||||
|
|
@ -633,6 +674,9 @@ def parseArgs(argv) {
|
|||
case '--bootstrap':
|
||||
args.serviceBootstrap = argv[++i]
|
||||
break
|
||||
case '--bootstrap-file':
|
||||
args.serviceBootstrapFile = argv[++i]
|
||||
break
|
||||
case '--info':
|
||||
args.serviceInfo = argv[++i]
|
||||
break
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue