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(
|
assertEquals(
|
||||||
ComputeServiceUtils.execHttpResponse(request).render(OsFamily.UNIX),
|
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(
|
assertEquals(
|
||||||
ComputeServiceUtils.extractTargzIntoDirectory(request, "/stage/").render(OsFamily.UNIX),
|
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
|
* request headers to send
|
||||||
*/
|
*/
|
||||||
public PipeHttpResponseTo(Statement toExec, String method, URI endpoint, Multimap<String, String> headers) {
|
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>() {
|
Iterables.transform(headers.entries(), new Function<Entry<String, String>, String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.scriptbuilder.domain;
|
package org.jclouds.scriptbuilder.domain;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
@ -32,6 +32,8 @@ import com.google.common.collect.Multimap;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class SaveHttpResponseTo extends InterpretableStatement {
|
public class SaveHttpResponseTo extends InterpretableStatement {
|
||||||
|
static final String CURL = "curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param dir
|
* @param dir
|
||||||
|
@ -44,15 +46,17 @@ public class SaveHttpResponseTo extends InterpretableStatement {
|
||||||
* request headers to send
|
* request headers to send
|
||||||
*/
|
*/
|
||||||
public SaveHttpResponseTo(String dir, String file, String method, URI endpoint, Multimap<String, String> headers) {
|
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(' ')
|
super(String.format("({md} %s && {cd} %s && [ ! -f %s ] && %s -C - -X %s %s %s >%s)\n", dir, dir, file, CURL,
|
||||||
.join(Iterables.transform(headers.entries(), new Function<Entry<String, String>, String>() {
|
method, Joiner.on(' ').join(
|
||||||
|
Iterables.transform(headers.entries(), new Function<Map.Entry<String, String>, String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apply(Entry<String, String> from) {
|
public String apply(Map.Entry<String, String> from) {
|
||||||
return String.format("-H \"%s: %s\"", from.getKey(), from.getValue());
|
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() {
|
public void testPipeHttpResponseToBashUNIX() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
bash.render(OsFamily.UNIX),
|
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));
|
assertEquals(bash2.render(OsFamily.UNIX), bash.render(OsFamily.UNIX));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public class PipeHttpResponseToTest {
|
||||||
public void testPipeHttpResponseToUntarUNIX() {
|
public void testPipeHttpResponseToUntarUNIX() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
untar.render(OsFamily.UNIX),
|
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));
|
assertEquals(untar.render(OsFamily.UNIX), untar2.render(OsFamily.UNIX));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue