Skip to content

Commit

Permalink
remove DeploymentScenario field
Browse files Browse the repository at this point in the history
  • Loading branch information
baixinsui committed Apr 16, 2024
1 parent e3afcd1 commit c6413ec
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 107 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.HashMap;
import java.util.Map;
import lombok.Data;
import org.eclipse.xpanse.tofu.maker.models.enums.DeploymentScenario;

/**
* Data model for the OpenTofu deploy requests.
Expand All @@ -23,12 +22,6 @@ public class OpenTofuDeployFromDirectoryRequest {
+ "or it must also apply the changes.")
Boolean isPlanOnly;

@Schema(description = "This value can be set by the client if they wish to know the type of"
+ "request for which the callback response is generated from tofu-maker. There will be"
+ "no difference in the way request is executed. This information is only set in the"
+ "callback response again for the client to handle the callback response accordingly.")
DeploymentScenario deploymentScenario;

@NotNull
@Schema(description = "Key-value pairs of variables that must be used to execute the "
+ "OpenTofu request.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,19 @@
import java.util.HashMap;
import java.util.Map;
import lombok.Data;
import org.eclipse.xpanse.tofu.maker.models.enums.DeploymentScenario;

/**
* Data model for the OpenTofu destroy requests.
*/
@Data
public class OpenTofuDestroyFromDirectoryRequest {

@Schema(description = "This value can be set by the client if they wish to know the type of"
+ "request for which the callback response is generated from tofu-maker. There will be"
+ "no difference in the way request is executed. This information is only set in the"
+ "callback response again for the client to handle the callback response accordingly.")
DeploymentScenario deploymentScenario;

@NotNull
@Schema(description = "Key-value pairs of regular variables that must be used to execute the "
+ "OpenTofu request.",
additionalProperties = TRUE)
+ "OpenTofu request.", additionalProperties = TRUE)
Map<String, Object> variables;

@Schema(description = "Key-value pairs of variables that must be injected as environment "
+ "variables to OpenTofu process.",
additionalProperties = TRUE)
+ "variables to OpenTofu process.", additionalProperties = TRUE)
Map<String, String> envVariables = new HashMap<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@

package org.eclipse.xpanse.tofu.maker.models.request.directory;

import static io.swagger.v3.oas.annotations.media.Schema.AdditionalPropertiesValue.TRUE;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.Map;
import lombok.Data;
import org.eclipse.xpanse.tofu.maker.models.enums.DeploymentScenario;

/**
* Data model for the OpenTofu modify requests.
Expand All @@ -23,20 +24,12 @@ public class OpenTofuModifyFromDirectoryRequest {
+ "or it must also apply the changes.")
Boolean isPlanOnly;

@Schema(description = "This value can be set by the client if they wish to know the type of"
+ "request for which the callback response is generated from tofu-maker. There will be"
+ "no difference in the way request is executed. This information is only set in the"
+ "callback response again for the client to handle the callback response accordingly.")
DeploymentScenario deploymentScenario;

@NotNull
@Schema(description = "Key-value pairs of variables that must be used to execute the "
+ "OpenTofu request.",
additionalProperties = Schema.AdditionalPropertiesValue.TRUE)
+ "OpenTofu request.", additionalProperties = TRUE)
Map<String, Object> variables;

@Schema(description = "Key-value pairs of variables that must be injected as environment "
+ "variables to OpenTofu process.",
additionalProperties = Schema.AdditionalPropertiesValue.TRUE)
+ "variables to OpenTofu process.", additionalProperties = TRUE)
Map<String, String> envVariables = new HashMap<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.Map;
import lombok.Builder;
import lombok.Data;
import org.eclipse.xpanse.tofu.maker.models.enums.DeploymentScenario;

/**
* Data model for the OpenTofu command execution results.
Expand All @@ -19,13 +18,8 @@
@Builder
public class OpenTofuResult {

@Schema(description = "This value can be set by the client if they wish to know the type of"
+ "request for which the callback response is generated from tofu-maker. There will be"
+ "no difference in the way request is executed. This information is only set in the"
+ "callback response again for the client to handle the callback response accordingly.")
private DeploymentScenario deploymentScenario;
@Schema(description = "defines if the command was successfully executed")
@NotNull
@Schema(description = "defines if the command was successfully executed")
private boolean isCommandSuccessful;
@Schema(description = "stdout of the command returned as string.")
private String commandStdOutput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import lombok.extern.slf4j.Slf4j;
import org.eclipse.xpanse.tofu.maker.async.TaskConfiguration;
import org.eclipse.xpanse.tofu.maker.models.OpenTofuMakerSystemStatus;
import org.eclipse.xpanse.tofu.maker.models.enums.DeploymentScenario;
import org.eclipse.xpanse.tofu.maker.models.enums.HealthStatus;
import org.eclipse.xpanse.tofu.maker.models.exceptions.OpenTofuExecutorException;
import org.eclipse.xpanse.tofu.maker.models.exceptions.OpenTofuHealthCheckException;
Expand Down Expand Up @@ -145,9 +144,7 @@ public OpenTofuResult deployFromDirectory(OpenTofuDeployFromDirectoryRequest req
result.setCommandStdError(tfEx.getMessage());
}
String workspace = executor.getModuleFullPath(moduleDirectory);
OpenTofuResult openTofuResult =
transSystemCmdResultToOpenTofuResult(result, workspace,
request.getDeploymentScenario());
OpenTofuResult openTofuResult = transSystemCmdResultToOpenTofuResult(result, workspace);
if (cleanWorkspaceAfterDeployment) {
deleteWorkspace(workspace);
}
Expand Down Expand Up @@ -176,8 +173,7 @@ public OpenTofuResult modifyFromDirectory(OpenTofuModifyFromDirectoryRequest req
}
String workspace = executor.getModuleFullPath(moduleDirectory);
OpenTofuResult openTofuResult =
transSystemCmdResultToOpenTofuResult(result, workspace,
request.getDeploymentScenario());
transSystemCmdResultToOpenTofuResult(result, workspace);
if (cleanWorkspaceAfterDeployment) {
deleteWorkspace(workspace);
}
Expand All @@ -200,8 +196,7 @@ public OpenTofuResult destroyFromDirectory(OpenTofuDestroyFromDirectoryRequest r
result.setCommandStdError(tfEx.getMessage());
}
String workspace = executor.getModuleFullPath(moduleDirectory);
OpenTofuResult openTofuResult = transSystemCmdResultToOpenTofuResult(
result, workspace, request.getDeploymentScenario());
OpenTofuResult openTofuResult = transSystemCmdResultToOpenTofuResult(result, workspace);
deleteWorkspace(workspace);
return openTofuResult;
}
Expand All @@ -228,7 +223,6 @@ public void asyncDeployWithScripts(
result = deployFromDirectory(asyncDeployRequest, moduleDirectory);
} catch (RuntimeException e) {
result = OpenTofuResult.builder()
.deploymentScenario(asyncDeployRequest.getDeploymentScenario())
.commandStdOutput(null)
.commandStdError(e.getMessage())
.isCommandSuccessful(false)
Expand All @@ -252,7 +246,6 @@ public void asyncModifyWithScripts(
result = modifyFromDirectory(asyncModifyRequest, moduleDirectory);
} catch (RuntimeException e) {
result = OpenTofuResult.builder()
.deploymentScenario(asyncModifyRequest.getDeploymentScenario())
.commandStdOutput(null)
.commandStdError(e.getMessage())
.isCommandSuccessful(false)
Expand All @@ -276,7 +269,6 @@ public void asyncDestroyWithScripts(OpenTofuAsyncDestroyFromDirectoryRequest req
result = destroyFromDirectory(request, moduleDirectory);
} catch (RuntimeException e) {
result = OpenTofuResult.builder()
.deploymentScenario(request.getDeploymentScenario())
.commandStdOutput(null)
.commandStdError(e.getMessage())
.isCommandSuccessful(false)
Expand All @@ -291,12 +283,9 @@ public void asyncDestroyWithScripts(OpenTofuAsyncDestroyFromDirectoryRequest req
}

private OpenTofuResult transSystemCmdResultToOpenTofuResult(SystemCmdResult result,
String workspace,
DeploymentScenario
deploymentScenario) {
String workspace) {
OpenTofuResult openTofuResult = OpenTofuResult.builder().build();
BeanUtils.copyProperties(result, openTofuResult);
openTofuResult.setDeploymentScenario(deploymentScenario);
openTofuResult.setTerraformState(getTerraformState(workspace));
openTofuResult.setImportantFileContentMap(getImportantFilesContent(workspace));
return openTofuResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public void asyncDeployFromGitRepo(
result = deployFromGitRepo(asyncDeployRequest, uuid);
} catch (RuntimeException e) {
result = OpenTofuResult.builder()
.deploymentScenario(asyncDeployRequest.getDeploymentScenario())
.commandStdOutput(null)
.commandStdError(e.getMessage())
.isCommandSuccessful(false)
Expand All @@ -150,7 +149,6 @@ public void asyncModifyFromGitRepo(
result = modifyFromGitRepo(asyncModifyRequest, uuid);
} catch (RuntimeException e) {
result = OpenTofuResult.builder()
.deploymentScenario(asyncModifyRequest.getDeploymentScenario())
.commandStdOutput(null)
.commandStdError(e.getMessage())
.isCommandSuccessful(false)
Expand All @@ -174,7 +172,6 @@ public void asyncDestroyFromGitRepo(OpenTofuAsyncDestroyFromGitRepoRequest reque
result = destroyFromGitRepo(request, uuid);
} catch (RuntimeException e) {
result = OpenTofuResult.builder()
.deploymentScenario(request.getDeploymentScenario())
.commandStdOutput(null)
.commandStdError(e.getMessage())
.isCommandSuccessful(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public void asyncDeployWithScripts(
result = deployWithScripts(asyncDeployRequest, uuid);
} catch (RuntimeException e) {
result = OpenTofuResult.builder()
.deploymentScenario(asyncDeployRequest.getDeploymentScenario())
.commandStdOutput(null)
.commandStdError(e.getMessage())
.isCommandSuccessful(false)
Expand All @@ -135,7 +134,6 @@ public void asyncModifyWithScripts(
result = modifyWithScripts(asyncModifyRequest, uuid);
} catch (RuntimeException e) {
result = OpenTofuResult.builder()
.deploymentScenario(asyncModifyRequest.getDeploymentScenario())
.commandStdOutput(null)
.commandStdError(e.getMessage())
.isCommandSuccessful(false)
Expand All @@ -159,7 +157,6 @@ public void asyncDestroyWithScripts(OpenTofuAsyncDestroyFromScriptsRequest reque
result = destroyWithScripts(request, uuid);
} catch (RuntimeException e) {
result = OpenTofuResult.builder()
.deploymentScenario(request.getDeploymentScenario())
.commandStdOutput(null)
.commandStdError(e.getMessage())
.isCommandSuccessful(false)
Expand Down

0 comments on commit c6413ec

Please sign in to comment.