|
@@ -1,6 +1,7 @@
|
|
|
package service
|
|
|
|
|
|
import (
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
|
|
|
"github.com/alessio/shellescape"
|
|
@@ -166,6 +167,7 @@ func (service *MarketplaceService) ReadInstalledItems() ServiceOutput {
|
|
|
|
|
|
func (service *MarketplaceService) DeleteInstalledItem(
|
|
|
input map[string]interface{},
|
|
|
+ shouldSchedule bool,
|
|
|
) ServiceOutput {
|
|
|
requiredParams := []string{"installedId"}
|
|
|
|
|
@@ -189,6 +191,34 @@ func (service *MarketplaceService) DeleteInstalledItem(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if shouldSchedule {
|
|
|
+ cliCmd := infraEnvs.InfiniteOsBinary + " mktplace delete"
|
|
|
+ installParams := []string{
|
|
|
+ "--installedId", installedId.String(),
|
|
|
+ "--shouldUninstallServices", strconv.FormatBool(shouldUninstallServices),
|
|
|
+ }
|
|
|
+
|
|
|
+ cliCmd += " " + strings.Join(installParams, " ")
|
|
|
+
|
|
|
+ scheduledTaskCmdRepo := scheduledTaskInfra.NewScheduledTaskCmdRepo(service.persistentDbSvc)
|
|
|
+ taskName, _ := valueObject.NewScheduledTaskName("DeleteMarketplaceCatalogItem")
|
|
|
+ taskCmd, _ := valueObject.NewUnixCommand(cliCmd)
|
|
|
+ taskTag, _ := valueObject.NewScheduledTaskTag("marketplace")
|
|
|
+ taskTags := []valueObject.ScheduledTaskTag{taskTag}
|
|
|
+ timeoutSeconds := uint16(600)
|
|
|
+
|
|
|
+ scheduledTaskCreateDto := dto.NewCreateScheduledTask(
|
|
|
+ taskName, taskCmd, taskTags, &timeoutSeconds, nil,
|
|
|
+ )
|
|
|
+
|
|
|
+ err = useCase.CreateScheduledTask(scheduledTaskCmdRepo, scheduledTaskCreateDto)
|
|
|
+ if err != nil {
|
|
|
+ return NewServiceOutput(InfraError, err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ return NewServiceOutput(Created, "DeleteMarketplaceCatalogItemScheduled")
|
|
|
+ }
|
|
|
+
|
|
|
deleteMarketplaceInstalledItem := dto.NewDeleteMarketplaceInstalledItem(
|
|
|
installedId, shouldUninstallServices,
|
|
|
)
|