You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2014/11/23 23:01:31 UTC
[50/50] [abbrv] jclouds git commit: JCLOUDS-776: Map chef cookbook
attribute files with Resource instead of Attribute
JCLOUDS-776: Map chef cookbook attribute files with Resource instead of Attribute
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/68f3bdc2
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/68f3bdc2
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/68f3bdc2
Branch: refs/heads/1.8.x
Commit: 68f3bdc264cde90772e3fc9c8551353dec7a1270
Parents: 494f35d
Author: akorompai <at...@gmail.com>
Authored: Sat Nov 15 12:58:01 2014 +0100
Committer: Ignasi Barrera <na...@apache.org>
Committed: Sun Nov 23 22:25:24 2014 +0100
----------------------------------------------------------------------
.../jclouds/chef/domain/CookbookVersion.java | 12 ++---
.../chef/internal/BaseChefApiLiveTest.java | 51 +++++++++++---------
2 files changed, 35 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/68f3bdc2/apis/chef/src/main/java/org/jclouds/chef/domain/CookbookVersion.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/domain/CookbookVersion.java b/apis/chef/src/main/java/org/jclouds/chef/domain/CookbookVersion.java
index df9bd82..01abb64 100644
--- a/apis/chef/src/main/java/org/jclouds/chef/domain/CookbookVersion.java
+++ b/apis/chef/src/main/java/org/jclouds/chef/domain/CookbookVersion.java
@@ -38,7 +38,7 @@ public class CookbookVersion {
public static class Builder {
private String cookbookName;
private ImmutableSet.Builder<Resource> definitions = ImmutableSet.builder();
- private ImmutableSet.Builder<Attribute> attributes = ImmutableSet.builder();
+ private ImmutableSet.Builder<Resource> attributes = ImmutableSet.builder();
private ImmutableSet.Builder<Resource> files = ImmutableSet.builder();
private Metadata metadata = Metadata.builder().build();
private ImmutableSet.Builder<Resource> providers = ImmutableSet.builder();
@@ -69,12 +69,12 @@ public class CookbookVersion {
return this;
}
- public Builder attribute(Attribute attribute) {
+ public Builder attribute(Resource attribute) {
this.attributes.add(checkNotNull(attribute, "attribute"));
return this;
}
- public Builder attributes(Iterable<Attribute> attributes) {
+ public Builder attributes(Iterable<Resource> attributes) {
this.attributes.addAll(checkNotNull(attributes, "attributes"));
return this;
}
@@ -168,7 +168,7 @@ public class CookbookVersion {
private final String name;
private final Set<Resource> definitions;
- private final Set<Attribute> attributes;
+ private final Set<Resource> attributes;
private final Set<Resource> files;
private final Metadata metadata;
private final Set<Resource> providers;
@@ -190,7 +190,7 @@ public class CookbookVersion {
@ConstructorProperties({ "name", "definitions", "attributes", "files", "metadata", "providers", "cookbook_name",
"resources", "templates", "libraries", "version", "recipes", "root_files" })
- protected CookbookVersion(String name, @Nullable Set<Resource> definitions, @Nullable Set<Attribute> attributes,
+ protected CookbookVersion(String name, @Nullable Set<Resource> definitions, @Nullable Set<Resource> attributes,
@Nullable Set<Resource> files, Metadata metadata, @Nullable Set<Resource> providers, String cookbookName,
@Nullable Set<Resource> resources, @Nullable Set<Resource> templates, @Nullable Set<Resource> libraries,
String version, @Nullable Set<Resource> recipes, @Nullable Set<Resource> rootFiles) {
@@ -217,7 +217,7 @@ public class CookbookVersion {
return definitions;
}
- public Set<Attribute> getAttributes() {
+ public Set<Resource> getAttributes() {
return attributes;
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/68f3bdc2/apis/chef/src/test/java/org/jclouds/chef/internal/BaseChefApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/internal/BaseChefApiLiveTest.java b/apis/chef/src/test/java/org/jclouds/chef/internal/BaseChefApiLiveTest.java
index a477be0..42a5cc2 100644
--- a/apis/chef/src/test/java/org/jclouds/chef/internal/BaseChefApiLiveTest.java
+++ b/apis/chef/src/test/java/org/jclouds/chef/internal/BaseChefApiLiveTest.java
@@ -30,6 +30,7 @@ import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
@@ -85,6 +86,30 @@ public abstract class BaseChefApiLiveTest<A extends ChefApi> extends BaseChefLiv
public void testCreateNewCookbook() throws Exception {
// Define the file you want in the cookbook
File file = new File(System.getProperty("user.dir"), "pom.xml");
+ FilePayload content = uploadAndGetFilePayload(file);
+
+ // Create the metadata of the cookbook
+ Metadata metadata = Metadata.builder() //
+ .name(PREFIX) //
+ .version("0.0.0") //
+ .description("Jclouds test uploaded cookbook") //
+ .maintainer("jclouds") //
+ .maintainerEmail("someone@jclouds.org") //
+ .license("Apache 2.0") //
+ .build();
+
+ // Create a new cookbook
+ CookbookVersion cookbook = CookbookVersion.builder(PREFIX, "0.0.0") //
+ .metadata(metadata) //
+ .rootFile(Resource.builder().fromPayload(content).build()) //
+ .attribute(Resource.builder().fromPayload(content).name("default.rb").build())
+ .build();
+
+ // upload the cookbook to the remote server
+ api.updateCookbook(PREFIX, "0.0.0", cookbook);
+ }
+
+ private FilePayload uploadAndGetFilePayload(File file) throws IOException {
FilePayload content = Payloads.newFilePayload(file);
content.getContentMetadata().setContentType("application/x-binary");
@@ -111,25 +136,7 @@ public abstract class BaseChefApiLiveTest<A extends ChefApi> extends BaseChefLiv
api.commitSandbox(site.getSandboxId(), false);
fail("Could not upload content");
}
-
- // Create the metadata of the cookbook
- Metadata metadata = Metadata.builder() //
- .name(PREFIX) //
- .version("0.0.0") //
- .description("Jclouds test uploaded cookbook") //
- .maintainer("jclouds") //
- .maintainerEmail("someone@jclouds.org") //
- .license("Apache 2.0") //
- .build();
-
- // Create a new cookbook
- CookbookVersion cookbook = CookbookVersion.builder(PREFIX, "0.0.0") //
- .metadata(metadata) //
- .rootFile(Resource.builder().fromPayload(content).build()) //
- .build();
-
- // upload the cookbook to the remote server
- api.updateCookbook(PREFIX, "0.0.0", cookbook);
+ return content;
}
public void testListCookbooks() throws Exception {
@@ -158,9 +165,9 @@ public abstract class BaseChefApiLiveTest<A extends ChefApi> extends BaseChefLiv
Iterable<? extends CookbookVersion> cookbooks = chefService.listCookbookVersions();
for (CookbookVersion cookbook : cookbooks) {
for (Resource resource : ImmutableList.<Resource> builder().addAll(cookbook.getDefinitions())
- .addAll(cookbook.getFiles()).addAll(cookbook.getLibraries()).addAll(cookbook.getSuppliers())
- .addAll(cookbook.getRecipes()).addAll(cookbook.getResources()).addAll(cookbook.getRootFiles())
- .addAll(cookbook.getTemplates()).build()) {
+ .addAll(cookbook.getFiles()).addAll(cookbook.getLibraries()).addAll(cookbook.getSuppliers())
+ .addAll(cookbook.getRecipes()).addAll(cookbook.getResources()).addAll(cookbook.getRootFiles())
+ .addAll(cookbook.getTemplates()).addAll(cookbook.getAttributes()).build()) {
InputStream stream = api.getResourceContents(resource);
assertNotNull(stream, "Resource contents are null for resource: " + resource.getName());