dasahcc commented on a change in pull request #675: Add REST API for Cluster Creation with CloudConfig URL: https://github.com/apache/helix/pull/675#discussion_r363896739
########## File path: helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java ########## @@ -132,18 +133,42 @@ public Response getClusterInfo(@PathParam("clusterId") String clusterId) { @PUT @Path("{clusterId}") public Response createCluster(@PathParam("clusterId") String clusterId, - @DefaultValue("false") @QueryParam("recreate") String recreate) { + @DefaultValue("false") @QueryParam("recreate") String recreate, + @DefaultValue("false") @QueryParam("addCloudConfig") String addCloudConfig, + String content) { + boolean recreateIfExists = Boolean.valueOf(recreate); + boolean cloudConfigIncluded = Boolean.valueOf(addCloudConfig); + + ClusterSetup clusterSetup = getClusterSetup(); - try { - clusterSetup.addCluster(clusterId, recreateIfExists); - } catch (Exception ex) { - _logger.error("Failed to create cluster " + clusterId + ", exception: " + ex); - return serverError(ex); - } + if (!cloudConfigIncluded) { Review comment: Let's reorganize the code. There are duplicated pieces. You can: 1. Define CloudConfig object 2. Create this object if enabled and move this piece of code to a separate function. Otherwise, keep it as null. 3. Call the addCluster with CloudConfig object. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org For additional commands, e-mail: reviews-h...@helix.apache.org