@Test(expectedExceptions = IllegalStateException.class) public void testMustHaveValidatorName() { Optional<PrivateKey> validatorCredential = Optional.of(createMock(PrivateKey.class)); GroupToBootScript fn = new GroupToBootScript(Suppliers.ofInstance(URI.create("http: CacheLoader.from(Functions.forMap(ImmutableMap.of("foo", BootstrapConfig.builder().build()))), installChefOmnibus, Optional.<String> absent(), validatorCredential); fn.apply("foo", null); }
public Statement apply(String group, @Nullable String nodeName) { BootstrapConfig config = null; try { config = bootstrapConfigForGroup.load(checkNotNull(group, "group")); } catch (Exception ex) { throw Throwables.propagate(ex); } String chefConfigDir = "{root}etc{fs}chef"; String chefBootFile = chefConfigDir + "{fs}first-boot.json"; ImmutableList.Builder<Statement> statements = ImmutableList.builder(); statements.add(new ExitInsteadOfReturn(installChef)); statements.add(exec("{md} " + chefConfigDir)); if (config.getSslCAFile() != null) { statements.add(createOrOverwriteFile(chefConfigDir + "{fs}chef-server.crt", Splitter.on(newLinePattern).split(config.getSslCAFile()))); } statements.add(createClientRbFile(chefConfigDir + "{fs}client.rb", group, nodeName, config)); statements.add(createOrOverwriteFile(chefConfigDir + "{fs}validation.pem", Splitter.on(newLinePattern).split(Pems.pem(validatorCredential.get())))); statements.add(createAttributesFile(chefBootFile, config)); statements.add(exec("chef-client -j " + chefBootFile)); return new StatementList(statements.build()); }
GroupToBootScript { public Statement apply(String group, @Nullable String nodeName) { BootstrapConfig config = null; try { config = bootstrapConfigForGroup.load(checkNotNull(group, "group")); } catch (Exception ex) { throw Throwables.propagate(ex); } String chefConfigDir = "{root}etc{fs}chef"; String chefBootFile = chefConfigDir + "{fs}first-boot.json"; ImmutableList.Builder<Statement> statements = ImmutableList.builder(); statements.add(new ExitInsteadOfReturn(installChef)); statements.add(exec("{md} " + chefConfigDir)); if (config.getSslCAFile() != null) { statements.add(createOrOverwriteFile(chefConfigDir + "{fs}chef-server.crt", Splitter.on(newLinePattern).split(config.getSslCAFile()))); } statements.add(createClientRbFile(chefConfigDir + "{fs}client.rb", group, nodeName, config)); statements.add(createOrOverwriteFile(chefConfigDir + "{fs}validation.pem", Splitter.on(newLinePattern).split(Pems.pem(validatorCredential.get())))); statements.add(createAttributesFile(chefBootFile, config)); statements.add(exec("chef-client -j " + chefBootFile)); return new StatementList(statements.build()); } }
GroupToBootScript { public Statement apply(String group, @Nullable String nodeName) { BootstrapConfig config = null; try { config = bootstrapConfigForGroup.load(checkNotNull(group, "group")); } catch (Exception ex) { throw Throwables.propagate(ex); } String chefConfigDir = "{root}etc{fs}chef"; String chefBootFile = chefConfigDir + "{fs}first-boot.json"; ImmutableList.Builder<Statement> statements = ImmutableList.builder(); statements.add(new ExitInsteadOfReturn(installChef)); statements.add(exec("{md} " + chefConfigDir)); if (config.getSslCAFile() != null) { statements.add(createOrOverwriteFile(chefConfigDir + "{fs}chef-server.crt", Splitter.on(newLinePattern).split(config.getSslCAFile()))); } statements.add(createClientRbFile(chefConfigDir + "{fs}client.rb", group, nodeName, config)); statements.add(createOrOverwriteFile(chefConfigDir + "{fs}validation.pem", Splitter.on(newLinePattern).split(Pems.pem(validatorCredential.get())))); statements.add(createAttributesFile(chefBootFile, config)); statements.add(exec("chef-client -j " + chefBootFile)); return new StatementList(statements.build()); } @Inject  GroupToBootScript(@Provider Supplier<URI> endpoint, CacheLoader<String, BootstrapConfig> bootstrapConfigForGroup,
         @InstallChef Statement installChef, @Validator Optional<String> validatorName,
         @Validator Optional<PrivateKey> validatorCredential); }
GroupToBootScript { public Statement apply(String group, @Nullable String nodeName) { BootstrapConfig config = null; try { config = bootstrapConfigForGroup.load(checkNotNull(group, "group")); } catch (Exception ex) { throw Throwables.propagate(ex); } String chefConfigDir = "{root}etc{fs}chef"; String chefBootFile = chefConfigDir + "{fs}first-boot.json"; ImmutableList.Builder<Statement> statements = ImmutableList.builder(); statements.add(new ExitInsteadOfReturn(installChef)); statements.add(exec("{md} " + chefConfigDir)); if (config.getSslCAFile() != null) { statements.add(createOrOverwriteFile(chefConfigDir + "{fs}chef-server.crt", Splitter.on(newLinePattern).split(config.getSslCAFile()))); } statements.add(createClientRbFile(chefConfigDir + "{fs}client.rb", group, nodeName, config)); statements.add(createOrOverwriteFile(chefConfigDir + "{fs}validation.pem", Splitter.on(newLinePattern).split(Pems.pem(validatorCredential.get())))); statements.add(createAttributesFile(chefBootFile, config)); statements.add(exec("chef-client -j " + chefBootFile)); return new StatementList(statements.build()); } @Inject  GroupToBootScript(@Provider Supplier<URI> endpoint, CacheLoader<String, BootstrapConfig> bootstrapConfigForGroup,
         @InstallChef Statement installChef, @Validator Optional<String> validatorName,
         @Validator Optional<PrivateKey> validatorCredential); Statement apply(String group, @Nullable String nodeName); }
GroupToBootScript { public Statement apply(String group, @Nullable String nodeName) { BootstrapConfig config = null; try { config = bootstrapConfigForGroup.load(checkNotNull(group, "group")); } catch (Exception ex) { throw Throwables.propagate(ex); } String chefConfigDir = "{root}etc{fs}chef"; String chefBootFile = chefConfigDir + "{fs}first-boot.json"; ImmutableList.Builder<Statement> statements = ImmutableList.builder(); statements.add(new ExitInsteadOfReturn(installChef)); statements.add(exec("{md} " + chefConfigDir)); if (config.getSslCAFile() != null) { statements.add(createOrOverwriteFile(chefConfigDir + "{fs}chef-server.crt", Splitter.on(newLinePattern).split(config.getSslCAFile()))); } statements.add(createClientRbFile(chefConfigDir + "{fs}client.rb", group, nodeName, config)); statements.add(createOrOverwriteFile(chefConfigDir + "{fs}validation.pem", Splitter.on(newLinePattern).split(Pems.pem(validatorCredential.get())))); statements.add(createAttributesFile(chefBootFile, config)); statements.add(exec("chef-client -j " + chefBootFile)); return new StatementList(statements.build()); } @Inject  GroupToBootScript(@Provider Supplier<URI> endpoint, CacheLoader<String, BootstrapConfig> bootstrapConfigForGroup,
         @InstallChef Statement installChef, @Validator Optional<String> validatorName,
         @Validator Optional<PrivateKey> validatorCredential); Statement apply(String group, @Nullable String nodeName);  }