diff --git a/src/main/java/org/eclipse/xpanse/tofu/maker/models/enums/DeploymentScenario.java b/src/main/java/org/eclipse/xpanse/tofu/maker/models/enums/DeploymentScenario.java deleted file mode 100644 index bae9f7f..0000000 --- a/src/main/java/org/eclipse/xpanse/tofu/maker/models/enums/DeploymentScenario.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * SPDX-FileCopyrightText: Huawei Inc. - */ - -package org.eclipse.xpanse.tofu.maker.models.enums; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import org.apache.commons.lang3.StringUtils; -import org.eclipse.xpanse.tofu.maker.models.exceptions.UnsupportedEnumValueException; - -/** - * The deployment scenario is used to set into OpenTofuResult and sent back to the - * client which sent the deployment request in what scenario. - */ -public enum DeploymentScenario { - DEPLOY("deploy"), - MODIFY("modify"), - DESTROY("destroy"), - ROLLBACK("rollback"), - PURGE("purge"); - private final String scenario; - - DeploymentScenario(String scenario) { - this.scenario = scenario; - } - - /** - * For DeploymentScenario deserialize. - */ - @JsonCreator - public static DeploymentScenario getByValue(String scenario) { - for (DeploymentScenario deploymentScenario : values()) { - if (StringUtils.equalsIgnoreCase(deploymentScenario.scenario, scenario)) { - return deploymentScenario; - } - } - throw new UnsupportedEnumValueException( - String.format("DeploymentScenario value %s is not supported.", scenario)); - } - - /** - * For DeploymentScenario serialize. - */ - @JsonValue - public String toValue() { - return this.scenario; - } -} diff --git a/src/main/java/org/eclipse/xpanse/tofu/maker/models/request/directory/OpenTofuDeployFromDirectoryRequest.java b/src/main/java/org/eclipse/xpanse/tofu/maker/models/request/directory/OpenTofuDeployFromDirectoryRequest.java index b9efb4f..98128c2 100644 --- a/src/main/java/org/eclipse/xpanse/tofu/maker/models/request/directory/OpenTofuDeployFromDirectoryRequest.java +++ b/src/main/java/org/eclipse/xpanse/tofu/maker/models/request/directory/OpenTofuDeployFromDirectoryRequest.java @@ -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. @@ -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.", diff --git a/src/main/java/org/eclipse/xpanse/tofu/maker/models/request/directory/OpenTofuDestroyFromDirectoryRequest.java b/src/main/java/org/eclipse/xpanse/tofu/maker/models/request/directory/OpenTofuDestroyFromDirectoryRequest.java index e7c95ad..e2cb705 100644 --- a/src/main/java/org/eclipse/xpanse/tofu/maker/models/request/directory/OpenTofuDestroyFromDirectoryRequest.java +++ b/src/main/java/org/eclipse/xpanse/tofu/maker/models/request/directory/OpenTofuDestroyFromDirectoryRequest.java @@ -12,7 +12,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 destroy requests. @@ -20,20 +19,12 @@ @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 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 envVariables = new HashMap<>(); } diff --git a/src/main/java/org/eclipse/xpanse/tofu/maker/models/request/directory/OpenTofuModifyFromDirectoryRequest.java b/src/main/java/org/eclipse/xpanse/tofu/maker/models/request/directory/OpenTofuModifyFromDirectoryRequest.java index 3d1fe3f..c7378f9 100644 --- a/src/main/java/org/eclipse/xpanse/tofu/maker/models/request/directory/OpenTofuModifyFromDirectoryRequest.java +++ b/src/main/java/org/eclipse/xpanse/tofu/maker/models/request/directory/OpenTofuModifyFromDirectoryRequest.java @@ -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. @@ -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 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 envVariables = new HashMap<>(); } diff --git a/src/main/java/org/eclipse/xpanse/tofu/maker/models/response/OpenTofuResult.java b/src/main/java/org/eclipse/xpanse/tofu/maker/models/response/OpenTofuResult.java index 1cfa00d..f941fef 100644 --- a/src/main/java/org/eclipse/xpanse/tofu/maker/models/response/OpenTofuResult.java +++ b/src/main/java/org/eclipse/xpanse/tofu/maker/models/response/OpenTofuResult.java @@ -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. @@ -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; diff --git a/src/main/java/org/eclipse/xpanse/tofu/maker/opentofu/service/OpenTofuDirectoryService.java b/src/main/java/org/eclipse/xpanse/tofu/maker/opentofu/service/OpenTofuDirectoryService.java index 3d6d5e6..0aac7fe 100644 --- a/src/main/java/org/eclipse/xpanse/tofu/maker/opentofu/service/OpenTofuDirectoryService.java +++ b/src/main/java/org/eclipse/xpanse/tofu/maker/opentofu/service/OpenTofuDirectoryService.java @@ -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; @@ -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); } @@ -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); } @@ -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; } @@ -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) @@ -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) @@ -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) @@ -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; diff --git a/src/main/java/org/eclipse/xpanse/tofu/maker/opentofu/service/OpenTofuGitRepoService.java b/src/main/java/org/eclipse/xpanse/tofu/maker/opentofu/service/OpenTofuGitRepoService.java index ec08e6b..388f8a1 100644 --- a/src/main/java/org/eclipse/xpanse/tofu/maker/opentofu/service/OpenTofuGitRepoService.java +++ b/src/main/java/org/eclipse/xpanse/tofu/maker/opentofu/service/OpenTofuGitRepoService.java @@ -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) @@ -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) @@ -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) diff --git a/src/main/java/org/eclipse/xpanse/tofu/maker/opentofu/service/OpenTofuScriptsService.java b/src/main/java/org/eclipse/xpanse/tofu/maker/opentofu/service/OpenTofuScriptsService.java index acd1be4..263b677 100644 --- a/src/main/java/org/eclipse/xpanse/tofu/maker/opentofu/service/OpenTofuScriptsService.java +++ b/src/main/java/org/eclipse/xpanse/tofu/maker/opentofu/service/OpenTofuScriptsService.java @@ -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) @@ -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) @@ -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)