Skip to content

Modern Docker Management, Designed for Everyone

chore: use correct converter service

Kyle Mendell3e01a4266b50
diff --git a/backend/internal/api/routes.go b/backend/internal/api/routes.go
index c313383f2..d4dcb01a5 100644
--- a/backend/internal/api/routes.go
+++ b/backend/internal/api/routes.go
@@ -44,6 +44,7 @@ func SetupRoutes(r *gin.Engine, services *Services, appConfig *config.Config) {
setupTemplateRoutes(api, services)
setupContainerRegistryRoutes(api, services)
setupAutoUpdateRoutes(api, services)
+ setupConverterRoutes(api, services)
}
func setupContainerRegistryRoutes(api *gin.RouterGroup, services *Services) {
@@ -116,7 +117,15 @@ func setupStackRoutes(router *gin.RouterGroup, services *Services) {
stacks.POST("/:id/down", stackHandler.DownStack)
stacks.DELETE("/:id/destroy", stackHandler.DestroyStack)
stacks.GET("/:id/logs/stream", stackHandler.GetStackLogsStream)
- stacks.POST("/convert", stackHandler.ConvertDockerRun)
+}
+
+func setupConverterRoutes(api *gin.RouterGroup, services *Services) {
+ convert := api.Group("/convert")
+ convert.Use(middleware.AuthMiddleware(services.Auth))
+
+ convertHandler := NewConverterHandler(services.Converter)
+
+ convert.POST("", convertHandler.ConvertDockerRun)
}
func setupEnvironmentRoutes(api *gin.RouterGroup, services *Services) {
diff --git a/backend/internal/services/converter_service.go b/backend/internal/services/converter_service.go
index b15c789ab..b7db369ce 100644
--- a/backend/internal/services/converter_service.go
+++ b/backend/internal/services/converter_service.go
@@ -15,7 +15,6 @@ func NewConverterService() *ConverterService {
return &ConverterService{}
}
-// ParseDockerRunCommand parses a docker run command string into structured data
func (s *ConverterService) ParseDockerRunCommand(command string) (*models.DockerRunCommand, error) {
if command == "" {
return nil, fmt.Errorf("docker run command must be a non-empty string")
diff --git a/frontend/src/lib/services/api/converter-api-service.ts b/frontend/src/lib/services/api/converter-api-service.ts
index ac3a11851..f7bb670e9 100644
--- a/frontend/src/lib/services/api/converter-api-service.ts
+++ b/frontend/src/lib/services/api/converter-api-service.ts
@@ -2,7 +2,7 @@ import BaseAPIService from './api-service';
export default class ConverterAPIService extends BaseAPIService {
async convert(dockerRunCommand: string) {
- const res = await this.api.post('/stacks/convert', {
+ const res = await this.api.post('/convert', {
dockerRunCommand
});
return res.data;
diff --git a/frontend/src/routes/compose/new/+page.svelte b/frontend/src/routes/compose/new/+page.svelte
index 4cc59d4d1..482a094c5 100644
--- a/frontend/src/routes/compose/new/+page.svelte
+++ b/frontend/src/routes/compose/new/+page.svelte
@@ -18,7 +18,7 @@
import DropdownCard from '$lib/components/dropdown-card.svelte';
import * as Resizable from '$lib/components/ui/resizable/index.js';
import TemplateSelectionDialog from '$lib/components/dialogs/template-selection-dialog.svelte';
- import { environmentAPI } from '$lib/services/api';
+ import { environmentAPI, converterAPI } from '$lib/services/api';
import type { Template } from '$lib/types/template.type';
import type { PageProps } from './+page';
@@ -57,18 +57,13 @@
}
handleApiResultWithCallbacks({
- result: await tryCatch(environmentAPI.convertDockerRun(dockerRunCommand)),
+ result: await tryCatch(converterAPI.convert(dockerRunCommand)),
message: 'Failed to Convert Docker Run Command',
setLoadingState: (value) => (converting = value),
onSuccess: (data) => {
- composeContent = data.composeContent;
-
- if (!name.trim() && dockerRunCommand.includes('--name ')) {
- const nameMatch = dockerRunCommand.match(/--name\s+(\S+)/);
- if (nameMatch) {
- name = nameMatch[1];
- }
- }
+ composeContent = data.dockerCompose;
+ envContent = data.envVars;
+ name = data.serviceName;
toast.success('Docker run command converted successfully!');
dockerRunCommand = '';