@VisibleForTesting void addArgValidation(StringBuilder switchClause, OsFamily family) { if (family.equals(OsFamily.WINDOWS)) { for (String value : valueToActions.keySet()) { switchClause.append("if not \"%").append(arg).append(String.format("\" == \"%s\" ", value)); } switchClause.append("(\r\n set EXCEPTION=bad argument: %").append(arg).append(" not in "); switchClause.append(Joiner.on(" ").join(valueToActions.keySet())); switchClause.append("\r\n goto abort\r\n)\r\n"); } }
@VisibleForTesting void addArgValidation(StringBuilder switchClause, OsFamily family) { if (family.equals(OsFamily.WINDOWS)) { for (String value : valueToActions.keySet()) { switchClause.append("if not \"%").append(arg).append(String.format("\" == \"%s\" ", value)); } switchClause.append("(\r\n set EXCEPTION=bad argument: %").append(arg).append(" not in "); switchClause.append(Joiner.on(" ").join(valueToActions.keySet())); switchClause.append("\r\n goto abort\r\n)\r\n"); } }
@VisibleForTesting void addArgValidation(StringBuilder switchClause, OsFamily family) { if (family.equals(OsFamily.WINDOWS)) { for (String value : valueToActions.keySet()) { switchClause.append("if not \"%").append(arg).append(String.format("\" == \"%s\" ", value)); } switchClause.append("(\r\n set EXCEPTION=bad argument: %").append(arg).append(" not in "); switchClause.append(Joiner.on(" ").join(valueToActions.keySet())); switchClause.append("\r\n goto abort\r\n)\r\n"); } }
@VisibleForTesting void addArgValidation(StringBuilder switchClause, OsFamily family) { if (family.equals(OsFamily.WINDOWS)) { for (String value : valueToActions.keySet()) { switchClause.append("if not \"%").append(arg).append(String.format("\" == \"%s\" ", value)); } switchClause.append("(\r\n set EXCEPTION=bad argument: %").append(arg).append(" not in "); switchClause.append(Joiner.on(" ").join(valueToActions.keySet())); switchClause.append("\r\n goto abort\r\n)\r\n"); } }
@VisibleForTesting void addArgValidation(StringBuilder switchClause, OsFamily family) { if (family.equals(OsFamily.WINDOWS)) { for (String value : valueToActions.keySet()) { switchClause.append("if not \"%").append(arg).append(String.format("\" == \"%s\" ", value)); } switchClause.append("(\r\n set EXCEPTION=bad argument: %").append(arg).append(" not in "); switchClause.append(Joiner.on(" ").join(valueToActions.keySet())); switchClause.append("\r\n goto abort\r\n)\r\n"); } }
@VisibleForTesting void addArgValidation(StringBuilder switchClause, OsFamily family) { if (family.equals(OsFamily.WINDOWS)) { for (String value : valueToActions.keySet()) { switchClause.append("if not \"%").append(arg).append(String.format("\" == \"%s\" ", value)); } switchClause.append("(\r\n set EXCEPTION=bad argument: %").append(arg).append(" not in "); switchClause.append(Joiner.on(" ").join(valueToActions.keySet())); switchClause.append("\r\n goto abort\r\n)\r\n"); } }
/** * Transforms the recipe into the series of statements that must be ran on the * server (after chef is installed). * * @return */ @Override public String render(OsFamily family) { if (family.equals(OsFamily.UNIX)) { // store the json file in tmp String fileName = "/tmp/" + this.fileName + ".json"; Statement storeJSonFile = Statements.createOrOverwriteFile(fileName, Collections.singleton(toJSON())); Statement runRecipe = null; runRecipe = Statements.exec("sudo -i chef-solo -j " + fileName + (url != null ? " -r " + url : "")); return Statements.newStatementList(storeJSonFile, runRecipe).render( family); } else { throw new UnsupportedOperationException(); } }
/** * Transforms the recipe into the series of statements that must be ran on the * server (after chef is installed). * * @return */ @Override public String render(OsFamily family) { if (family.equals(OsFamily.UNIX)) { // store the json file in tmp String fileName = "/tmp/" + this.fileName + ".json"; Statement storeJSonFile = Statements.createOrOverwriteFile(fileName, Collections.singleton(toJSON())); Statement runRecipe = null; runRecipe = Statements.exec("sudo -i chef-solo -j " + fileName + (url != null ? " -r " + url : "")); return Statements.newStatementList(storeJSonFile, runRecipe).render( family); } else { throw new UnsupportedOperationException(); } }