mirror of https://github.com/apache/jclouds.git
Issue 615:enhance curl arg defaults
This commit is contained in:
parent
521d3c3289
commit
5f00612929
|
@ -51,7 +51,7 @@ public class ComputeServiceUtilsTest {
|
|||
|
||||
assertEquals(
|
||||
ComputeServiceUtils.execHttpResponse(request).render(OsFamily.UNIX),
|
||||
"curl -X GET -s --retry 20 -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(bash)\n");
|
||||
"curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(bash)\n");
|
||||
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class ComputeServiceUtilsTest {
|
|||
|
||||
assertEquals(
|
||||
ComputeServiceUtils.extractTargzIntoDirectory(request, "/stage/").render(OsFamily.UNIX),
|
||||
"curl -X GET -s --retry 20 -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(mkdir -p /stage/ &&cd /stage/ &&tar -xpzf -)\n");
|
||||
"curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(mkdir -p /stage/ &&cd /stage/ &&tar -xpzf -)\n");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class PipeHttpResponseTo extends InterpretableStatement {
|
|||
* request headers to send
|
||||
*/
|
||||
public PipeHttpResponseTo(Statement toExec, String method, URI endpoint, Multimap<String, String> headers) {
|
||||
super(String.format("curl -X %s -s --retry 20 %s %s |(%s)\n", method, Joiner.on(' ').join(
|
||||
super(String.format("%s -X %s %s %s |(%s)\n", SaveHttpResponseTo.CURL, method, Joiner.on(' ').join(
|
||||
Iterables.transform(headers.entries(), new Function<Entry<String, String>, String>() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.jclouds.scriptbuilder.domain;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
|
@ -32,6 +32,8 @@ import com.google.common.collect.Multimap;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
public class SaveHttpResponseTo extends InterpretableStatement {
|
||||
static final String CURL = "curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dir
|
||||
|
@ -44,15 +46,17 @@ public class SaveHttpResponseTo extends InterpretableStatement {
|
|||
* request headers to send
|
||||
*/
|
||||
public SaveHttpResponseTo(String dir, String file, String method, URI endpoint, Multimap<String, String> headers) {
|
||||
super(String.format("({md} %s &&{cd} %s &&curl -X %s -s --retry 20 %s %s >%s\n", dir, dir, method, Joiner.on(' ')
|
||||
.join(Iterables.transform(headers.entries(), new Function<Entry<String, String>, String>() {
|
||||
super(String.format("({md} %s && {cd} %s && [ ! -f %s ] && %s -C - -X %s %s %s >%s)\n", dir, dir, file, CURL,
|
||||
method, Joiner.on(' ').join(
|
||||
Iterables.transform(headers.entries(), new Function<Map.Entry<String, String>, String>() {
|
||||
|
||||
@Override
|
||||
public String apply(Entry<String, String> from) {
|
||||
return String.format("-H \"%s: %s\"", from.getKey(), from.getValue());
|
||||
}
|
||||
@Override
|
||||
public String apply(Map.Entry<String, String> from) {
|
||||
return String.format("-H \"%s: %s\"", from.getKey(), from.getValue());
|
||||
}
|
||||
|
||||
})), endpoint.toASCIIString(), file));
|
||||
|
||||
})), endpoint.toASCIIString(), file));
|
||||
}
|
||||
|
||||
}
|
|
@ -44,7 +44,7 @@ public class PipeHttpResponseToTest {
|
|||
public void testPipeHttpResponseToBashUNIX() {
|
||||
assertEquals(
|
||||
bash.render(OsFamily.UNIX),
|
||||
"curl -X GET -s --retry 20 -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(bash)\n");
|
||||
"curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(bash)\n");
|
||||
assertEquals(bash2.render(OsFamily.UNIX), bash.render(OsFamily.UNIX));
|
||||
}
|
||||
|
||||
|
@ -59,15 +59,15 @@ public class PipeHttpResponseToTest {
|
|||
"adriancolehappy.s3.amazonaws.com", "Date", "Sun, 12 Sep 2010 08:25:19 GMT", "Authorization",
|
||||
"AWS 0ASHDJAS82:JASHFDA="));
|
||||
|
||||
PipeHttpResponseTo untar2 = new PipeHttpResponseToTarxpzfIntoDirectory( "GET", URI
|
||||
PipeHttpResponseTo untar2 = new PipeHttpResponseToTarxpzfIntoDirectory("GET", URI
|
||||
.create("https://adriancolehappy.s3.amazonaws.com/java/install"), ImmutableMultimap.of("Host",
|
||||
"adriancolehappy.s3.amazonaws.com", "Date", "Sun, 12 Sep 2010 08:25:19 GMT", "Authorization",
|
||||
"AWS 0ASHDJAS82:JASHFDA="),"{root}stage{fs}");
|
||||
"AWS 0ASHDJAS82:JASHFDA="), "{root}stage{fs}");
|
||||
|
||||
public void testPipeHttpResponseToUntarUNIX() {
|
||||
assertEquals(
|
||||
untar.render(OsFamily.UNIX),
|
||||
"curl -X GET -s --retry 20 -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(mkdir -p /stage/ &&cd /stage/ &&tar -xpzf -)\n");
|
||||
"curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(mkdir -p /stage/ &&cd /stage/ &&tar -xpzf -)\n");
|
||||
assertEquals(untar.render(OsFamily.UNIX), untar2.render(OsFamily.UNIX));
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue