protected ChefSolo(Optional<String> fileCachePath, Optional<String> rolePath, Optional<String> databagPath, Optional<ImmutableList<String>> cookbookPath, Optional<String> cookbooksArchiveLocation, Optional<String> jsonAttributes, Optional<String> group, Optional<Integer> interval, Optional<String> logLevel, Optional<String> logFile, Optional<String> nodeName, Optional<Integer> splay, Optional<String> user, Optional<List<Role>> roles, Optional<List<DataBag>> databags, Optional<RunList> runlist, Optional<String> chefVersion) { this.fileCachePath = checkNotNull(fileCachePath, "fileCachePath must be set").or(DEFAULT_SOLO_PATH); this.rolePath = checkNotNull(rolePath, "rolePath must be set").or(this.fileCachePath + "/roles"); this.databagPath = checkNotNull(databagPath, "databagPath must be set").or(this.fileCachePath + "/data_bags"); this.cookbooksArchiveLocation = checkNotNull(cookbooksArchiveLocation, "cookbooksArchiveLocation must be set"); this.jsonAttributes = checkNotNull(jsonAttributes, "jsonAttributes must be set"); this.group = checkNotNull(group, "group must be set"); this.interval = checkNotNull(interval, "interval must be set"); this.logLevel = checkNotNull(logLevel, "logLevel must be set"); this.logFile = checkNotNull(logFile, "logFile must be set"); this.nodeName = checkNotNull(nodeName, "nodeName must be set"); this.splay = checkNotNull(splay, "splay must be set"); this.user = checkNotNull(user, "user must be set"); this.roles = checkNotNull(roles, "roles must be set"); this.databags = checkNotNull(databags, "databags must be set"); this.runlist = checkNotNull(runlist, "runlist must be set").or(RunList.builder().build()); this.user = checkNotNull(user, "chefVersion must be set"); if (!checkNotNull(cookbookPath, "cookbookPath must be set").isPresent() || cookbookPath.get().isEmpty()) { this.cookbookPath = ImmutableList.<String> of(this.fileCachePath + "/cookbooks"); } else { this.cookbookPath = ImmutableList.<String> copyOf(cookbookPath.get()); } this.installChefGems = InstallChefGems.builder().version(chefVersion.orNull()).build(); }
protected ChefSolo(Optional<String> fileCachePath, Optional<String> rolePath, Optional<String> databagPath, Optional<ImmutableList<String>> cookbookPath, Optional<String> cookbooksArchiveLocation, Optional<String> jsonAttributes, Optional<String> group, Optional<Integer> interval, Optional<String> logLevel, Optional<String> logFile, Optional<String> nodeName, Optional<Integer> splay, Optional<String> user, Optional<List<Role>> roles, Optional<List<DataBag>> databags, Optional<RunList> runlist) { this.fileCachePath = checkNotNull(fileCachePath, "fileCachePath must be set").or(DEFAULT_SOLO_PATH); this.rolePath = checkNotNull(rolePath, "rolePath must be set").or(this.fileCachePath + "/roles"); this.databagPath = checkNotNull(databagPath, "databagPath must be set").or(this.fileCachePath + "/data_bags"); this.cookbooksArchiveLocation = checkNotNull(cookbooksArchiveLocation, "cookbooksArchiveLocation must be set"); this.jsonAttributes = checkNotNull(jsonAttributes, "jsonAttributes must be set"); this.group = checkNotNull(group, "group must be set"); this.interval = checkNotNull(interval, "interval must be set"); this.logLevel = checkNotNull(logLevel, "logLevel must be set"); this.logFile = checkNotNull(logFile, "logFile must be set"); this.nodeName = checkNotNull(nodeName, "nodeName must be set"); this.splay = checkNotNull(splay, "splay must be set"); this.user = checkNotNull(user, "user must be set"); this.roles = checkNotNull(roles, "roles must be set"); this.databags = checkNotNull(databags, "databags must be set"); this.runlist = checkNotNull(runlist, "runlist must be set").or(RunList.builder().build()); this.user = checkNotNull(user, "user must be set"); if (!checkNotNull(cookbookPath, "cookbookPath must be set").isPresent() || cookbookPath.get().isEmpty()) { this.cookbookPath = ImmutableList.<String> of(this.fileCachePath + "/cookbooks"); } else { this.cookbookPath = ImmutableList.<String> copyOf(cookbookPath.get()); } }
protected ChefSolo(Optional<String> fileCachePath, Optional<String> rolePath, Optional<String> databagPath, Optional<ImmutableList<String>> cookbookPath, Optional<String> cookbooksArchiveLocation, Optional<String> jsonAttributes, Optional<String> group, Optional<Integer> interval, Optional<String> logLevel, Optional<String> logFile, Optional<String> nodeName, Optional<Integer> splay, Optional<String> user, Optional<List<Role>> roles, Optional<List<DataBag>> databags, Optional<RunList> runlist) { this.fileCachePath = checkNotNull(fileCachePath, "fileCachePath must be set").or(DEFAULT_SOLO_PATH); this.rolePath = checkNotNull(rolePath, "rolePath must be set").or(this.fileCachePath + "/roles"); this.databagPath = checkNotNull(databagPath, "databagPath must be set").or(this.fileCachePath + "/data_bags"); this.cookbooksArchiveLocation = checkNotNull(cookbooksArchiveLocation, "cookbooksArchiveLocation must be set"); this.jsonAttributes = checkNotNull(jsonAttributes, "jsonAttributes must be set"); this.group = checkNotNull(group, "group must be set"); this.interval = checkNotNull(interval, "interval must be set"); this.logLevel = checkNotNull(logLevel, "logLevel must be set"); this.logFile = checkNotNull(logFile, "logFile must be set"); this.nodeName = checkNotNull(nodeName, "nodeName must be set"); this.splay = checkNotNull(splay, "splay must be set"); this.user = checkNotNull(user, "user must be set"); this.roles = checkNotNull(roles, "roles must be set"); this.databags = checkNotNull(databags, "databags must be set"); this.runlist = checkNotNull(runlist, "runlist must be set").or(RunList.builder().build()); this.user = checkNotNull(user, "user must be set"); if (!checkNotNull(cookbookPath, "cookbookPath must be set").isPresent() || cookbookPath.get().isEmpty()) { this.cookbookPath = ImmutableList.<String> of(this.fileCachePath + "/cookbooks"); } else { this.cookbookPath = ImmutableList.<String> copyOf(cookbookPath.get()); } }
protected ChefSolo(Optional<String> fileCachePath, Optional<String> rolePath, Optional<String> databagPath, Optional<ImmutableList<String>> cookbookPath, Optional<String> cookbooksArchiveLocation, Optional<String> jsonAttributes, Optional<String> group, Optional<Integer> interval, Optional<String> logLevel, Optional<String> logFile, Optional<String> nodeName, Optional<Integer> splay, Optional<String> user, Optional<List<Role>> roles, Optional<List<DataBag>> databags, Optional<RunList> runlist) { this.fileCachePath = checkNotNull(fileCachePath, "fileCachePath must be set").or(DEFAULT_SOLO_PATH); this.rolePath = checkNotNull(rolePath, "rolePath must be set").or(this.fileCachePath + "/roles"); this.databagPath = checkNotNull(databagPath, "databagPath must be set").or(this.fileCachePath + "/data_bags"); this.cookbooksArchiveLocation = checkNotNull(cookbooksArchiveLocation, "cookbooksArchiveLocation must be set"); this.jsonAttributes = checkNotNull(jsonAttributes, "jsonAttributes must be set"); this.group = checkNotNull(group, "group must be set"); this.interval = checkNotNull(interval, "interval must be set"); this.logLevel = checkNotNull(logLevel, "logLevel must be set"); this.logFile = checkNotNull(logFile, "logFile must be set"); this.nodeName = checkNotNull(nodeName, "nodeName must be set"); this.splay = checkNotNull(splay, "splay must be set"); this.user = checkNotNull(user, "user must be set"); this.roles = checkNotNull(roles, "roles must be set"); this.databags = checkNotNull(databags, "databags must be set"); this.runlist = checkNotNull(runlist, "runlist must be set").or(RunList.builder().build()); this.user = checkNotNull(user, "user must be set"); if (!checkNotNull(cookbookPath, "cookbookPath must be set").isPresent() || cookbookPath.get().isEmpty()) { this.cookbookPath = ImmutableList.<String> of(this.fileCachePath + "/cookbooks"); } else { this.cookbookPath = ImmutableList.<String> copyOf(cookbookPath.get()); } }
protected ChefSolo(Optional<String> fileCachePath, Optional<String> rolePath, Optional<String> databagPath, Optional<ImmutableList<String>> cookbookPath, Optional<String> cookbooksArchiveLocation, Optional<String> jsonAttributes, Optional<String> group, Optional<Integer> interval, Optional<String> logLevel, Optional<String> logFile, Optional<String> nodeName, Optional<Integer> splay, Optional<String> user, Optional<List<Role>> roles, Optional<List<DataBag>> databags, Optional<RunList> runlist) { this.fileCachePath = checkNotNull(fileCachePath, "fileCachePath must be set").or(DEFAULT_SOLO_PATH); this.rolePath = checkNotNull(rolePath, "rolePath must be set").or(this.fileCachePath + "/roles"); this.databagPath = checkNotNull(databagPath, "databagPath must be set").or(this.fileCachePath + "/data_bags"); this.cookbooksArchiveLocation = checkNotNull(cookbooksArchiveLocation, "cookbooksArchiveLocation must be set"); this.jsonAttributes = checkNotNull(jsonAttributes, "jsonAttributes must be set"); this.group = checkNotNull(group, "group must be set"); this.interval = checkNotNull(interval, "interval must be set"); this.logLevel = checkNotNull(logLevel, "logLevel must be set"); this.logFile = checkNotNull(logFile, "logFile must be set"); this.nodeName = checkNotNull(nodeName, "nodeName must be set"); this.splay = checkNotNull(splay, "splay must be set"); this.user = checkNotNull(user, "user must be set"); this.roles = checkNotNull(roles, "roles must be set"); this.databags = checkNotNull(databags, "databags must be set"); this.runlist = checkNotNull(runlist, "runlist must be set").or(RunList.builder().build()); this.user = checkNotNull(user, "user must be set"); if (!checkNotNull(cookbookPath, "cookbookPath must be set").isPresent() || cookbookPath.get().isEmpty()) { this.cookbookPath = ImmutableList.<String> of(this.fileCachePath + "/cookbooks"); } else { this.cookbookPath = ImmutableList.<String> copyOf(cookbookPath.get()); } }
protected ChefSolo(Optional<String> fileCachePath, Optional<String> rolePath, Optional<String> databagPath, Optional<ImmutableList<String>> cookbookPath, Optional<String> cookbooksArchiveLocation, Optional<String> jsonAttributes, Optional<String> group, Optional<Integer> interval, Optional<String> logLevel, Optional<String> logFile, Optional<String> nodeName, Optional<Integer> splay, Optional<String> user, Optional<List<Role>> roles, Optional<List<DataBag>> databags, Optional<RunList> runlist, Optional<String> chefVersion) { this.fileCachePath = checkNotNull(fileCachePath, "fileCachePath must be set").or(DEFAULT_SOLO_PATH); this.rolePath = checkNotNull(rolePath, "rolePath must be set").or(this.fileCachePath + "/roles"); this.databagPath = checkNotNull(databagPath, "databagPath must be set").or(this.fileCachePath + "/data_bags"); this.cookbooksArchiveLocation = checkNotNull(cookbooksArchiveLocation, "cookbooksArchiveLocation must be set"); this.jsonAttributes = checkNotNull(jsonAttributes, "jsonAttributes must be set"); this.group = checkNotNull(group, "group must be set"); this.interval = checkNotNull(interval, "interval must be set"); this.logLevel = checkNotNull(logLevel, "logLevel must be set"); this.logFile = checkNotNull(logFile, "logFile must be set"); this.nodeName = checkNotNull(nodeName, "nodeName must be set"); this.splay = checkNotNull(splay, "splay must be set"); this.user = checkNotNull(user, "user must be set"); this.roles = checkNotNull(roles, "roles must be set"); this.databags = checkNotNull(databags, "databags must be set"); this.runlist = checkNotNull(runlist, "runlist must be set").or(RunList.builder().build()); this.user = checkNotNull(user, "chefVersion must be set"); if (!checkNotNull(cookbookPath, "cookbookPath must be set").isPresent() || cookbookPath.get().isEmpty()) { this.cookbookPath = ImmutableList.<String> of(this.fileCachePath + "/cookbooks"); } else { this.cookbookPath = ImmutableList.<String> copyOf(cookbookPath.get()); } this.installChefGems = InstallChefGems.builder().version(chefVersion.orNull()).build(); }
public void testCreateRolesIfNecessaryWithMultipleRoleAndCustomPath() { ImmutableList.Builder<Statement> statements = ImmutableList.builder(); Role roleFoo = Role.builder().name("foo").runlist(RunList.builder().recipe("foo").build()).build(); Role roleBar = Role.builder().name("bar").runlist(RunList.builder().recipe("bar").build()).build(); ChefSolo solo = ChefSolo.builder().rolePath("/tmp/roles").defineRole(roleFoo).defineRole(roleBar).build(); solo.createRolesIfNecessary(statements); ImmutableList<Statement> statementList = statements.build(); Statement expectedFoo = createOrOverwriteFile("/tmp/roles/" + roleFoo.getName() + ".json", ImmutableSet.of(roleFoo.toJsonString())); Statement expectedBar = createOrOverwriteFile("/tmp/roles/" + roleBar.getName() + ".json", ImmutableSet.of(roleBar.toJsonString())); assertEquals(statementList.size(), 3); assertEquals(statementList.get(0), exec("{md} /tmp/roles")); assertEquals(statementList.get(1).render(OsFamily.UNIX), expectedFoo.render(OsFamily.UNIX)); assertEquals(statementList.get(2).render(OsFamily.UNIX), expectedBar.render(OsFamily.UNIX)); }
public void testToStringEmptyRunlist() { assertEquals(RunList.builder().build().toString(), "[]"); }
public static Builder builder() { return new Builder(); }
public static Builder builder() { return new Builder(); }
public static Builder builder() { return new Builder(); }
public void testCreateRolesIfNecessaryWithMultipleRoleAndCustomPath() { ImmutableList.Builder<Statement> statements = ImmutableList.builder(); Role roleFoo = Role.builder().name("foo").runlist(RunList.builder().recipe("foo").build()).build(); Role roleBar = Role.builder().name("bar").runlist(RunList.builder().recipe("bar").build()).build(); ChefSolo solo = ChefSolo.builder().rolePath("/tmp/roles").defineRole(roleFoo).defineRole(roleBar).build(); solo.createRolesIfNecessary(statements); ImmutableList<Statement> statementList = statements.build(); Statement expectedFoo = createOrOverwriteFile("/tmp/roles/" + roleFoo.getName() + ".json", ImmutableSet.of(roleFoo.toJsonString())); Statement expectedBar = createOrOverwriteFile("/tmp/roles/" + roleBar.getName() + ".json", ImmutableSet.of(roleBar.toJsonString())); assertEquals(statementList.size(), 3); assertEquals(statementList.get(0), exec("{md} /tmp/roles")); assertEquals(statementList.get(1).render(OsFamily.UNIX), expectedFoo.render(OsFamily.UNIX)); assertEquals(statementList.get(2).render(OsFamily.UNIX), expectedBar.render(OsFamily.UNIX)); }
public static Builder builder() { return new Builder(); }
public static Builder builder() { return new Builder(); }
public void testToStringEmptyRunlist() { assertEquals(RunList.builder().build().toString(), "[]"); }