Skip to content

Commit

Permalink
Merge pull request #14 from WangLiNaruto/feature/validate_interface
Browse files Browse the repository at this point in the history
implement terraform-boot for validate method
  • Loading branch information
swaroopar authored Sep 5, 2023
2 parents 16e7cab + 55dfdb7 commit b073082
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,21 @@ public TerraformResult destroy(
moduleDirectory + File.separator + UUID.randomUUID());
}

/**
* Method to validate resources by scripts.
*
* @return Returns the status of the deployment.
*/
@Tag(name = "Terraform", description = "APIs for running Terraform commands")
@Operation(description = "Deploy resources via Terraform")
@PostMapping(value = "/validate/scripts", produces =
MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public TerraformValidationResult validateWithScripts(
@Valid @RequestBody TerraformDeployWithScriptsRequest request) {
return terraformScriptsService.validateWithScripts(request);
}

/**
* Method to deploy resources by scripts.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.xpanse.terraform.boot.models.request.async.TerraformAsyncDeployFromDirectoryRequest;
import org.eclipse.xpanse.terraform.boot.models.request.async.TerraformAsyncDestroyFromDirectoryRequest;
import org.eclipse.xpanse.terraform.boot.models.response.TerraformResult;
import org.eclipse.xpanse.terraform.boot.models.validation.TerraformValidationResult;
import org.eclipse.xpanse.terraform.boot.terraform.TerraformExecutor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
Expand Down Expand Up @@ -50,6 +51,15 @@ public TerraformScriptsService(TerraformExecutor executor, RestTemplate restTemp

}

/**
* Method of deployment a service using a script.
*/
public TerraformValidationResult validateWithScripts(
TerraformDeployWithScriptsRequest request) {
String moduleDirectory = buildDeployEnv(request.getScripts());
return tfValidateFromDirectory(moduleDirectory);
}

/**
* Method of deployment a service using a script.
*/
Expand Down

0 comments on commit b073082

Please sign in to comment.