Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement terraform-boot for validate method #14

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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