Github user aledsage commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/531#discussion_r25416073
--- Diff:
software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java
---
@@ -156,6 +157,34 @@ public void install() {
.add("ln -s `which riak-admin` " +
Urls.mergePaths(installBin, "riak-admin"))
.build();
}
+
+ private List<String> installPackageCloud() {
+ return ifExecutable0Else1("yum", installDebianBased(),
installRpmBased());
+ }
+
+ private ImmutableList<String> installDebianBased() {
+ ImmutableList.Builder<String> commands =
ImmutableList.<String>builder();
+ commands.add("curl
https://packagecloud.io/install/repositories/basho/riak/script.deb | sudo
bash");
+ commands.add("sudo apt-get install --assume-yes riak");
+ return commands.build();
+ }
+
+ private ImmutableList<String> installRpmBased() {
+ ImmutableList.Builder<String> commands =
ImmutableList.<String>builder();
+ commands.add("curl
https://packagecloud.io/install/repositories/basho/riak/script.rpm | sudo
bash");
+ commands.add("sudo yum install -y riak");
+ return commands.build();
+ }
+
+ private static ImmutableList<String> ifExecutable0Else1(String
command, List<String> ifTrue, List<String> otherwise) {
+ ImmutableList.Builder<String> commands =
ImmutableList.<String>builder();
--- End diff --
personal preference for a fluent API style when using a builder like this.
e.g.
return ImmutableList.<String>builder()
.add(String.format("if test -z `which %s`; then", command))
.addAll(ifTrue)
.add("else")
.addAll(otherwise)
.add("fi")
.build();
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---