Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
refactor: move internal utils to public pkg directory (#2083)
Kyle Mendellabc4357a21e5
diff --git a/backend/cli/root.go b/backend/cli/root.goindex 5b6f193cd..ba7690ceb 100644--- a/backend/cli/root.go+++ b/backend/cli/root.go@@ -11,7 +11,7 @@ import ("github.com/getarcaneapp/arcane/backend/cli/upgrade""github.com/getarcaneapp/arcane/backend/internal/bootstrap""github.com/getarcaneapp/arcane/backend/internal/config"- "github.com/getarcaneapp/arcane/backend/internal/utils/signals"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/signals")var rootCmd = &cobra.Command{diff --git a/backend/cli/upgrade/upgrade.go b/backend/cli/upgrade/upgrade.goindex 42decbaee..72320ab25 100644--- a/backend/cli/upgrade/upgrade.go+++ b/backend/cli/upgrade/upgrade.go@@ -7,7 +7,7 @@ import ("strings""time"- "github.com/getarcaneapp/arcane/backend/internal/utils/docker"+ docker "github.com/getarcaneapp/arcane/backend/pkg/dockerutil""github.com/getarcaneapp/arcane/backend/pkg/libarcane"libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater""github.com/moby/moby/api/types/container"diff --git a/backend/internal/api/buildables_handler.go b/backend/internal/api/buildables_handler.goindex b0d754df8..b9060db38 100644--- a/backend/internal/api/buildables_handler.go+++ b/backend/internal/api/buildables_handler.go@@ -10,8 +10,8 @@ import ("github.com/getarcaneapp/arcane/backend/buildables""github.com/getarcaneapp/arcane/backend/internal/common""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/cookie"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/cookie"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types/auth""github.com/getarcaneapp/arcane/types/base""github.com/getarcaneapp/arcane/types/user"diff --git a/backend/internal/api/diagnostics_handler.go b/backend/internal/api/diagnostics_handler.goindex f820d3d21..a2348b71b 100644--- a/backend/internal/api/diagnostics_handler.go+++ b/backend/internal/api/diagnostics_handler.go@@ -6,7 +6,7 @@ import ("time""github.com/getarcaneapp/arcane/backend/internal/middleware"- ws "github.com/getarcaneapp/arcane/backend/internal/utils/ws"+ ws "github.com/getarcaneapp/arcane/backend/pkg/libarcane/ws""github.com/gin-gonic/gin")diff --git a/backend/internal/api/ws_handler.go b/backend/internal/api/ws_handler.goindex a51975cb9..5f2ec3fb2 100644--- a/backend/internal/api/ws_handler.go+++ b/backend/internal/api/ws_handler.go@@ -23,9 +23,9 @@ import ("github.com/getarcaneapp/arcane/backend/internal/config""github.com/getarcaneapp/arcane/backend/internal/middleware""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/docker"- httputil "github.com/getarcaneapp/arcane/backend/internal/utils/http"- ws "github.com/getarcaneapp/arcane/backend/internal/utils/ws"+ docker "github.com/getarcaneapp/arcane/backend/pkg/dockerutil"+ ws "github.com/getarcaneapp/arcane/backend/pkg/libarcane/ws"+ httputil "github.com/getarcaneapp/arcane/backend/pkg/utils/httpx"systemtypes "github.com/getarcaneapp/arcane/types/system""github.com/gin-gonic/gin""github.com/gorilla/websocket"diff --git a/backend/internal/bootstrap/bootstrap.go b/backend/internal/bootstrap/bootstrap.goindex 01b0298a4..e4e2802ad 100644--- a/backend/internal/bootstrap/bootstrap.go+++ b/backend/internal/bootstrap/bootstrap.go@@ -18,12 +18,12 @@ import ("github.com/getarcaneapp/arcane/backend/internal/config""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils"- "github.com/getarcaneapp/arcane/backend/internal/utils/crypto"- httputils "github.com/getarcaneapp/arcane/backend/internal/utils/http"+ libcrypto "github.com/getarcaneapp/arcane/backend/pkg/libarcane/crypto""github.com/getarcaneapp/arcane/backend/pkg/libarcane/edge"tunnelpb "github.com/getarcaneapp/arcane/backend/pkg/libarcane/edge/proto/tunnel/v1"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/startup""github.com/getarcaneapp/arcane/backend/pkg/scheduler"+ httputils "github.com/getarcaneapp/arcane/backend/pkg/utils/httpx""golang.org/x/net/http2""golang.org/x/net/http2/h2c""google.golang.org/grpc"@@ -102,18 +102,33 @@ func initializeStartupState(appCtx context.Context, cfg *config.Config, appServi}}- utils.LoadAgentToken(appCtx, cfg, appServices.Settings.GetStringSetting)- utils.EnsureEncryptionKey(appCtx, cfg, appServices.Settings.EnsureEncryptionKey)- crypto.InitEncryption(cfg)- utils.InitializeDefaultSettings(appCtx, cfg, appServices.Settings)- utils.MigrateSchedulerCronValues(+ runtimeCfg := &startup.RuntimeConfig{+ AgentMode: cfg.AgentMode,+ AgentToken: cfg.AgentToken,+ Environment: string(cfg.Environment),+ EncryptionKey: cfg.EncryptionKey,+ AutoLoginUsername: cfg.AutoLoginUsername,+ }++ startup.LoadAgentToken(appCtx, runtimeCfg, appServices.Settings.GetStringSetting)+ startup.EnsureEncryptionKey(appCtx, runtimeCfg, appServices.Settings.EnsureEncryptionKey)+ cfg.AgentToken = runtimeCfg.AgentToken+ cfg.EncryptionKey = runtimeCfg.EncryptionKey++ libcrypto.InitEncryption(&libcrypto.Config{+ EncryptionKey: cfg.EncryptionKey,+ Environment: string(cfg.Environment),+ AgentMode: cfg.AgentMode,+ })+ startup.InitializeDefaultSettings(appCtx, runtimeCfg, appServices.Settings)+ startup.MigrateSchedulerCronValues(appCtx,appServices.Settings.GetStringSetting,appServices.Settings.UpdateSetting,appServices.Settings.LoadDatabaseSettings,)if appServices.GitOpsSync != nil {- utils.MigrateGitOpsSyncIntervals(+ startup.MigrateGitOpsSyncIntervals(appCtx,appServices.GitOpsSync.ListSyncIntervalsRaw,appServices.GitOpsSync.UpdateSyncIntervalMinutes,@@ -138,7 +153,7 @@ func initializeStartupState(appCtx context.Context, cfg *config.Config, appServi}}- utils.TestDockerConnection(appCtx, func(ctx context.Context) error {+ startup.TestDockerConnection(appCtx, func(ctx context.Context) error {dockerClient, err := dockerClientService.GetClient(ctx)if err != nil {return err@@ -157,16 +172,16 @@ func initializeStartupState(appCtx context.Context, cfg *config.Config, appServireturn nil})- utils.InitializeNonAgentFeatures(appCtx, cfg,+ startup.InitializeNonAgentFeatures(appCtx, runtimeCfg,appServices.User.CreateDefaultAdmin,func(ctx context.Context) error {- utils.InitializeAutoLogin(ctx, cfg)+ startup.InitializeAutoLogin(ctx, runtimeCfg)return nil},appServices.Settings.MigrateOidcConfigToFields,appServices.Notification.MigrateDiscordWebhookUrlToFields,)- utils.CleanupUnknownSettings(appCtx, appServices.Settings)+ startup.CleanupUnknownSettings(appCtx, appServices.Settings)// Handle agent auto-pairing with API key.if cfg.AgentMode && cfg.AgentToken != "" && cfg.ManagerApiUrl != "" {@@ -182,13 +197,23 @@ func startEdgeTunnelClientIfConfigured(appCtx context.Context, cfg *config.Confireturn}+ edgeCfg := &edge.Config{+ EdgeAgent: cfg.EdgeAgent,+ EdgeTransport: cfg.EdgeTransport,+ EdgeReconnectInterval: cfg.EdgeReconnectInterval,+ ManagerApiUrl: cfg.ManagerApiUrl,+ AgentToken: cfg.AgentToken,+ Port: cfg.Port,+ Listen: cfg.Listen,+ }+slog.InfoContext(appCtx, "Starting edge tunnel client",- "transport_mode", edge.NormalizeEdgeTransport(cfg.EdgeTransport),- "live_tunnel_attempt_grpc", edge.UseGRPCEdgeTransport(cfg) || (edge.UsePollEdgeTransport(cfg) && strings.TrimSpace(cfg.GetManagerGRPCAddr()) != ""),- "live_tunnel_attempt_websocket", edge.UseWebSocketEdgeTransport(cfg) || (edge.UsePollEdgeTransport(cfg) && strings.TrimSpace(cfg.GetManagerBaseURL()) != ""),+ "transport_mode", edge.NormalizeEdgeTransport(edgeCfg.EdgeTransport),+ "live_tunnel_attempt_grpc", edge.UseGRPCEdgeTransport(edgeCfg) || (edge.UsePollEdgeTransport(edgeCfg) && strings.TrimSpace(edgeCfg.GetManagerGRPCAddr()) != ""),+ "live_tunnel_attempt_websocket", edge.UseWebSocketEdgeTransport(edgeCfg) || (edge.UsePollEdgeTransport(edgeCfg) && strings.TrimSpace(edgeCfg.GetManagerBaseURL()) != ""),"manager_url", cfg.ManagerApiUrl,)- errCh, err := edge.StartTunnelClientWithErrors(appCtx, cfg, router)+ errCh, err := edge.StartTunnelClientWithErrors(appCtx, edgeCfg, router)if err != nil {slog.ErrorContext(appCtx, "Failed to start edge tunnel client", "error", err)returndiff --git a/backend/internal/bootstrap/router_bootstrap.go b/backend/internal/bootstrap/router_bootstrap.goindex b9d142f94..bf1d398c6 100644--- a/backend/internal/bootstrap/router_bootstrap.go+++ b/backend/internal/bootstrap/router_bootstrap.go@@ -14,8 +14,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/config""github.com/getarcaneapp/arcane/backend/internal/huma""github.com/getarcaneapp/arcane/backend/internal/middleware"- "github.com/getarcaneapp/arcane/backend/internal/utils/cookie""github.com/getarcaneapp/arcane/backend/pkg/libarcane/edge"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/cookie""github.com/getarcaneapp/arcane/types")diff --git a/backend/internal/config/config.go b/backend/internal/config/config.goindex b167e6cdd..651e91c57 100644--- a/backend/internal/config/config.go+++ b/backend/internal/config/config.go@@ -12,6 +12,7 @@ import ("time""github.com/getarcaneapp/arcane/backend/internal/common"+ pkgutils "github.com/getarcaneapp/arcane/backend/pkg/utils")type AppEnvironment string@@ -98,6 +99,8 @@ func Load() *Config {// Set global file permissionscommon.FilePerm = cfg.FilePermcommon.DirPerm = cfg.DirPerm+ pkgutils.FilePerm = cfg.FilePerm+ pkgutils.DirPerm = cfg.DirPermreturn cfg}diff --git a/backend/internal/huma/handlers/apikeys.go b/backend/internal/huma/handlers/apikeys.goindex 6ed30749d..06fac4542 100644--- a/backend/internal/huma/handlers/apikeys.go+++ b/backend/internal/huma/handlers/apikeys.go@@ -9,7 +9,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/common"humamw "github.com/getarcaneapp/arcane/backend/internal/huma/middleware""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/types/apikey""github.com/getarcaneapp/arcane/types/base")diff --git a/backend/internal/huma/handlers/auth.go b/backend/internal/huma/handlers/auth.goindex 8cc0efe9e..e6e96ddd3 100644--- a/backend/internal/huma/handlers/auth.go+++ b/backend/internal/huma/handlers/auth.go@@ -10,8 +10,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/common"humamw "github.com/getarcaneapp/arcane/backend/internal/huma/middleware""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/cookie"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/cookie"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types/auth""github.com/getarcaneapp/arcane/types/base""github.com/getarcaneapp/arcane/types/user"diff --git a/backend/internal/huma/handlers/container_registries.go b/backend/internal/huma/handlers/container_registries.goindex 1262f12c8..d48ea2cce 100644--- a/backend/internal/huma/handlers/container_registries.go+++ b/backend/internal/huma/handlers/container_registries.go@@ -9,8 +9,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/common""github.com/getarcaneapp/arcane/backend/internal/models""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/crypto"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/crypto"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types/base""github.com/getarcaneapp/arcane/types/containerregistry")diff --git a/backend/internal/huma/handlers/containers.go b/backend/internal/huma/handlers/containers.goindex 2c3724f4a..1566475c4 100644--- a/backend/internal/huma/handlers/containers.go+++ b/backend/internal/huma/handlers/containers.go@@ -11,8 +11,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/common"humamw "github.com/getarcaneapp/arcane/backend/internal/huma/middleware""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination""github.com/getarcaneapp/arcane/backend/pkg/libarcane"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/types/base"containertypes "github.com/getarcaneapp/arcane/types/container"dockercontainer "github.com/moby/moby/api/types/container"diff --git a/backend/internal/huma/handlers/environments.go b/backend/internal/huma/handlers/environments.goindex 4c52de179..f57da6a3b 100644--- a/backend/internal/huma/handlers/environments.go+++ b/backend/internal/huma/handlers/environments.go@@ -15,10 +15,10 @@ import (humamw "github.com/getarcaneapp/arcane/backend/internal/huma/middleware""github.com/getarcaneapp/arcane/backend/internal/models""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"- "github.com/getarcaneapp/arcane/backend/internal/utils/stringutils""github.com/getarcaneapp/arcane/backend/pkg/libarcane/edge"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/utils"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types/base""github.com/getarcaneapp/arcane/types/environment""github.com/getarcaneapp/arcane/types/version"@@ -763,7 +763,7 @@ func (h *EnvironmentHandler) PairAgent(ctx context.Context, input *PairAgentInpushouldRotate := input.Body != nil && input.Body.Rotate != nil && *input.Body.Rotateif h.cfg.AgentToken == "" || shouldRotate {- h.cfg.AgentToken = stringutils.GenerateRandomString(48)+ h.cfg.AgentToken = utils.GenerateRandomString(48)}if err := h.settingsService.SetStringSetting(ctx, "agentToken", h.cfg.AgentToken); err != nil {diff --git a/backend/internal/huma/handlers/git_repositories.go b/backend/internal/huma/handlers/git_repositories.goindex 1dc0bf5d3..1270585da 100644--- a/backend/internal/huma/handlers/git_repositories.go+++ b/backend/internal/huma/handlers/git_repositories.go@@ -8,7 +8,7 @@ import (humamw "github.com/getarcaneapp/arcane/backend/internal/huma/middleware""github.com/getarcaneapp/arcane/backend/internal/models""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types/base""github.com/getarcaneapp/arcane/types/gitops")diff --git a/backend/internal/huma/handlers/gitops_syncs.go b/backend/internal/huma/handlers/gitops_syncs.goindex 2dbe6adb4..fe7ff9f27 100644--- a/backend/internal/huma/handlers/gitops_syncs.go+++ b/backend/internal/huma/handlers/gitops_syncs.go@@ -8,7 +8,7 @@ import (humamw "github.com/getarcaneapp/arcane/backend/internal/huma/middleware""github.com/getarcaneapp/arcane/backend/internal/models""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types/base""github.com/getarcaneapp/arcane/types/gitops")diff --git a/backend/internal/huma/handlers/helpers.go b/backend/internal/huma/handlers/helpers.goindex 0a1df622b..a57beb135 100644--- a/backend/internal/huma/handlers/helpers.go+++ b/backend/internal/huma/handlers/helpers.go@@ -5,7 +5,7 @@ import ("github.com/danielgtaylor/huma/v2"humamw "github.com/getarcaneapp/arcane/backend/internal/huma/middleware"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination")// checkAdmin checks if the current user is an admin and returns a 403 error if not.diff --git a/backend/internal/huma/handlers/images.go b/backend/internal/huma/handlers/images.goindex 2b8644d06..e479ad8ba 100644--- a/backend/internal/huma/handlers/images.go+++ b/backend/internal/huma/handlers/images.go@@ -12,7 +12,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/common"humamw "github.com/getarcaneapp/arcane/backend/internal/huma/middleware""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/types/base""github.com/getarcaneapp/arcane/types/image""gorm.io/gorm"diff --git a/backend/internal/huma/handlers/networks.go b/backend/internal/huma/handlers/networks.goindex b3cac3747..ae0e72217 100644--- a/backend/internal/huma/handlers/networks.go+++ b/backend/internal/huma/handlers/networks.go@@ -12,8 +12,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/common"humamw "github.com/getarcaneapp/arcane/backend/internal/huma/middleware""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types/base"networktypes "github.com/getarcaneapp/arcane/types/network"dockernetwork "github.com/moby/moby/api/types/network"diff --git a/backend/internal/huma/handlers/oidc.go b/backend/internal/huma/handlers/oidc.goindex 13af5714b..3741cc0f7 100644--- a/backend/internal/huma/handlers/oidc.go+++ b/backend/internal/huma/handlers/oidc.go@@ -10,8 +10,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/common""github.com/getarcaneapp/arcane/backend/internal/config""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/cookie"- httputils "github.com/getarcaneapp/arcane/backend/internal/utils/http"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/cookie"+ httputils "github.com/getarcaneapp/arcane/backend/pkg/utils/httpx""github.com/getarcaneapp/arcane/types/auth""github.com/getarcaneapp/arcane/types/user")diff --git a/backend/internal/huma/handlers/projects.go b/backend/internal/huma/handlers/projects.goindex 73db6e3f4..4ad08f1e5 100644--- a/backend/internal/huma/handlers/projects.go+++ b/backend/internal/huma/handlers/projects.go@@ -12,10 +12,10 @@ import ("github.com/getarcaneapp/arcane/backend/internal/common"humamw "github.com/getarcaneapp/arcane/backend/internal/huma/middleware""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"projects "github.com/getarcaneapp/arcane/backend/pkg/projects"+ "github.com/getarcaneapp/arcane/backend/pkg/utils"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types/base""github.com/getarcaneapp/arcane/types/project")diff --git a/backend/internal/huma/handlers/settings.go b/backend/internal/huma/handlers/settings.goindex 244f4a6d7..21c8c54ea 100644--- a/backend/internal/huma/handlers/settings.go+++ b/backend/internal/huma/handlers/settings.go@@ -13,8 +13,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/config"humamw "github.com/getarcaneapp/arcane/backend/internal/huma/middleware""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"- "github.com/getarcaneapp/arcane/backend/internal/utils/pathmapper"+ "github.com/getarcaneapp/arcane/backend/pkg/projects"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types/base""github.com/getarcaneapp/arcane/types/category""github.com/getarcaneapp/arcane/types/search"@@ -74,7 +74,7 @@ type GetCategoriesOutput struct {// - Mapping format "container:host" where container is absolute Unix or Windows pathfunc validateProjectsDirectoryValue(path string) error {switch {- case pathmapper.IsWindowsDrivePath(path):+ case projects.IsWindowsDrivePath(path):return nilcase strings.Contains(path, ":"):parts := strings.SplitN(path, ":", 2)@@ -82,7 +82,7 @@ func validateProjectsDirectoryValue(path string) error {return errors.New("projectsDirectory must be an absolute path or valid mapping format")}container := parts[0]- if !strings.HasPrefix(container, "/") && !pathmapper.IsWindowsDrivePath(container) {+ if !strings.HasPrefix(container, "/") && !projects.IsWindowsDrivePath(container) {return errors.New("projectsDirectory mapping format: container path must be absolute")}return nildiff --git a/backend/internal/huma/handlers/settings_validation_test.go b/backend/internal/huma/handlers/settings_validation_test.goindex 5f38f3ec0..00d14bc61 100644--- a/backend/internal/huma/handlers/settings_validation_test.go+++ b/backend/internal/huma/handlers/settings_validation_test.go@@ -4,7 +4,7 @@ import ("strings""testing"- "github.com/getarcaneapp/arcane/backend/internal/utils/pathmapper"+ "github.com/getarcaneapp/arcane/backend/pkg/projects""github.com/stretchr/testify/assert")@@ -78,7 +78,7 @@ func TestProjectsDirectoryValidation(t *testing.T) {isValid := trueswitch {- case pathmapper.IsWindowsDrivePath(path):+ case projects.IsWindowsDrivePath(path):// Valid Windows pathcase strings.Contains(path, ":"):// Mapping format (container:host)@@ -88,7 +88,7 @@ func TestProjectsDirectoryValidation(t *testing.T) {break}container := parts[0]- if !strings.HasPrefix(container, "/") && !pathmapper.IsWindowsDrivePath(container) {+ if !strings.HasPrefix(container, "/") && !projects.IsWindowsDrivePath(container) {isValid = false}default:diff --git a/backend/internal/huma/handlers/system.go b/backend/internal/huma/handlers/system.goindex ece234c40..e638ec0e2 100644--- a/backend/internal/huma/handlers/system.go+++ b/backend/internal/huma/handlers/system.go@@ -11,9 +11,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/common""github.com/getarcaneapp/arcane/backend/internal/config"humamw "github.com/getarcaneapp/arcane/backend/internal/huma/middleware"- "github.com/getarcaneapp/arcane/backend/internal/models""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/docker"+ docker "github.com/getarcaneapp/arcane/backend/pkg/dockerutil""github.com/getarcaneapp/arcane/types/base"containertypes "github.com/getarcaneapp/arcane/types/container""github.com/getarcaneapp/arcane/types/dockerinfo"@@ -83,11 +82,11 @@ type StopAllContainersOutput struct {type ConvertDockerRunInput struct {EnvironmentID string `path:"id" doc:"Environment ID"`- Body models.ConvertDockerRunRequest `doc:"Docker run command"`+ Body system.ConvertDockerRunRequest `doc:"Docker run command"`}type ConvertDockerRunOutput struct {- Body models.ConvertDockerRunResponse+ Body system.ConvertDockerRunResponse}type CheckUpgradeInput struct {@@ -471,7 +470,7 @@ func (h *SystemHandler) ConvertDockerRun(ctx context.Context, input *ConvertDock}return &ConvertDockerRunOutput{- Body: models.ConvertDockerRunResponse{+ Body: system.ConvertDockerRunResponse{Success: true,DockerCompose: dockerCompose,EnvVars: envVars,diff --git a/backend/internal/huma/handlers/templates.go b/backend/internal/huma/handlers/templates.goindex e95d98fbc..8f1bb901d 100644--- a/backend/internal/huma/handlers/templates.go+++ b/backend/internal/huma/handlers/templates.go@@ -8,7 +8,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/common""github.com/getarcaneapp/arcane/backend/internal/models""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types/base""github.com/getarcaneapp/arcane/types/env""github.com/getarcaneapp/arcane/types/template"diff --git a/backend/internal/huma/handlers/users.go b/backend/internal/huma/handlers/users.goindex 6b8a32005..115287a61 100644--- a/backend/internal/huma/handlers/users.go+++ b/backend/internal/huma/handlers/users.go@@ -10,7 +10,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/common""github.com/getarcaneapp/arcane/backend/internal/models""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/validation"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/validation""github.com/getarcaneapp/arcane/types/base""github.com/getarcaneapp/arcane/types/user")diff --git a/backend/internal/huma/handlers/volumes.go b/backend/internal/huma/handlers/volumes.goindex e1e724b58..07d8bade9 100644--- a/backend/internal/huma/handlers/volumes.go+++ b/backend/internal/huma/handlers/volumes.go@@ -13,7 +13,7 @@ import (humamw "github.com/getarcaneapp/arcane/backend/internal/huma/middleware""github.com/getarcaneapp/arcane/backend/internal/models""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/types/base"volumetypes "github.com/getarcaneapp/arcane/types/volume""github.com/moby/moby/client"diff --git a/backend/internal/middleware/auth_middleware.go b/backend/internal/middleware/auth_middleware.goindex 91ef04160..1693f28ed 100644--- a/backend/internal/middleware/auth_middleware.go+++ b/backend/internal/middleware/auth_middleware.go@@ -10,8 +10,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/config""github.com/getarcaneapp/arcane/backend/internal/models""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/cookie"pkgutils "github.com/getarcaneapp/arcane/backend/pkg/utils"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/cookie""github.com/gin-gonic/gin")diff --git a/backend/internal/middleware/environment_middleware.go b/backend/internal/middleware/environment_middleware.goindex d6409fe38..78bb2ff86 100644--- a/backend/internal/middleware/environment_middleware.go+++ b/backend/internal/middleware/environment_middleware.go@@ -11,9 +11,8 @@ import ("strings""time"- "github.com/getarcaneapp/arcane/backend/internal/utils/remenv"- wsutil "github.com/getarcaneapp/arcane/backend/internal/utils/ws""github.com/getarcaneapp/arcane/backend/pkg/libarcane/edge"+ wsutil "github.com/getarcaneapp/arcane/backend/pkg/libarcane/ws""github.com/gin-gonic/gin""github.com/gorilla/websocket")@@ -204,8 +203,8 @@ func (m *EnvironmentMiddleware) setProxyContextHeadersInternal(c *gin.Context, a// ProxyHTTPRequest and ProxyWebSocketRequest copy headers from c.Request.Header,// so setting these here ensures the agent receives proper authentication.if accessToken != nil && *accessToken != "" {- c.Request.Header.Set(remenv.HeaderAgentToken, *accessToken)- c.Request.Header.Set(remenv.HeaderAPIKey, *accessToken)+ c.Request.Header.Set(edge.HeaderAgentToken, *accessToken)+ c.Request.Header.Set(edge.HeaderAPIKey, *accessToken)}}@@ -294,8 +293,8 @@ func (m *EnvironmentMiddleware) isWebSocketUpgrade(c *gin.Context) bool {if websocket.IsWebSocketUpgrade(c.Request) {return true}- return strings.EqualFold(c.GetHeader(remenv.HeaderUpgrade), "websocket") ||- strings.Contains(strings.ToLower(c.GetHeader(remenv.HeaderConnection)), remenv.ConnectionUpgradeToken) ||+ return strings.EqualFold(c.GetHeader(edge.HeaderUpgrade), "websocket") ||+ strings.Contains(strings.ToLower(c.GetHeader(edge.HeaderConnection)), edge.ConnectionUpgradeToken) ||c.GetHeader("Sec-Websocket-Key") != ""}@@ -361,8 +360,8 @@ func (m *EnvironmentMiddleware) proxyWebSocket(c *gin.Context, target string, acreturn}- wsTarget := remenv.HTTPToWebSocketURL(target)- headers := remenv.BuildWebSocketHeaders(c, accessToken)+ wsTarget := edge.HTTPToWebSocketURL(target)+ headers := edge.BuildWebSocketHeaders(c, accessToken)if err := wsutil.ProxyHTTP(c.Writer, c.Request, wsTarget, headers); err != nil {slog.Error("websocket proxy failed", "err", err)@@ -428,11 +427,11 @@ func (m *EnvironmentMiddleware) createProxyRequest(c *gin.Context, target stringreturn nil, err}- skip := remenv.GetSkipHeaders()- remenv.CopyRequestHeaders(c.Request.Header, req.Header, skip)- remenv.SetAuthHeader(req, c)- remenv.SetAgentToken(req, accessToken)- remenv.SetForwardedHeaders(req, c.ClientIP(), c.Request.Host)+ skip := edge.GetSkipHeaders()+ edge.CopyRequestHeaders(c.Request.Header, req.Header, skip)+ edge.SetAuthHeader(req, c)+ edge.SetAgentToken(req, accessToken)+ edge.SetForwardedHeaders(req, c.ClientIP(), c.Request.Host)// Set Content-Length based on actual body sizeif len(bodyBytes) > 0 {@@ -444,8 +443,8 @@ func (m *EnvironmentMiddleware) createProxyRequest(c *gin.Context, target string// writeProxyResponse copies the proxy response back to the client.func (m *EnvironmentMiddleware) writeProxyResponse(c *gin.Context, resp *http.Response) {- hopByHop := remenv.BuildHopByHopHeaders(resp.Header)- remenv.CopyResponseHeaders(resp.Header, c.Writer.Header(), hopByHop)+ hopByHop := edge.BuildHopByHopHeaders(resp.Header)+ edge.CopyResponseHeaders(resp.Header, c.Writer.Header(), hopByHop)c.Status(resp.StatusCode)if c.Request.Method != http.MethodHead {@@ -453,6 +452,6 @@ func (m *EnvironmentMiddleware) writeProxyResponse(c *gin.Context, resp *http.Re// This is critical for streaming responses (e.g., JSON line streams) where// clients expect incremental updates.c.Writer.WriteHeaderNow()- remenv.CopyBodyWithFlush(c.Writer, resp.Body)+ edge.CopyBodyWithFlush(c.Writer, resp.Body)}}diff --git a/backend/internal/services/api_key_service.go b/backend/internal/services/api_key_service.goindex a18b9766b..b85c98731 100644--- a/backend/internal/services/api_key_service.go+++ b/backend/internal/services/api_key_service.go@@ -11,7 +11,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/types/apikey""gorm.io/gorm")diff --git a/backend/internal/services/app_images_service.go b/backend/internal/services/app_images_service.goindex d7f52a2c9..cd33c6d11 100644--- a/backend/internal/services/app_images_service.go+++ b/backend/internal/services/app_images_service.go@@ -8,7 +8,7 @@ import ("strings""sync"- "github.com/getarcaneapp/arcane/backend/internal/utils/image"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/image")type ApplicationImagesService struct {diff --git a/backend/internal/services/auth_service.go b/backend/internal/services/auth_service.goindex 6c28323c3..c8b5891e4 100644--- a/backend/internal/services/auth_service.go+++ b/backend/internal/services/auth_service.go@@ -10,7 +10,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/config""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/crypto"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/jwtclaims""github.com/getarcaneapp/arcane/types/auth""github.com/golang-jwt/jwt/v5""github.com/google/uuid"@@ -63,7 +63,7 @@ func NewAuthService(userService *UserService, settingsService *SettingsService,userService: userService,settingsService: settingsService,eventService: eventService,- jwtSecret: crypto.CheckOrGenerateJwtSecret(jwtSecret),+ jwtSecret: jwtclaims.CheckOrGenerateJwtSecret(jwtSecret),refreshExpiry: cfg.JWTRefreshExpiry,config: cfg,}@@ -509,13 +509,13 @@ func (s *AuthService) isAdminFromOidc(ctx context.Context, userInfo auth.OidcUsereturn false}- if v, ok := crypto.GetByPath(userInfo.Extra, claimKey); ok && crypto.EvalMatch(v, values) {+ if v, ok := jwtclaims.GetByPath(userInfo.Extra, claimKey); ok && jwtclaims.EvalMatch(v, values) {return true}if tokenResp != nil && tokenResp.IDToken != "" {- if claims := crypto.ParseJWTClaims(tokenResp.IDToken); claims != nil {- if v, ok := crypto.GetByPath(claims, claimKey); ok && crypto.EvalMatch(v, values) {+ if claims := jwtclaims.ParseJWTClaims(tokenResp.IDToken); claims != nil {+ if v, ok := jwtclaims.GetByPath(claims, claimKey); ok && jwtclaims.EvalMatch(v, values) {return true}}diff --git a/backend/internal/services/build_service.go b/backend/internal/services/build_service.goindex cb52c63c2..169c14b32 100644--- a/backend/internal/services/build_service.go+++ b/backend/internal/services/build_service.go@@ -14,9 +14,9 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- buildgit "github.com/getarcaneapp/arcane/backend/internal/utils/git"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"+ buildgit "github.com/getarcaneapp/arcane/backend/pkg/gitutil"libbuild "github.com/getarcaneapp/arcane/backend/pkg/libarcane/libbuild"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"buildtypes "github.com/getarcaneapp/arcane/types/builds"imagetypes "github.com/getarcaneapp/arcane/types/image"dockerregistry "github.com/moby/moby/api/types/registry"diff --git a/backend/internal/services/build_service_test.go b/backend/internal/services/build_service_test.goindex b870fe7d9..4174f1eb1 100644--- a/backend/internal/services/build_service_test.go+++ b/backend/internal/services/build_service_test.go@@ -9,8 +9,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/crypto"- buildgit "github.com/getarcaneapp/arcane/backend/internal/utils/git"+ buildgit "github.com/getarcaneapp/arcane/backend/pkg/gitutil"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/crypto""github.com/getarcaneapp/arcane/types/image"glsqlite "github.com/glebarez/sqlite""github.com/stretchr/testify/assert"diff --git a/backend/internal/services/container_registry_service.go b/backend/internal/services/container_registry_service.goindex ae671f65c..a934569b8 100644--- a/backend/internal/services/container_registry_service.go+++ b/backend/internal/services/container_registry_service.go@@ -15,13 +15,13 @@ import (cerrdefs "github.com/containerd/errdefs""github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils"- "github.com/getarcaneapp/arcane/backend/internal/utils/cache"- "github.com/getarcaneapp/arcane/backend/internal/utils/crypto"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"- utilsregistry "github.com/getarcaneapp/arcane/backend/internal/utils/registry"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/crypto"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/utils"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/cache"utilsdistribution "github.com/getarcaneapp/arcane/backend/pkg/utils/distribution"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper"+ utilsregistry "github.com/getarcaneapp/arcane/backend/pkg/utils/registry""github.com/getarcaneapp/arcane/types/containerregistry"dockerregistry "github.com/moby/moby/api/types/registry""github.com/moby/moby/client"@@ -1009,6 +1009,16 @@ func (s *ContainerRegistryService) fetchDigestFromRegistryInternal(ctx context.C}}+ if s.distributionHTTPClient == nil {+ return utilsdistribution.FetchDigest(+ ctx,+ registryHost,+ repository,+ tag,+ distributionCredential,+ )+ }+return utilsdistribution.FetchDigestWithHTTPClient(ctx,registryHost,diff --git a/backend/internal/services/container_registry_service_test.go b/backend/internal/services/container_registry_service_test.goindex 8df0b2df1..9d0a763f3 100644--- a/backend/internal/services/container_registry_service_test.go+++ b/backend/internal/services/container_registry_service_test.go@@ -11,7 +11,7 @@ import ("testing""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/crypto"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/crypto""github.com/getarcaneapp/arcane/types/containerregistry"dockerregistry "github.com/moby/moby/api/types/registry""github.com/moby/moby/client"diff --git a/backend/internal/services/container_service.go b/backend/internal/services/container_service.goindex 20eb55fb6..3cb11be4b 100644--- a/backend/internal/services/container_service.go+++ b/backend/internal/services/container_service.go@@ -14,14 +14,14 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- dockerutils "github.com/getarcaneapp/arcane/backend/internal/utils/docker"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"- "github.com/getarcaneapp/arcane/backend/internal/utils/timeouts"+ dockerutils "github.com/getarcaneapp/arcane/backend/pkg/dockerutil""github.com/getarcaneapp/arcane/backend/pkg/libarcane"- "github.com/getarcaneapp/arcane/backend/pkg/utils/stdcopy"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"containertypes "github.com/getarcaneapp/arcane/types/container""github.com/getarcaneapp/arcane/types/containerregistry"imagetypes "github.com/getarcaneapp/arcane/types/image"+ "github.com/moby/moby/api/pkg/stdcopy""github.com/moby/moby/api/types/container""github.com/moby/moby/api/types/network""github.com/moby/moby/client"diff --git a/backend/internal/services/container_service_test.go b/backend/internal/services/container_service_test.goindex 9a2e640eb..e4128f795 100644--- a/backend/internal/services/container_service_test.go+++ b/backend/internal/services/container_service_test.go@@ -4,7 +4,7 @@ import ("net/netip""testing"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"containertypes "github.com/getarcaneapp/arcane/types/container""github.com/moby/moby/api/types/container""github.com/moby/moby/api/types/network"diff --git a/backend/internal/services/customize_search_service.go b/backend/internal/services/customize_search_service.goindex 275bba45d..be39784cf 100644--- a/backend/internal/services/customize_search_service.go+++ b/backend/internal/services/customize_search_service.go@@ -7,7 +7,7 @@ import ("sync""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils"+ "github.com/getarcaneapp/arcane/backend/pkg/utils""github.com/getarcaneapp/arcane/types/category""github.com/getarcaneapp/arcane/types/meta""github.com/getarcaneapp/arcane/types/search"diff --git a/backend/internal/services/docker_client_service.go b/backend/internal/services/docker_client_service.goindex 8da9831c0..cbc5017db 100644--- a/backend/internal/services/docker_client_service.go+++ b/backend/internal/services/docker_client_service.go@@ -10,8 +10,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/config""github.com/getarcaneapp/arcane/backend/internal/database"- "github.com/getarcaneapp/arcane/backend/internal/utils/docker"- "github.com/getarcaneapp/arcane/backend/internal/utils/timeouts"+ docker "github.com/getarcaneapp/arcane/backend/pkg/dockerutil"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts""github.com/moby/moby/api/types/container""github.com/moby/moby/api/types/image""github.com/moby/moby/api/types/mount"diff --git a/backend/internal/services/ecr_token_service.go b/backend/internal/services/ecr_token_service.goindex cd85461a2..e37e95f46 100644--- a/backend/internal/services/ecr_token_service.go+++ b/backend/internal/services/ecr_token_service.go@@ -12,7 +12,7 @@ import ("github.com/aws/aws-sdk-go-v2/credentials""github.com/aws/aws-sdk-go-v2/service/ecr""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/crypto"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/crypto")const ecrTokenTTL = 12 * time.Hourdiff --git a/backend/internal/services/environment_service.go b/backend/internal/services/environment_service.goindex 45ef660cc..900ccf56c 100644--- a/backend/internal/services/environment_service.go+++ b/backend/internal/services/environment_service.go@@ -14,11 +14,11 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/crypto"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"- "github.com/getarcaneapp/arcane/backend/internal/utils/timeouts"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/crypto""github.com/getarcaneapp/arcane/backend/pkg/libarcane/edge"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types/containerregistry""github.com/getarcaneapp/arcane/types/environment""github.com/getarcaneapp/arcane/types/gitops"diff --git a/backend/internal/services/environment_service_test.go b/backend/internal/services/environment_service_test.goindex 793630637..6e6e3b498 100644--- a/backend/internal/services/environment_service_test.go+++ b/backend/internal/services/environment_service_test.go@@ -17,7 +17,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/config""github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/crypto"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/crypto""github.com/getarcaneapp/arcane/types/containerregistry")@@ -32,7 +32,11 @@ func setupEnvironmentServiceTestDB(t *testing.T) *database.DB {EncryptionKey: "test-encryption-key-for-testing-32bytes-min",Environment: "test",}- crypto.InitEncryption(testCfg)+ crypto.InitEncryption(&crypto.Config{+ EncryptionKey: testCfg.EncryptionKey,+ Environment: string(testCfg.Environment),+ AgentMode: testCfg.AgentMode,+ })return &database.DB{DB: db}}diff --git a/backend/internal/services/event_service.go b/backend/internal/services/event_service.goindex 77d94b4a4..619c1d22f 100644--- a/backend/internal/services/event_service.go+++ b/backend/internal/services/event_service.go@@ -16,9 +16,9 @@ import ("github.com/getarcaneapp/arcane/backend/internal/config""github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination""github.com/getarcaneapp/arcane/backend/pkg/libarcane/edge"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types/event""golang.org/x/text/cases""golang.org/x/text/language"diff --git a/backend/internal/services/git_repository_service.go b/backend/internal/services/git_repository_service.goindex 9386687a0..5043c6587 100644--- a/backend/internal/services/git_repository_service.go+++ b/backend/internal/services/git_repository_service.go@@ -8,13 +8,13 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils"- "github.com/getarcaneapp/arcane/backend/internal/utils/crypto"- "github.com/getarcaneapp/arcane/backend/internal/utils/git"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"- "github.com/getarcaneapp/arcane/backend/internal/utils/timeouts"+ git "github.com/getarcaneapp/arcane/backend/pkg/gitutil"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/crypto"libbuild "github.com/getarcaneapp/arcane/backend/pkg/libarcane/libbuild"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/utils"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types/gitops""gorm.io/gorm")diff --git a/backend/internal/services/gitops_sync_service.go b/backend/internal/services/gitops_sync_service.goindex f7d91b7bd..14b6ed970 100644--- a/backend/internal/services/gitops_sync_service.go+++ b/backend/internal/services/gitops_sync_service.go@@ -12,10 +12,10 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- bootstraputils "github.com/getarcaneapp/arcane/backend/internal/utils"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/startup"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/backend/pkg/projects"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types/gitops""gorm.io/gorm")@@ -38,21 +38,21 @@ func NewGitOpsSyncService(db *database.DB, repoService *GitRepositoryService, pr}}-func (s *GitOpsSyncService) ListSyncIntervalsRaw(ctx context.Context) ([]bootstraputils.IntervalMigrationItem, error) {+func (s *GitOpsSyncService) ListSyncIntervalsRaw(ctx context.Context) ([]startup.IntervalMigrationItem, error) {rows, err := s.db.WithContext(ctx).Raw("SELECT id, sync_interval FROM gitops_syncs").Rows()if err != nil {return nil, fmt.Errorf("failed to load git sync intervals: %w", err)}defer func() { _ = rows.Close() }()- items := make([]bootstraputils.IntervalMigrationItem, 0)+ items := make([]startup.IntervalMigrationItem, 0)for rows.Next() {var id stringvar raw anyif err := rows.Scan(&id, &raw); err != nil {return nil, fmt.Errorf("failed to scan git sync interval: %w", err)}- items = append(items, bootstraputils.IntervalMigrationItem{+ items = append(items, startup.IntervalMigrationItem{ID: id,RawValue: strings.TrimSpace(fmt.Sprint(raw)),})diff --git a/backend/internal/services/image_service.go b/backend/internal/services/image_service.goindex d8fdf9626..b31ef3858 100644--- a/backend/internal/services/image_service.go+++ b/backend/internal/services/image_service.go@@ -11,9 +11,9 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- dockerutils "github.com/getarcaneapp/arcane/backend/internal/utils/docker"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"- utilsregistry "github.com/getarcaneapp/arcane/backend/internal/utils/registry"+ dockerutils "github.com/getarcaneapp/arcane/backend/pkg/dockerutil"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"+ utilsregistry "github.com/getarcaneapp/arcane/backend/pkg/utils/registry""github.com/getarcaneapp/arcane/types/containerregistry"imagetypes "github.com/getarcaneapp/arcane/types/image""github.com/getarcaneapp/arcane/types/vulnerability"diff --git a/backend/internal/services/image_service_test.go b/backend/internal/services/image_service_test.goindex a55c61ece..3a4ace342 100644--- a/backend/internal/services/image_service_test.go+++ b/backend/internal/services/image_service_test.go@@ -12,7 +12,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/config""github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/crypto"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/crypto"imagetypes "github.com/getarcaneapp/arcane/types/image""github.com/getarcaneapp/arcane/types/vulnerability"dockerauthconfig "github.com/moby/moby/api/pkg/authconfig"@@ -60,8 +60,8 @@ func setupImageServiceAuthTest(t *testing.T) (*ImageService, *database.DB) {require.NoError(t, err)require.NoError(t, db.AutoMigrate(&models.ContainerRegistry{}))- crypto.InitEncryption(&config.Config{- Environment: config.AppEnvironmentTest,+ crypto.InitEncryption(&crypto.Config{+ Environment: string(config.AppEnvironmentTest),EncryptionKey: "test-encryption-key-for-testing-32bytes-min",})diff --git a/backend/internal/services/image_update_service.go b/backend/internal/services/image_update_service.goindex f8cd60b31..a2c8c65e5 100644--- a/backend/internal/services/image_update_service.go+++ b/backend/internal/services/image_update_service.go@@ -11,8 +11,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/crypto"- registry "github.com/getarcaneapp/arcane/backend/internal/utils/registry"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/crypto"+ registry "github.com/getarcaneapp/arcane/backend/pkg/utils/registry""github.com/getarcaneapp/arcane/types/containerregistry""github.com/getarcaneapp/arcane/types/imageupdate""github.com/moby/moby/api/types/image"diff --git a/backend/internal/services/network_service.go b/backend/internal/services/network_service.goindex a5c3ea265..6b6456a37 100644--- a/backend/internal/services/network_service.go+++ b/backend/internal/services/network_service.go@@ -7,9 +7,9 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- dockerutil "github.com/getarcaneapp/arcane/backend/internal/utils/docker"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"+ dockerutil "github.com/getarcaneapp/arcane/backend/pkg/dockerutil""github.com/getarcaneapp/arcane/backend/pkg/libarcane"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"networktypes "github.com/getarcaneapp/arcane/types/network""github.com/moby/moby/api/types/container""github.com/moby/moby/api/types/network"diff --git a/backend/internal/services/notification_service.go b/backend/internal/services/notification_service.goindex 4c5f37d04..d1f873b3e 100644--- a/backend/internal/services/notification_service.go+++ b/backend/internal/services/notification_service.go@@ -19,7 +19,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/config""github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/crypto"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/crypto""github.com/getarcaneapp/arcane/backend/pkg/utils/notifications""github.com/getarcaneapp/arcane/backend/resources""github.com/getarcaneapp/arcane/types/imageupdate"diff --git a/backend/internal/services/notification_service_test.go b/backend/internal/services/notification_service_test.goindex c0c640f01..3d9e95752 100644--- a/backend/internal/services/notification_service_test.go+++ b/backend/internal/services/notification_service_test.go@@ -20,7 +20,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/config""github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/crypto"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/crypto""github.com/getarcaneapp/arcane/backend/pkg/utils/notifications""github.com/getarcaneapp/arcane/types/imageupdate"notificationdto "github.com/getarcaneapp/arcane/types/notification"@@ -38,7 +38,11 @@ func setupNotificationTestDB(t *testing.T) *database.DB {EncryptionKey: "test-encryption-key-for-testing-32bytes-min",Environment: "test",}- crypto.InitEncryption(testCfg)+ crypto.InitEncryption(&crypto.Config{+ EncryptionKey: testCfg.EncryptionKey,+ Environment: string(testCfg.Environment),+ AgentMode: testCfg.AgentMode,+ })return &database.DB{DB: db}}diff --git a/backend/internal/services/oidc_service.go b/backend/internal/services/oidc_service.goindex 34d1aa422..577cfb3e9 100644--- a/backend/internal/services/oidc_service.go+++ b/backend/internal/services/oidc_service.go@@ -22,8 +22,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/config""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/crypto"- "github.com/getarcaneapp/arcane/backend/internal/utils/stringutils"+ "github.com/getarcaneapp/arcane/backend/pkg/utils"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/jwtclaims""github.com/getarcaneapp/arcane/types/auth")@@ -189,9 +189,9 @@ func (s *OidcService) GenerateAuthURL(ctx context.Context, redirectTo string, or}}- state := stringutils.GenerateRandomString(32)- nonce := stringutils.GenerateRandomString(32)- codeVerifier := stringutils.GenerateRandomString(128)+ state := utils.GenerateRandomString(32)+ nonce := utils.GenerateRandomString(32)+ codeVerifier := utils.GenerateRandomString(128)oauth2Config, err := s.getOauth2Config(config, provider, origin)if err != nil {@@ -545,7 +545,7 @@ func (s *OidcService) buildUserInfo(ctx context.Context, provider *oidc.Providerreturn nil, nil, fmt.Errorf("failed to fetch user claims: %w", err)}- subject := crypto.GetStringClaim(claims, "sub")+ subject := jwtclaims.GetStringClaim(claims, "sub")if subject == "" {slog.Error("HandleCallback: missing required 'sub' claim")return nil, nil, errors.New("missing required 'sub' claim in user info")@@ -553,15 +553,15 @@ func (s *OidcService) buildUserInfo(ctx context.Context, provider *oidc.ProvideruserInfoDto := auth.OidcUserInfo{Subject: subject,- Name: crypto.GetStringClaim(claims, "name"),- Email: crypto.GetStringClaim(claims, "email"),- EmailVerified: crypto.GetBoolClaim(claims, "email_verified"),- PreferredUsername: crypto.GetStringClaim(claims, "preferred_username"),- GivenName: crypto.GetStringClaim(claims, "given_name"),- FamilyName: crypto.GetStringClaim(claims, "family_name"),- Admin: crypto.GetBoolClaim(claims, "admin"),- Roles: crypto.GetStringSliceClaim(claims, "roles"),- Groups: crypto.GetStringSliceClaim(claims, "groups"),+ Name: jwtclaims.GetStringClaim(claims, "name"),+ Email: jwtclaims.GetStringClaim(claims, "email"),+ EmailVerified: jwtclaims.GetBoolClaim(claims, "email_verified"),+ PreferredUsername: jwtclaims.GetStringClaim(claims, "preferred_username"),+ GivenName: jwtclaims.GetStringClaim(claims, "given_name"),+ FamilyName: jwtclaims.GetStringClaim(claims, "family_name"),+ Admin: jwtclaims.GetBoolClaim(claims, "admin"),+ Roles: jwtclaims.GetStringSliceClaim(claims, "roles"),+ Groups: jwtclaims.GetStringSliceClaim(claims, "groups"),Extra: claims,}@@ -780,7 +780,7 @@ func (s *OidcService) ExchangeDeviceToken(ctx context.Context, deviceCode stringtoken := &oauth2.Token{AccessToken: accessToken,- TokenType: stringutils.GetStringOrDefault(tokenResp, "token_type", "Bearer"),+ TokenType: utils.GetStringOrDefault(tokenResp, "token_type", "Bearer"),}if refreshToken, ok := tokenResp["refresh_token"].(string); ok {token.RefreshToken = refreshTokendiff --git a/backend/internal/services/playwright_service.go b/backend/internal/services/playwright_service.goindex be40ea5ce..64bac28b4 100644--- a/backend/internal/services/playwright_service.go+++ b/backend/internal/services/playwright_service.go@@ -7,7 +7,7 @@ import ("fmt""log/slog"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/types/apikey")diff --git a/backend/internal/services/project_service.go b/backend/internal/services/project_service.goindex 89954aaf9..330b980b6 100644--- a/backend/internal/services/project_service.go+++ b/backend/internal/services/project_service.go@@ -19,15 +19,13 @@ import ("github.com/getarcaneapp/arcane/backend/internal/common""github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils"- "github.com/getarcaneapp/arcane/backend/internal/utils/docker"- "github.com/getarcaneapp/arcane/backend/internal/utils/fs"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"- "github.com/getarcaneapp/arcane/backend/internal/utils/pathmapper"- "github.com/getarcaneapp/arcane/backend/internal/utils/timeouts"+ dockerutil "github.com/getarcaneapp/arcane/backend/pkg/dockerutil"libbuild "github.com/getarcaneapp/arcane/backend/pkg/libarcane/libbuild"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/backend/pkg/projects"+ "github.com/getarcaneapp/arcane/backend/pkg/utils"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types""github.com/getarcaneapp/arcane/types/containerregistry"imagetypes "github.com/getarcaneapp/arcane/types/image"@@ -56,7 +54,7 @@ func NewProjectService(db *database.DB, settingsService *SettingsService, eventS}}-func (s *ProjectService) getPathMapper(ctx context.Context) (*pathmapper.PathMapper, error) {+func (s *ProjectService) getPathMapper(ctx context.Context) (*projects.PathMapper, error) {configuredPath := s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects")var containerDir, hostDir string@@ -64,7 +62,7 @@ func (s *ProjectService) getPathMapper(ctx context.Context) (*pathmapper.PathMap// Handle mapping format: "container_path:host_path"if parts := strings.SplitN(configuredPath, ":", 2); len(parts) == 2 {// Only treat as mapping if first part is absolute Linux path (not Windows drive)- if !pathmapper.IsWindowsDrivePath(configuredPath) && strings.HasPrefix(parts[0], "/") {+ if !projects.IsWindowsDrivePath(configuredPath) && strings.HasPrefix(parts[0], "/") {containerDir = parts[0]hostDir = parts[1]}@@ -75,7 +73,7 @@ func (s *ProjectService) getPathMapper(ctx context.Context) (*pathmapper.PathMap}// Resolve container directory to absolute path- containerDirResolved, err := fs.GetProjectsDirectory(ctx, strings.TrimSpace(containerDir))+ containerDirResolved, err := projects.GetProjectsDirectory(ctx, strings.TrimSpace(containerDir))if err != nil {slog.WarnContext(ctx, "unable to resolve container projects directory, using default", "error", err)containerDirResolved = "/app/data/projects"@@ -85,7 +83,7 @@ func (s *ProjectService) getPathMapper(ctx context.Context) (*pathmapper.PathMapif hostDir == "" && s.dockerService != nil {if dockerCli, derr := s.dockerService.GetClient(ctx); derr == nil {absContainerDir, _ := filepath.Abs(containerDirResolved)- if discovery, aerr := docker.GetHostPathForContainerPath(ctx, dockerCli, absContainerDir); aerr == nil && discovery != "" {+ if discovery, aerr := dockerutil.GetHostPathForContainerPath(ctx, dockerCli, absContainerDir); aerr == nil && discovery != "" {hostDir = discoveryslog.DebugContext(ctx, "Auto-discovered host path for projects", "container", absContainerDir, "host", hostDir)}@@ -98,7 +96,7 @@ func (s *ProjectService) getPathMapper(ctx context.Context) (*pathmapper.PathMaphostDirResolved = filepath.Clean(hostDirResolved)}- pm := pathmapper.NewPathMapper(containerDirResolved, hostDirResolved)+ pm := projects.NewPathMapper(containerDirResolved, hostDirResolved)if !pm.IsNonMatchingMount() {return nil, nil}@@ -279,7 +277,7 @@ func (s *ProjectService) GetProjectServices(ctx context.Context, projectID strin// Get configured projects directory from settingsprojectsDirSetting := s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects")- projectsDirectory, pdErr := fs.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))+ projectsDirectory, pdErr := projects.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))if pdErr != nil {slog.WarnContext(ctx, "unable to determine projects directory; using default", "error", pdErr)projectsDirectory = "/app/data/projects"@@ -362,7 +360,7 @@ func (s *ProjectService) GetProjectContent(ctx context.Context, projectID stringif err != nil {return "", "", err}- return fs.ReadProjectFiles(proj.Path)+ return projects.ReadProjectFiles(proj.Path)}func (s *ProjectService) GetProjectDetails(ctx context.Context, projectID string) (project.Details, error) {@@ -475,7 +473,7 @@ func (s *ProjectService) enrichWithGitOpsInfo(ctx context.Context, proj *models.func (s *ProjectService) enrichWithComposeServiceConfigs(ctx context.Context, proj *models.Project, composeFile string, resp *project.Details) {projectsDirSetting := s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects")- projectsDirectory, _ := fs.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))+ projectsDirectory, _ := projects.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))pathMapper, pmErr := s.getPathMapper(ctx)if pmErr != nil {@@ -508,7 +506,7 @@ func (s *ProjectService) enrichWithComposeServiceConfigs(ctx context.Context, prfunc (s *ProjectService) SyncProjectsFromFileSystem(ctx context.Context) error {projectsDirSetting := s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects")- projectsDir, err := fs.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))+ projectsDir, err := projects.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))if err != nil {slog.WarnContext(ctx, "unable to prepare projects directory", "error", err)return nil@@ -668,7 +666,7 @@ func formatDockerPorts(ports []container.PortSummary) []string {func (s *ProjectService) countProjectFolders(ctx context.Context) (int, error) {projectsDirSetting := s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects")- projectsDir, err := fs.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))+ projectsDir, err := projects.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))if err != nil {return 0, fmt.Errorf("could not determine projects directory: %w", err)}@@ -826,7 +824,7 @@ func (s *ProjectService) DeployProject(ctx context.Context, projectID string, us// Get configured projects directory from settingsprojectsDirSetting := s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects")- projectsDirectory, pdErr := fs.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))+ projectsDirectory, pdErr := projects.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))if pdErr != nil {slog.WarnContext(ctx, "unable to determine projects directory; using default", "error", pdErr)projectsDirectory = "/app/data/projects"@@ -893,7 +891,7 @@ func (s *ProjectService) DownProject(ctx context.Context, projectID string, user// Get configured projects directory from settingsprojectsDirSetting := s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects")- projectsDirectory, pdErr := fs.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))+ projectsDirectory, pdErr := projects.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))if pdErr != nil {slog.WarnContext(ctx, "unable to determine projects directory; using default", "error", pdErr)projectsDirectory = "/app/data/projects"@@ -933,15 +931,15 @@ func (s *ProjectService) DownProject(ctx context.Context, projectID string, user}func (s *ProjectService) CreateProject(ctx context.Context, name, composeContent string, envContent *string, user models.User) (*models.Project, error) {- sanitized := fs.SanitizeProjectName(name)+ sanitized := projects.SanitizeProjectName(name)- projectsDirectory, err := fs.GetProjectsDirectory(ctx, s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects"))+ projectsDirectory, err := projects.GetProjectsDirectory(ctx, s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects"))if err != nil {return nil, fmt.Errorf("failed to get projects directory: %w", err)}basePath := filepath.Join(projectsDirectory, sanitized)- projectPath, folderName, err := fs.CreateUniqueDir(projectsDirectory, basePath, name, common.DirPerm)+ projectPath, folderName, err := projects.CreateUniqueDir(projectsDirectory, basePath, name, common.DirPerm)if err != nil {return nil, fmt.Errorf("failed to create project directory: %w", err)}@@ -959,7 +957,7 @@ func (s *ProjectService) CreateProject(ctx context.Context, name, composeContentreturn nil, fmt.Errorf("failed to create project: %w", err)}- if err := fs.SaveOrUpdateProjectFiles(projectsDirectory, projectPath, composeContent, envContent); err != nil {+ if err := projects.SaveOrUpdateProjectFiles(projectsDirectory, projectPath, composeContent, envContent); err != nil {// Best-effort cleanup to restore pre-transaction behavior._ = s.db.WithContext(ctx).Delete(proj).Errorreturn nil, fmt.Errorf("failed to save project files: %w", err)@@ -997,7 +995,7 @@ func (s *ProjectService) DestroyProject(ctx context.Context, projectID string, rif removeVolumes {// Get configured projects directory from settingsprojectsDirSetting := s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects")- projectsDirectory, pdErr := fs.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))+ projectsDirectory, pdErr := projects.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))if pdErr != nil {slog.WarnContext(ctx, "unable to determine projects directory; using default", "error", pdErr)projectsDirectory = "/app/data/projects"@@ -1067,7 +1065,7 @@ func (s *ProjectService) PullProjectImages(ctx context.Context, projectID string// Get configured projects directory from settingsprojectsDirSetting := s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects")- projectsDirectory, pdErr := fs.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))+ projectsDirectory, pdErr := projects.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))if pdErr != nil {slog.WarnContext(ctx, "unable to determine projects directory; using default", "error", pdErr)projectsDirectory = "/app/data/projects"@@ -1126,7 +1124,7 @@ func (s *ProjectService) BuildProjectServices(ctx context.Context, projectID str}projectsDirSetting := s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects")- projectsDirectory, pdErr := fs.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))+ projectsDirectory, pdErr := projects.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))if pdErr != nil {slog.WarnContext(ctx, "unable to determine projects directory; using default", "error", pdErr)projectsDirectory = "/app/data/projects"@@ -1159,7 +1157,7 @@ func (s *ProjectService) EnsureProjectImagesPresent(ctx context.Context, project// Get configured projects directory from settingsprojectsDirSetting := s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects")- projectsDirectory, pdErr := fs.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))+ projectsDirectory, pdErr := projects.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))if pdErr != nil {slog.WarnContext(ctx, "unable to determine projects directory; using default", "error", pdErr)projectsDirectory = "/app/data/projects"@@ -1305,7 +1303,7 @@ func (s *ProjectService) ensureDeployServiceImageReady(progressWriter io.Writer,credentials []containerregistry.Credential,user *models.User,- pathMapper *pathmapper.PathMapper,+ pathMapper *projects.PathMapper,) error {if decision.Build {return s.buildServiceImageForDeploy(ctx, projectID, project, serviceName, svc, progressWriter, user, pathMapper)@@ -1345,7 +1343,7 @@ func (s *ProjectService) buildServiceImageForDeploy(svc composetypes.ServiceConfig,progressWriter io.Writer,user *models.User,- pathMapper *pathmapper.PathMapper,+ pathMapper *projects.PathMapper,) error {if s.buildService == nil {return fmt.Errorf("build service not available for service %s", serviceName)@@ -1600,7 +1598,7 @@ func (s *ProjectService) prepareServiceBuildRequest(serviceName string,svc composetypes.ServiceConfig,options ProjectBuildOptions,- pathMapper *pathmapper.PathMapper,+ pathMapper *projects.PathMapper,) (imagetypes.BuildRequest, composetypes.ServiceConfig, bool, error) {_ = ctximageName, updatedSvc, updated := ensureServiceImage(projectID, project.Name, serviceName, svc)@@ -1783,7 +1781,7 @@ func (s *ProjectService) RestartProject(ctx context.Context, projectID string, u// Get configured projects directory from settingsprojectsDirSetting := s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects")- projectsDirectory, pdErr := fs.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))+ projectsDirectory, pdErr := projects.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))if pdErr != nil {slog.WarnContext(ctx, "unable to determine projects directory; using default", "error", pdErr)projectsDirectory = "/app/data/projects"@@ -1873,7 +1871,7 @@ func (s *ProjectService) ApplyGitSyncProjectFiles(ctx context.Context, projectIDreturn nil, fmt.Errorf("invalid compose file: %w", err)}- if err := fs.WriteComposeFile(projectsDirectory, proj.Path, composeContent); err != nil {+ if err := projects.WriteComposeFile(projectsDirectory, proj.Path, composeContent); err != nil {return nil, fmt.Errorf("failed to save compose file: %w", err)}if err := s.persistGitSyncEnvFilesInternal(proj.Path, projectsDirectory, envUpdate); err != nil {@@ -1909,7 +1907,7 @@ func (s *ProjectService) getProjectForUpdate(ctx context.Context, projectID strireturn models.Project{}, "", fmt.Errorf("failed to get project: %w", err)}- projectsDirectory, err := fs.GetProjectsDirectory(ctx, s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects"))+ projectsDirectory, err := projects.GetProjectsDirectory(ctx, s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects"))if err != nil {return models.Project{}, "", fmt.Errorf("failed to get projects directory: %w", err)}@@ -1950,7 +1948,7 @@ func (s *ProjectService) persistUpdatedProjectFiles(ctx context.Context, proj *mif err := s.validateComposeContentForUpdate(ctx, proj.Path, proj.Name, *composeContent, effectiveEnvContent); err != nil {return fmt.Errorf("invalid compose file: %w", err)}- if err := fs.WriteComposeFile(projectsDirectory, proj.Path, *composeContent); err != nil {+ if err := projects.WriteComposeFile(projectsDirectory, proj.Path, *composeContent); err != nil {return fmt.Errorf("failed to save project files: %w", err)}if envContent != nil {@@ -2036,7 +2034,7 @@ func withTransientValidationEnvFile(projectPath string, effectiveEnvContent *strif effectiveEnvContent != nil {content = *effectiveEnvContent}- if writeErr := fs.WriteEnvFile(projectPath, projectPath, content); writeErr != nil {+ if writeErr := projects.WriteEnvFile(projectPath, projectPath, content); writeErr != nil {return fmt.Errorf("prepare env file for compose validation: %w", writeErr)}@@ -2044,7 +2042,7 @@ func withTransientValidationEnvFile(projectPath string, effectiveEnvContent *strvar restoreErr errorswitch {case originalExists:- restoreErr = fs.WriteEnvFile(projectPath, projectPath, string(originalContent))+ restoreErr = projects.WriteEnvFile(projectPath, projectPath, string(originalContent))case effectiveEnvContent != nil:restoreErr = os.Remove(envPath)default:@@ -2109,11 +2107,11 @@ func (s *ProjectService) persistEffectiveEnvContentInternal(projectPath, projectif !state.HasGitSource {if state.HasOverride {- if err := fs.RemoveProjectFile(projectsDirectory, projectPath, projects.OverrideEnvFileName); err != nil {+ if err := projects.RemoveProjectFile(projectsDirectory, projectPath, projects.OverrideEnvFileName); err != nil {return err}}- return fs.WriteEnvFile(projectsDirectory, projectPath, envContent)+ return projects.WriteEnvFile(projectsDirectory, projectPath, envContent)}overrideContent, err := projects.BuildOverrideEnvContent(state.GitContent, envContent)@@ -2126,15 +2124,15 @@ func (s *ProjectService) persistEffectiveEnvContentInternal(projectPath, projectreturn fmt.Errorf("build effective env content: %w", err)}- if err := fs.WriteEnvFile(projectsDirectory, projectPath, effectiveContent); err != nil {+ if err := projects.WriteEnvFile(projectsDirectory, projectPath, effectiveContent); err != nil {return err}if strings.TrimSpace(overrideContent) == "" {- if err := fs.RemoveProjectFile(projectsDirectory, projectPath, projects.OverrideEnvFileName); err != nil {+ if err := projects.RemoveProjectFile(projectsDirectory, projectPath, projects.OverrideEnvFileName); err != nil {return err}- } else if err := fs.WriteProjectFile(projectsDirectory, projectPath, projects.OverrideEnvFileName, overrideContent); err != nil {+ } else if err := projects.WriteProjectFile(projectsDirectory, projectPath, projects.OverrideEnvFileName, overrideContent); err != nil {return err}@@ -2149,16 +2147,16 @@ func (s *ProjectService) ensureEffectiveEnvFileInternal(projectPath, projectsDirif !state.HasGitSource {if state.HasOverride {- if err := fs.RemoveProjectFile(projectsDirectory, projectPath, projects.OverrideEnvFileName); err != nil {+ if err := projects.RemoveProjectFile(projectsDirectory, projectPath, projects.OverrideEnvFileName); err != nil {return err}effectiveContent, err := s.resolveStoredEffectiveEnvContentInternal(state)if err != nil {return err}- return fs.WriteEnvFile(projectsDirectory, projectPath, effectiveContent)+ return projects.WriteEnvFile(projectsDirectory, projectPath, effectiveContent)}- return fs.EnsureEnvFile(projectsDirectory, projectPath)+ return projects.EnsureEnvFile(projectsDirectory, projectPath)}effectiveContent, err := projects.BuildEffectiveEnvContent(state.GitContent, state.OverrideContent)@@ -2166,7 +2164,7 @@ func (s *ProjectService) ensureEffectiveEnvFileInternal(projectPath, projectsDirreturn fmt.Errorf("build effective env content: %w", err)}- return fs.WriteEnvFile(projectsDirectory, projectPath, effectiveContent)+ return projects.WriteEnvFile(projectsDirectory, projectPath, effectiveContent)}type gitSyncEnvUpdateInternal struct {@@ -2246,12 +2244,12 @@ func (s *ProjectService) resolveOverrideContentForGitSyncInternal(state projectsfunc (s *ProjectService) persistGitSyncEnvFilesInternal(projectPath, projectsDirectory string, update gitSyncEnvUpdateInternal) error {if update.gitEnvContent == nil {if update.state.HasGitSource {- if err := fs.RemoveProjectFile(projectsDirectory, projectPath, projects.GitSourceEnvFileName); err != nil {+ if err := projects.RemoveProjectFile(projectsDirectory, projectPath, projects.GitSourceEnvFileName); err != nil {return err}}if update.state.HasOverride {- if err := fs.RemoveProjectFile(projectsDirectory, projectPath, projects.OverrideEnvFileName); err != nil {+ if err := projects.RemoveProjectFile(projectsDirectory, projectPath, projects.OverrideEnvFileName); err != nil {return err}}@@ -2260,26 +2258,26 @@ func (s *ProjectService) persistGitSyncEnvFilesInternal(projectPath, projectsDirif update.effectiveContent != nil {effectiveContent = *update.effectiveContent}- return fs.WriteEnvFile(projectsDirectory, projectPath, effectiveContent)+ return projects.WriteEnvFile(projectsDirectory, projectPath, effectiveContent)}- return fs.EnsureEnvFile(projectsDirectory, projectPath)+ return projects.EnsureEnvFile(projectsDirectory, projectPath)}if update.effectiveContent == nil {return fmt.Errorf("missing effective env content for git sync update")}- if err := fs.WriteEnvFile(projectsDirectory, projectPath, *update.effectiveContent); err != nil {+ if err := projects.WriteEnvFile(projectsDirectory, projectPath, *update.effectiveContent); err != nil {return err}- if err := fs.WriteProjectFile(projectsDirectory, projectPath, projects.GitSourceEnvFileName, *update.gitEnvContent); err != nil {+ if err := projects.WriteProjectFile(projectsDirectory, projectPath, projects.GitSourceEnvFileName, *update.gitEnvContent); err != nil {return err}if strings.TrimSpace(update.overrideContent) == "" {- if err := fs.RemoveProjectFile(projectsDirectory, projectPath, projects.OverrideEnvFileName); err != nil {+ if err := projects.RemoveProjectFile(projectsDirectory, projectPath, projects.OverrideEnvFileName); err != nil {return err}- } else if err := fs.WriteProjectFile(projectsDirectory, projectPath, projects.OverrideEnvFileName, update.overrideContent); err != nil {+ } else if err := projects.WriteProjectFile(projectsDirectory, projectPath, projects.OverrideEnvFileName, update.overrideContent); err != nil {return err}@@ -2300,7 +2298,7 @@ func (s *ProjectService) applyProjectRenameIfNeeded(proj *models.Project, name *return fmt.Errorf("project must be stopped before renaming (current status: %s)", proj.Status)}- newDirName := fs.SanitizeProjectName(newName)+ newDirName := projects.SanitizeProjectName(newName)if newDirName == "" || strings.Trim(newDirName, "_") == "" {return fmt.Errorf("invalid project name: results in empty directory name")}@@ -2359,7 +2357,7 @@ func (s *ProjectService) UpdateProjectIncludeFile(ctx context.Context, projectID// If not, it normalizes the path to `<projectsRoot>/<dirName or sanitized project name>`. When persist=true, it saves// the updated project path to the database.func (s *ProjectService) ensureProjectPathUnderRoot(ctx context.Context, proj *models.Project, persist bool) error {- projectsDirectory, err := fs.GetProjectsDirectory(ctx, s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects"))+ projectsDirectory, err := projects.GetProjectsDirectory(ctx, s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects"))if err != nil {return fmt.Errorf("failed to get projects directory: %w", err)}@@ -2372,14 +2370,14 @@ func (s *ProjectService) ensureProjectPathUnderRoot(ctx context.Context, proj *mprojPathAbs = filepath.Clean(abs)}- if fs.IsSafeSubdirectory(rootAbs, projPathAbs) {+ if projects.IsSafeSubdirectory(rootAbs, projPathAbs) {return nil}// Attempt to repair using known directory name or sanitized project namedirName := utils.DerefString(proj.DirName)if strings.TrimSpace(dirName) == "" {- dirName = fs.SanitizeProjectName(proj.Name)+ dirName = projects.SanitizeProjectName(proj.Name)}candidate := filepath.Join(projectsDirectory, dirName)@@ -2732,7 +2730,7 @@ func (s *ProjectService) getProjectMetadataFromPath(ctx context.Context, projectfunc (s *ProjectService) countServicesFromCompose(ctx context.Context, p models.Project) (int, error) {projectsDirSetting := s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects")- projectsDirectory, err := fs.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))+ projectsDirectory, err := projects.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))if err != nil {return 0, err}diff --git a/backend/internal/services/project_service_test.go b/backend/internal/services/project_service_test.goindex a0a0b9ddf..9d0bbe2d2 100644--- a/backend/internal/services/project_service_test.go+++ b/backend/internal/services/project_service_test.go@@ -10,7 +10,7 @@ import ("time"composetypes "github.com/compose-spec/compose-go/v2/types"- "github.com/getarcaneapp/arcane/backend/internal/utils/pathmapper"+ "github.com/getarcaneapp/arcane/backend/pkg/projects"buildtypes "github.com/getarcaneapp/arcane/types/builds"imagetypes "github.com/getarcaneapp/arcane/types/image"glsqlite "github.com/glebarez/sqlite"@@ -1186,7 +1186,7 @@ func TestProjectService_PrepareServiceBuildRequest_MapsComposeFields(t *testing.func TestProjectService_PrepareServiceBuildRequest_UsesExecutorVisiblePaths(t *testing.T) {svc := &ProjectService{}proj := &composetypes.Project{WorkingDir: "/app/data/projects/demo", Name: "demo"}- pm := pathmapper.NewPathMapper("/app/data/projects", "/docker-data/arcane/projects")+ pm := projects.NewPathMapper("/app/data/projects", "/docker-data/arcane/projects")serviceCfg := composetypes.ServiceConfig{Name: "web",diff --git a/backend/internal/services/settings_search_service.go b/backend/internal/services/settings_search_service.goindex 1fa4b309f..feb14850d 100644--- a/backend/internal/services/settings_search_service.go+++ b/backend/internal/services/settings_search_service.go@@ -7,7 +7,7 @@ import ("sync""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils"+ "github.com/getarcaneapp/arcane/backend/pkg/utils""github.com/getarcaneapp/arcane/types/category""github.com/getarcaneapp/arcane/types/meta""github.com/getarcaneapp/arcane/types/search"diff --git a/backend/internal/services/settings_service.go b/backend/internal/services/settings_service.goindex 5e41ec087..64c9a071a 100644--- a/backend/internal/services/settings_service.go+++ b/backend/internal/services/settings_service.go@@ -23,9 +23,9 @@ import ("github.com/getarcaneapp/arcane/backend/internal/config""github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/pathmapper"- "github.com/getarcaneapp/arcane/backend/internal/utils/stringutils""github.com/getarcaneapp/arcane/backend/pkg/libarcane"+ "github.com/getarcaneapp/arcane/backend/pkg/projects"+ "github.com/getarcaneapp/arcane/backend/pkg/utils""github.com/getarcaneapp/arcane/types/settings")@@ -233,7 +233,7 @@ func (s *SettingsService) loadDatabaseConfigFromEnv(ctx context.Context, db *datcontinue}- envVarName := stringutils.CamelCaseToScreamingSnakeCase(key)+ envVarName := utils.CamelCaseToScreamingSnakeCase(key)// debug: log each env name checked and whether a value existsif val, ok := os.LookupEnv(envVarName); ok {@@ -242,7 +242,7 @@ func (s *SettingsService) loadDatabaseConfigFromEnv(ctx context.Context, db *datmask = fmt.Sprintf("%d chars", len(val))}slog.DebugContext(ctx, "loadDatabaseConfigFromEnv: env override found", "key", key, "env", envVarName, "valueMasked", mask)- rv.Field(i).FieldByName("Value").SetString(stringutils.TrimQuotes(val))+ rv.Field(i).FieldByName("Value").SetString(utils.TrimQuotes(val))continue} else if val, ok := settingsMap[key]; ok {// Fallback to database if environment variable is not set@@ -288,10 +288,10 @@ func (s *SettingsService) applyEnvOverrides(ctx context.Context, dest *models.Se}// Check if environment variable is set- envVarName := stringutils.CamelCaseToScreamingSnakeCase(key)+ envVarName := utils.CamelCaseToScreamingSnakeCase(key)if val, ok := os.LookupEnv(envVarName); ok && val != "" {slog.DebugContext(ctx, "applyEnvOverrides: applying env override", "key", key, "env", envVarName)- rv.Field(i).FieldByName("Value").SetString(stringutils.TrimQuotes(val))+ rv.Field(i).FieldByName("Value").SetString(utils.TrimQuotes(val))}}}@@ -315,7 +315,7 @@ func (s *SettingsService) isEnvOverrideActiveInternal(key string) bool {return false}- envVarName := stringutils.CamelCaseToScreamingSnakeCase(key)+ envVarName := utils.CamelCaseToScreamingSnakeCase(key)val, ok := os.LookupEnv(envVarName)return ok && val != ""}@@ -785,12 +785,12 @@ func (s *SettingsService) processEnvField(ctx context.Context, tx *gorm.DB, fielreturn nil}- envVarName := stringutils.CamelCaseToScreamingSnakeCase(key)+ envVarName := utils.CamelCaseToScreamingSnakeCase(key)envVal, ok := os.LookupEnv(envVarName)if !ok {return nil}- envVal = stringutils.TrimQuotes(envVal)+ envVal = utils.TrimQuotes(envVal)return s.upsertEnvSetting(ctx, tx, key, envVal)}@@ -1018,7 +1018,7 @@ func (s *SettingsService) NormalizeProjectsDirectory(ctx context.Context, projec// Treat as mapping if the container side looks like an absolute Unix path// or a Windows drive path (C:/ or C:\). We purposely avoid splitting on the// first colon to not break on Windows drive letters.- if strings.HasPrefix(value, "/") || pathmapper.IsWindowsDrivePath(value) {+ if strings.HasPrefix(value, "/") || projects.IsWindowsDrivePath(value) {isMapping = true}}@@ -1051,7 +1051,7 @@ func (s *SettingsService) NormalizeProjectsDirectory(ctx context.Context, projecfunc (s *SettingsService) NormalizeBuildsDirectory(ctx context.Context) error {const buildsKey = "buildsDirectory"- envVarName := stringutils.CamelCaseToScreamingSnakeCase(buildsKey)+ envVarName := utils.CamelCaseToScreamingSnakeCase(buildsKey)if envVal, ok := os.LookupEnv(envVarName); ok && strings.TrimSpace(envVal) != "" {slog.DebugContext(ctx, "BUILDS_DIRECTORY environment variable is set, skipping normalization", "value", envVal)return nildiff --git a/backend/internal/services/system_service.go b/backend/internal/services/system_service.goindex 4532ab3a1..6119499c8 100644--- a/backend/internal/services/system_service.go+++ b/backend/internal/services/system_service.go@@ -10,7 +10,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/converter"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/dockerrun"libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"containertypes "github.com/getarcaneapp/arcane/types/container""github.com/getarcaneapp/arcane/types/system"@@ -392,7 +392,7 @@ func (s *SystemService) pruneNetworks(ctx context.Context, result *system.PruneAreturn nil}-func (s *SystemService) ParseDockerRunCommand(command string) (*models.DockerRunCommand, error) {+func (s *SystemService) ParseDockerRunCommand(command string) (*system.DockerRunCommand, error) {if command == "" {return nil, fmt.Errorf("docker run command must be a non-empty string")}@@ -404,8 +404,8 @@ func (s *SystemService) ParseDockerRunCommand(command string) (*models.DockerRunreturn nil, fmt.Errorf("no arguments found after 'docker run'")}- result := &models.DockerRunCommand{}- tokens, err := converter.ParseCommandTokens(cmd)+ result := &system.DockerRunCommand{}+ tokens, err := dockerrun.ParseCommandTokens(cmd)if err != nil {return nil, fmt.Errorf("failed to parse command tokens: %w", err)}@@ -414,7 +414,7 @@ func (s *SystemService) ParseDockerRunCommand(command string) (*models.DockerRunreturn nil, fmt.Errorf("no valid tokens found in docker run command")}- if err := converter.ParseTokens(tokens, result); err != nil {+ if err := dockerrun.ParseTokens(tokens, result); err != nil {return nil, err}@@ -425,7 +425,7 @@ func (s *SystemService) ParseDockerRunCommand(command string) (*models.DockerRunreturn result, nil}-func (s *SystemService) ConvertToDockerCompose(parsed *models.DockerRunCommand) (string, string, string, error) {+func (s *SystemService) ConvertToDockerCompose(parsed *system.DockerRunCommand) (string, string, string, error) {if parsed.Image == "" {return "", "", "", fmt.Errorf("cannot convert to Docker Compose: no image specified")}@@ -435,7 +435,7 @@ func (s *SystemService) ConvertToDockerCompose(parsed *models.DockerRunCommand)serviceName = "app"}- service := models.DockerComposeService{+ service := system.DockerComposeService{Image: parsed.Image,}@@ -493,15 +493,15 @@ func (s *SystemService) ConvertToDockerCompose(parsed *models.DockerRunCommand)}if parsed.HealthCheck != "" {- service.Healthcheck = &models.DockerComposeHealthcheck{+ service.Healthcheck = &system.DockerComposeHealthcheck{Test: parsed.HealthCheck,}}if parsed.MemoryLimit != "" || parsed.CPULimit != "" {- service.Deploy = &models.DockerComposeDeploy{- Resources: &models.DockerComposeResources{- Limits: &models.DockerComposeResourceLimits{},+ service.Deploy = &system.DockerComposeDeploy{+ Resources: &system.DockerComposeResources{+ Limits: &system.DockerComposeResourceLimits{},},}if parsed.MemoryLimit != "" {@@ -512,8 +512,8 @@ func (s *SystemService) ConvertToDockerCompose(parsed *models.DockerRunCommand)}}- compose := models.DockerComposeConfig{- Services: map[string]models.DockerComposeService{+ compose := system.DockerComposeConfig{+ Services: map[string]system.DockerComposeService{serviceName: service,},}diff --git a/backend/internal/services/system_upgrade_service.go b/backend/internal/services/system_upgrade_service.goindex 22ca47862..df4c3423d 100644--- a/backend/internal/services/system_upgrade_service.go+++ b/backend/internal/services/system_upgrade_service.go@@ -11,9 +11,9 @@ import ("time""github.com/getarcaneapp/arcane/backend/internal/models"- dockerutils "github.com/getarcaneapp/arcane/backend/internal/utils/docker"- "github.com/getarcaneapp/arcane/backend/internal/utils/timeouts"+ dockerutils "github.com/getarcaneapp/arcane/backend/pkg/dockerutil""github.com/getarcaneapp/arcane/backend/pkg/libarcane"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"containertypes "github.com/moby/moby/api/types/container"mounttypes "github.com/moby/moby/api/types/mount"diff --git a/backend/internal/services/template_service.go b/backend/internal/services/template_service.goindex 1c45b9d5d..f6ae63585 100644--- a/backend/internal/services/template_service.go+++ b/backend/internal/services/template_service.go@@ -20,11 +20,10 @@ import ("github.com/getarcaneapp/arcane/backend/internal/common""github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- appfs "github.com/getarcaneapp/arcane/backend/internal/utils/fs"- "github.com/getarcaneapp/arcane/backend/internal/utils/mapper"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"- templateutil "github.com/getarcaneapp/arcane/backend/internal/utils/template"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/projects""github.com/getarcaneapp/arcane/backend/pkg/utils"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/mapper""github.com/getarcaneapp/arcane/types/env"tmpl "github.com/getarcaneapp/arcane/types/template""github.com/google/uuid"@@ -78,7 +77,7 @@ func NewTemplateService(ctx context.Context, db *database.DB, httpClient *http.ChttpClient = http.DefaultClient}- if err := appfs.EnsureDefaultTemplates(ctx); err != nil {+ if err := projects.EnsureDefaultTemplates(ctx); err != nil {slog.WarnContext(ctx, "failed to ensure default templates", "error", err)}@@ -316,7 +315,7 @@ func (s *TemplateService) DeleteTemplate(ctx context.Context, id string) error {return fmt.Errorf("cannot delete remote template directly")}- baseDir, err := appfs.GetTemplatesDirectory(ctx)+ baseDir, err := projects.GetTemplatesDirectory(ctx)if err != nil {return fmt.Errorf("failed to get templates directory: %w", err)} else {@@ -352,7 +351,7 @@ func (s *TemplateService) GetComposeTemplate() string {func (s *TemplateService) SaveComposeTemplate(content string) error {templateDir := filepath.Join("data", "templates")composePath := filepath.Join(templateDir, ".compose.template")- return appfs.WriteTemplateFile(composePath, content)+ return projects.WriteTemplateFile(composePath, content)}func (s *TemplateService) GetEnvTemplate() string {@@ -368,7 +367,7 @@ func (s *TemplateService) GetEnvTemplate() string {func (s *TemplateService) SaveEnvTemplate(content string) error {templateDir := filepath.Join("data", "templates")envPath := filepath.Join(templateDir, ".env.template")- return appfs.WriteTemplateFile(envPath, content)+ return projects.WriteTemplateFile(envPath, content)}func (s *TemplateService) GetRegistries(ctx context.Context) ([]models.TemplateRegistry, error) {@@ -726,11 +725,11 @@ func (s *TemplateService) DownloadTemplate(ctx context.Context, remoteTemplate *base := s.templateBaseFromRemote(remoteTemplate)- dir, composePath, envPath, err := appfs.EnsureTemplateDir(ctx, base)+ dir, composePath, envPath, err := projects.EnsureTemplateDir(ctx, base)if err != nil {return nil, err}- srcDesc := appfs.ImportedComposeDescription(dir)+ srcDesc := projects.ImportedComposeDescription(dir)return s.downloadTemplateTransaction(ctx, remoteTemplate, base, composePath, envPath, srcDesc)}@@ -751,7 +750,7 @@ func (s *TemplateService) downloadTemplateTransaction(ctx context.Context, remotreturn fmt.Errorf("failed to fetch template content for existing local template: %w", err)}- envPtr, werr := appfs.WriteTemplateFiles(composePath, envPath, composeContent, envContent)+ envPtr, werr := projects.WriteTemplateFiles(composePath, envPath, composeContent, envContent)if werr != nil {return werr}@@ -773,7 +772,7 @@ func (s *TemplateService) downloadTemplateTransaction(ctx context.Context, remotreturn fmt.Errorf("failed to fetch template content for download: %w", err)}- envPtr, werr := appfs.WriteTemplateFiles(composePath, envPath, composeContent, envContent)+ envPtr, werr := projects.WriteTemplateFiles(composePath, envPath, composeContent, envContent)if werr != nil {return werr}@@ -804,13 +803,13 @@ func (s *TemplateService) downloadTemplateTransaction(ctx context.Context, remot}func (s *TemplateService) templateBaseFromRemote(remoteTemplate *models.ComposeTemplate) string {- base := appfs.Slugify(remoteTemplate.Name)+ base := projects.Slugify(remoteTemplate.Name)if base != "" {return base}parts := strings.Split(remoteTemplate.ID, ":")if len(parts) > 0 {- base = appfs.Slugify(parts[len(parts)-1])+ base = projects.Slugify(parts[len(parts)-1])}if base == "" {base = "template-" + uuid.NewString()@@ -917,7 +916,7 @@ func (s *TemplateService) upsertFilesystemTemplate(ctx context.Context, name, de}func (s *TemplateService) processFolderEntry(ctx context.Context, baseDir, folder string) error {- compose, envPtr, desc, found, err := appfs.ReadFolderComposeTemplate(baseDir, folder)+ compose, envPtr, desc, found, err := projects.ReadFolderComposeTemplate(baseDir, folder)if err != nil || !found {return err}@@ -932,7 +931,7 @@ func (s *TemplateService) syncFilesystemTemplatesInternal(ctx context.Context) ereturn nil}- dir, err := appfs.GetTemplatesDirectory(ctx)+ dir, err := projects.GetTemplatesDirectory(ctx)if err != nil {return fmt.Errorf("ensure templates dir: %w", err)}@@ -960,7 +959,7 @@ func (s *TemplateService) syncFilesystemTemplatesInternal(ctx context.Context) e}func (s *TemplateService) getGlobalVariablesPath(ctx context.Context) (string, error) {- projectsDirectory, err := appfs.GetProjectsDirectory(ctx, s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects"))+ projectsDirectory, err := projects.GetProjectsDirectory(ctx, s.settingsService.GetStringSetting(ctx, "projectsDirectory", "/app/data/projects"))if err != nil {return "", fmt.Errorf("failed to get projects directory: %w", err)}@@ -1059,7 +1058,7 @@ func (s *TemplateService) UpdateGlobalVariables(ctx context.Context, vars []env._, _ = fmt.Fprintf(&builder, "%s=%s\n", key, value)}- if err := appfs.WriteFileWithPerm(envPath, builder.String(), common.FilePerm); err != nil {+ if err := projects.WriteFileWithPerm(envPath, builder.String(), common.FilePerm); err != nil {return fmt.Errorf("failed to write global variables file: %w", err)}@@ -1086,7 +1085,7 @@ func (s *TemplateService) ParseComposeServices(ctx context.Context, composeConte// Create a dummy .env file to prevent env file errorsenvPath := filepath.Join(tmpDir, ".env")- if err := appfs.WriteFileWithPerm(envPath, "", common.FilePerm); err != nil {+ if err := projects.WriteFileWithPerm(envPath, "", common.FilePerm); err != nil {slog.WarnContext(ctx, "Failed to create dummy env file", "error", err)}@@ -1128,12 +1127,12 @@ func (s *TemplateService) resolveTemplateIconURL(ctx context.Context, composeCondefer func() { _ = os.RemoveAll(tmpDir) }()envPath := filepath.Join(tmpDir, ".env")- if err := appfs.WriteFileWithPerm(envPath, envContent, common.FilePerm); err != nil {+ if err := projects.WriteFileWithPerm(envPath, envContent, common.FilePerm); err != nil {slog.WarnContext(ctx, "failed to create temp env file for template icon parsing", "error", err)}envMap := make(composetypes.Mapping)- for _, variable := range templateutil.ParseEnvContent(envContent) {+ for _, variable := range projects.ParseEnvContent(envContent) {if key := strings.TrimSpace(variable.Key); key != "" {envMap[key] = variable.Value}@@ -1255,7 +1254,7 @@ func (s *TemplateService) GetTemplateContentWithParsedData(ctx context.Context,services := s.ParseComposeServices(ctx, composeContent)// Parse environment variables- parsedEnvVars := templateutil.ParseEnvContent(envContent)+ parsedEnvVars := projects.ParseEnvContent(envContent)envVars := make([]env.Variable, len(parsedEnvVars))for i, v := range parsedEnvVars {envVars[i] = env.Variable{Key: v.Key, Value: v.Value}diff --git a/backend/internal/services/updater_service.go b/backend/internal/services/updater_service.goindex 450ddbce9..a263c631f 100644--- a/backend/internal/services/updater_service.go+++ b/backend/internal/services/updater_service.go@@ -19,10 +19,10 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- arcRegistry "github.com/getarcaneapp/arcane/backend/internal/utils/registry""github.com/getarcaneapp/arcane/backend/pkg/libarcane"libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"projectspkg "github.com/getarcaneapp/arcane/backend/pkg/projects"+ arcRegistry "github.com/getarcaneapp/arcane/backend/pkg/utils/registry""github.com/getarcaneapp/arcane/types/updater")diff --git a/backend/internal/services/user_service.go b/backend/internal/services/user_service.goindex ccc3d3623..c35aca59d 100644--- a/backend/internal/services/user_service.go+++ b/backend/internal/services/user_service.go@@ -17,7 +17,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/types/user")diff --git a/backend/internal/services/user_service_test.go b/backend/internal/services/user_service_test.goindex e56fc8f1d..7d0e1da1d 100644--- a/backend/internal/services/user_service_test.go+++ b/backend/internal/services/user_service_test.go@@ -5,7 +5,7 @@ import ("testing""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/stretchr/testify/require")diff --git a/backend/internal/services/version_service.go b/backend/internal/services/version_service.goindex 84c44499a..185844967 100644--- a/backend/internal/services/version_service.go+++ b/backend/internal/services/version_service.go@@ -12,10 +12,10 @@ import ("github.com/getarcaneapp/arcane/backend/buildables""github.com/getarcaneapp/arcane/backend/internal/config"- "github.com/getarcaneapp/arcane/backend/internal/utils/cache"- "github.com/getarcaneapp/arcane/backend/internal/utils/docker"+ docker "github.com/getarcaneapp/arcane/backend/pkg/dockerutil""github.com/getarcaneapp/arcane/backend/pkg/libarcane"libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/cache""github.com/getarcaneapp/arcane/types/version"containertypes "github.com/moby/moby/api/types/container""github.com/moby/moby/client"diff --git a/backend/internal/services/volume_service.go b/backend/internal/services/volume_service.goindex bb287ce76..a0be8757c 100644--- a/backend/internal/services/volume_service.go+++ b/backend/internal/services/volume_service.go@@ -19,13 +19,13 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/docker"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"- "github.com/getarcaneapp/arcane/backend/internal/utils/timeouts"+ docker "github.com/getarcaneapp/arcane/backend/pkg/dockerutil""github.com/getarcaneapp/arcane/backend/pkg/libarcane"- "github.com/getarcaneapp/arcane/backend/pkg/utils/stdcopy"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"volumetypes "github.com/getarcaneapp/arcane/types/volume""github.com/google/uuid"+ "github.com/moby/moby/api/pkg/stdcopy""github.com/moby/moby/api/types/container""github.com/moby/moby/api/types/mount""github.com/moby/moby/api/types/volume"diff --git a/backend/internal/services/vulnerability_service.go b/backend/internal/services/vulnerability_service.goindex 7d2039fe0..2593e3698 100644--- a/backend/internal/services/vulnerability_service.go+++ b/backend/internal/services/vulnerability_service.go@@ -22,13 +22,13 @@ import (cerrdefs "github.com/containerd/errdefs""github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- dockerutils "github.com/getarcaneapp/arcane/backend/internal/utils/docker"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"- "github.com/getarcaneapp/arcane/backend/internal/utils/timeouts"+ dockerutils "github.com/getarcaneapp/arcane/backend/pkg/dockerutil""github.com/getarcaneapp/arcane/backend/pkg/libarcane"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"- "github.com/getarcaneapp/arcane/backend/pkg/utils/stdcopy"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/types/vulnerability"+ "github.com/moby/moby/api/pkg/stdcopy"containertypes "github.com/moby/moby/api/types/container"imagetypes "github.com/moby/moby/api/types/image"mounttypes "github.com/moby/moby/api/types/mount"diff --git a/backend/internal/services/vulnerability_service_test.go b/backend/internal/services/vulnerability_service_test.goindex 667e06120..71b95bd8f 100644--- a/backend/internal/services/vulnerability_service_test.go+++ b/backend/internal/services/vulnerability_service_test.go@@ -14,8 +14,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"- "github.com/getarcaneapp/arcane/backend/internal/utils/pagination"- "github.com/getarcaneapp/arcane/backend/internal/utils/timeouts"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"+ "github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/types/vulnerability"glsqlite "github.com/glebarez/sqlite"containertypes "github.com/moby/moby/api/types/container"diff --git a/backend/internal/utils/stringutils/stringutils.go b/backend/internal/utils/stringutils/stringutils.godeleted file mode 100644index 934716b69..000000000--- a/backend/internal/utils/stringutils/stringutils.go+++ /dev/null@@ -1,55 +0,0 @@-package stringutils--import (- "crypto/rand"- "encoding/base64"- "strings"-)--func CapitalizeFirstLetter(str string) string {- if len(str) == 0 {- return str- }- return strings.ToUpper(str[:1]) + str[1:]-}--func CamelCaseToSnakeCase(str string) string {- var result strings.Builder- for i, r := range str {- if i > 0 && r >= 'A' && r <= 'Z' {- result.WriteRune('_')- }- result.WriteRune(r)- }- return strings.ToLower(result.String())-}--func CamelCaseToScreamingSnakeCase(s string) string {- return strings.ToUpper(CamelCaseToSnakeCase(s))-}--func GenerateRandomString(length int) string {- bytes := make([]byte, length)- if _, err := rand.Read(bytes); err != nil {- panic(err)- }- return base64.URLEncoding.EncodeToString(bytes)[:length]-}--func TrimQuotes(s string) string {- if len(s) >= 2 {- if (s[0] == '"' && s[len(s)-1] == '"') || (s[0] == '\'' && s[len(s)-1] == '\'') {- return s[1 : len(s)-1]- }- }- return s-}--func GetStringOrDefault(m map[string]any, key, defaultValue string) string {- if val, ok := m[key]; ok {- if str, ok := val.(string); ok {- return str- }- }- return defaultValue-}diff --git a/backend/internal/utils/docker/cgroup_utils.go b/backend/pkg/dockerutil/cgroup_utils.gosimilarity index 100%rename from backend/internal/utils/docker/cgroup_utils.gorename to backend/pkg/dockerutil/cgroup_utils.godiff --git a/backend/internal/utils/docker/jsonstream.go b/backend/pkg/dockerutil/jsonstream.gosimilarity index 100%rename from backend/internal/utils/docker/jsonstream.gorename to backend/pkg/dockerutil/jsonstream.godiff --git a/backend/internal/utils/docker/jsonstream_test.go b/backend/pkg/dockerutil/jsonstream_test.gosimilarity index 100%rename from backend/internal/utils/docker/jsonstream_test.gorename to backend/pkg/dockerutil/jsonstream_test.godiff --git a/backend/internal/utils/docker/mount_utils.go b/backend/pkg/dockerutil/mount_utils.gosimilarity index 95%rename from backend/internal/utils/docker/mount_utils.gorename to backend/pkg/dockerutil/mount_utils.goindex 8aecda7c4..2605c770c 100644--- a/backend/internal/utils/docker/mount_utils.go+++ b/backend/pkg/dockerutil/mount_utils.go@@ -5,8 +5,8 @@ import ("os""strings"- "github.com/getarcaneapp/arcane/backend/internal/utils/pathmapper""github.com/getarcaneapp/arcane/backend/pkg/libarcane"+ "github.com/getarcaneapp/arcane/backend/pkg/projects"containertypes "github.com/moby/moby/api/types/container"mounttypes "github.com/moby/moby/api/types/mount""github.com/moby/moby/client"@@ -54,7 +54,7 @@ func GetHostPathForContainerPath(ctx context.Context, dockerCli *client.Client,if rel != "" {// Determine path separator from the host pathseparator := "/"- if pathmapper.IsWindowsDrivePath(hostPath) && strings.Contains(hostPath, "\\") {+ if projects.IsWindowsDrivePath(hostPath) && strings.Contains(hostPath, "\\") {separator = "\\"rel = strings.ReplaceAll(rel, "/", "\\")}diff --git a/backend/internal/utils/docker/mount_utils_test.go b/backend/pkg/dockerutil/mount_utils_test.gosimilarity index 100%rename from backend/internal/utils/docker/mount_utils_test.gorename to backend/pkg/dockerutil/mount_utils_test.godiff --git a/backend/internal/utils/docker/network_utils.go b/backend/pkg/dockerutil/network_utils.gosimilarity index 100%rename from backend/internal/utils/docker/network_utils.gorename to backend/pkg/dockerutil/network_utils.godiff --git a/backend/internal/utils/docker/volume_utils.go b/backend/pkg/dockerutil/volume_utils.gosimilarity index 100%rename from backend/internal/utils/docker/volume_utils.gorename to backend/pkg/dockerutil/volume_utils.godiff --git a/backend/internal/utils/fs/watcher.go b/backend/pkg/fswatch/watcher.gosimilarity index 99%rename from backend/internal/utils/fs/watcher.gorename to backend/pkg/fswatch/watcher.goindex d820a883a..1edf825c1 100644--- a/backend/internal/utils/fs/watcher.go+++ b/backend/pkg/fswatch/watcher.go@@ -1,4 +1,4 @@-package fs+package fswatchimport ("context"diff --git a/backend/internal/utils/git/git.go b/backend/pkg/gitutil/git.gosimilarity index 100%rename from backend/internal/utils/git/git.gorename to backend/pkg/gitutil/git.godiff --git a/backend/internal/utils/git/git_test.go b/backend/pkg/gitutil/git_test.gosimilarity index 100%rename from backend/internal/utils/git/git_test.gorename to backend/pkg/gitutil/git_test.godiff --git a/backend/internal/utils/crypto/encryption.go b/backend/pkg/libarcane/crypto/encryption.gosimilarity index 98%rename from backend/internal/utils/crypto/encryption.gorename to backend/pkg/libarcane/crypto/encryption.goindex 884ba64af..6987ed60a 100644--- a/backend/internal/utils/crypto/encryption.go+++ b/backend/pkg/libarcane/crypto/encryption.go@@ -13,14 +13,18 @@ import ("os""path/filepath""strings"-- "github.com/getarcaneapp/arcane/backend/internal/config")var encryptionKey []byte+type Config struct {+ EncryptionKey string+ Environment string+ AgentMode bool+}+// InitEncryption initializes the global encryption key based on configuration-func InitEncryption(cfg *config.Config) {+func InitEncryption(cfg *Config) {if keyStr := strings.TrimSpace(cfg.EncryptionKey); keyStr != "" {key, err := parseExplicitKey(keyStr)if err != nil {diff --git a/backend/internal/utils/crypto/encryption_test.go b/backend/pkg/libarcane/crypto/encryption_test.gosimilarity index 96%rename from backend/internal/utils/crypto/encryption_test.gorename to backend/pkg/libarcane/crypto/encryption_test.goindex 020c3ac1c..5152a3f04 100644--- a/backend/internal/utils/crypto/encryption_test.go+++ b/backend/pkg/libarcane/crypto/encryption_test.go@@ -4,7 +4,6 @@ import ("encoding/base64""testing"- "github.com/getarcaneapp/arcane/backend/internal/config""github.com/stretchr/testify/assert""github.com/stretchr/testify/require")@@ -115,7 +114,7 @@ func TestParseExplicitKey(t *testing.T) {func TestInitEncryption(t *testing.T) {t.Run("with explicit hex key", func(t *testing.T) {hexKey := "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"- cfg := &config.Config{+ cfg := &Config{EncryptionKey: hexKey,Environment: "production",}@@ -129,7 +128,7 @@ func TestInitEncryption(t *testing.T) {t.Run("with explicit base64 key", func(t *testing.T) {rawKey := []byte("01234567890123456789012345678901")b64Key := base64.StdEncoding.EncodeToString(rawKey)- cfg := &config.Config{+ cfg := &Config{EncryptionKey: b64Key,Environment: "production",}@@ -141,7 +140,7 @@ func TestInitEncryption(t *testing.T) {})t.Run("with explicit raw key", func(t *testing.T) {- cfg := &config.Config{+ cfg := &Config{EncryptionKey: "01234567890123456789012345678901",Environment: "production",}@@ -153,7 +152,7 @@ func TestInitEncryption(t *testing.T) {})t.Run("dev mode with no key", func(t *testing.T) {- cfg := &config.Config{+ cfg := &Config{EncryptionKey: "",Environment: "development",AgentMode: false,@@ -166,7 +165,7 @@ func TestInitEncryption(t *testing.T) {})t.Run("production mode without key panics", func(t *testing.T) {- cfg := &config.Config{+ cfg := &Config{EncryptionKey: "",Environment: "production",AgentMode: false,@@ -178,7 +177,7 @@ func TestInitEncryption(t *testing.T) {})t.Run("invalid key panics", func(t *testing.T) {- cfg := &config.Config{+ cfg := &Config{EncryptionKey: "tooshort",Environment: "production",}@@ -191,7 +190,7 @@ func TestInitEncryption(t *testing.T) {func TestEncryptDecrypt(t *testing.T) {hexKey := "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"- cfg := &config.Config{+ cfg := &Config{EncryptionKey: hexKey,Environment: "test",}@@ -287,7 +286,7 @@ func TestEncryptDecrypt(t *testing.T) {require.NoError(t, err)differentKey := "fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210"- differentCfg := &config.Config{+ differentCfg := &Config{EncryptionKey: differentKey,Environment: "test",}diff --git a/backend/internal/utils/converter/converter_util.go b/backend/pkg/libarcane/dockerrun/dockerrun.gosimilarity index 91%rename from backend/internal/utils/converter/converter_util.gorename to backend/pkg/libarcane/dockerrun/dockerrun.goindex f90fd2dac..31619ef39 100644--- a/backend/internal/utils/converter/converter_util.go+++ b/backend/pkg/libarcane/dockerrun/dockerrun.go@@ -1,13 +1,13 @@-package converter+package dockerrunimport ("fmt""strings"- "github.com/getarcaneapp/arcane/backend/internal/models"+ systemtypes "github.com/getarcaneapp/arcane/types/system")-func ParseTokens(tokens []string, result *models.DockerRunCommand) error {+func ParseTokens(tokens []string, result *systemtypes.DockerRunCommand) error {for i := 0; i < len(tokens); i++ {token := tokens[i]@@ -33,7 +33,7 @@ func ParseTokens(tokens []string, result *models.DockerRunCommand) error {return nil}-func parseFlag(token string, tokens []string, index int, result *models.DockerRunCommand) (int, error) {+func parseFlag(token string, tokens []string, index int, result *systemtypes.DockerRunCommand) (int, error) {switch token {case "-d", "--detach":result.Detached = true@@ -55,7 +55,7 @@ func parseFlag(token string, tokens []string, index int, result *models.DockerRu}}-func parseFlagWithValue(token string, tokens []string, index int, result *models.DockerRunCommand) (int, error) {+func parseFlagWithValue(token string, tokens []string, index int, result *systemtypes.DockerRunCommand) (int, error) {switch token {case "--name":return parseStringFlag(token, tokens, index, &result.Name)@@ -116,7 +116,7 @@ func parseSliceFlag(flagName string, tokens []string, index int, target *[]strinreturn 1, nil}-func parseUnknownFlag(token string, tokens []string, index int, result *models.DockerRunCommand) (int, error) {+func parseUnknownFlag(token string, tokens []string, index int, result *systemtypes.DockerRunCommand) (int, error) {if !strings.HasPrefix(token, "--") && len(token) > 2 {parseCombinedFlags(token, result)return 0, nil@@ -129,7 +129,7 @@ func parseUnknownFlag(token string, tokens []string, index int, result *models.Dreturn 0, nil}-func parseCombinedFlags(token string, result *models.DockerRunCommand) {+func parseCombinedFlags(token string, result *systemtypes.DockerRunCommand) {flags := strings.SplitSeq(token[1:], "")for flag := range flags {switch flag {diff --git a/backend/pkg/libarcane/edge/client.go b/backend/pkg/libarcane/edge/client.goindex 939406644..3f258dc0c 100644--- a/backend/pkg/libarcane/edge/client.go+++ b/backend/pkg/libarcane/edge/client.go@@ -12,8 +12,6 @@ import ("sync""time"- "github.com/getarcaneapp/arcane/backend/internal/config"- "github.com/getarcaneapp/arcane/backend/internal/utils/remenv""github.com/google/uuid""github.com/gorilla/websocket")@@ -50,7 +48,7 @@ type wsPayload struct {// TunnelClient represents the agent-side tunnel clienttype TunnelClient struct {- cfg *config.Config+ cfg *Confighandler http.HandlerreconnectInterval time.DurationheartbeatInterval time.Duration@@ -69,7 +67,7 @@ type TunnelClient struct {}// NewTunnelClient creates a new tunnel client-func NewTunnelClient(cfg *config.Config, handler http.Handler) *TunnelClient {+func NewTunnelClient(cfg *Config, handler http.Handler) *TunnelClient {reconnectInterval := time.Duration(cfg.EdgeReconnectInterval) * time.Secondif reconnectInterval < time.Second {reconnectInterval = 5 * time.Second@@ -78,7 +76,7 @@ func NewTunnelClient(cfg *config.Config, handler http.Handler) *TunnelClient {managerURL := ""if managerBaseURL := strings.TrimRight(cfg.GetManagerBaseURL(), "/"); managerBaseURL != "" {// Convert HTTP to WebSocket URL- managerURL = remenv.HTTPToWebSocketURL(managerBaseURL) + "/api/tunnel/connect"+ managerURL = HTTPToWebSocketURL(managerBaseURL) + "/api/tunnel/connect"}managerGRPCAddr := cfg.GetManagerGRPCAddr()@@ -235,7 +233,7 @@ func (c *TunnelClient) managerWebSocketURLInternal() string {if managerBaseURL == "" {return ""}- return remenv.HTTPToWebSocketURL(managerBaseURL) + "/api/tunnel/connect"+ return HTTPToWebSocketURL(managerBaseURL) + "/api/tunnel/connect"}func (c *TunnelClient) grpcRegistrationTimeoutInternal() time.Duration {@@ -605,8 +603,8 @@ func (c *TunnelClient) buildLocalWebSocketHeadersInternal(msg *TunnelMessage) ht}if c.cfg.AgentToken != "" {- headers.Set(remenv.HeaderAPIKey, c.cfg.AgentToken)- headers.Set(remenv.HeaderAgentToken, c.cfg.AgentToken)+ headers.Set(HeaderAPIKey, c.cfg.AgentToken)+ headers.Set(HeaderAgentToken, c.cfg.AgentToken)}return headers@@ -895,7 +893,7 @@ func (r *streamingResponseRecorder) writeHeaderLocked(statusCode int) error {}// StartTunnelClientWithErrors starts the tunnel client and returns a channel for connection errors.-func StartTunnelClientWithErrors(ctx context.Context, cfg *config.Config, handler http.Handler) (<-chan error, error) {+func StartTunnelClientWithErrors(ctx context.Context, cfg *Config, handler http.Handler) (<-chan error, error) {if !cfg.EdgeAgent {return nil, fmt.Errorf("edge tunnel disabled")}diff --git a/backend/pkg/libarcane/edge/client_grpc_test.go b/backend/pkg/libarcane/edge/client_grpc_test.goindex 03fe47f46..fec27c5c6 100644--- a/backend/pkg/libarcane/edge/client_grpc_test.go+++ b/backend/pkg/libarcane/edge/client_grpc_test.go@@ -14,8 +14,6 @@ import ("testing""time"- "github.com/getarcaneapp/arcane/backend/internal/config"- "github.com/getarcaneapp/arcane/backend/internal/utils/remenv"tunnelpb "github.com/getarcaneapp/arcane/backend/pkg/libarcane/edge/proto/tunnel/v1""github.com/gin-gonic/gin""github.com/gorilla/websocket"@@ -114,7 +112,7 @@ func TestTunnelClient_GRPC_EndToEnd(t *testing.T) {_, _ = w.Write([]byte("ok-from-agent"))})- cfg := &config.Config{+ cfg := &Config{EdgeTransport: EdgeTransportGRPC,ManagerApiUrl: managerURL,AgentToken: "valid-token",@@ -164,7 +162,7 @@ func TestTunnelClient_useTLSForManagerGRPC(t *testing.T) {for _, tc := range tests {t.Run(tc.name, func(t *testing.T) {- client := NewTunnelClient(&config.Config{ManagerApiUrl: tc.managerURL}, http.NotFoundHandler())+ client := NewTunnelClient(&Config{ManagerApiUrl: tc.managerURL}, http.NotFoundHandler())assert.Equal(t, tc.expected, client.useTLSForManagerGRPC())})}@@ -174,13 +172,13 @@ func TestStartTunnelClientWithErrors_GRPCValidation(t *testing.T) {ctx := t.Context()t.Run("edge mode required", func(t *testing.T) {- _, err := StartTunnelClientWithErrors(ctx, &config.Config{}, http.NotFoundHandler())+ _, err := StartTunnelClientWithErrors(ctx, &Config{}, http.NotFoundHandler())require.Error(t, err)assert.Contains(t, err.Error(), "edge tunnel disabled")})t.Run("manager url required for grpc transport", func(t *testing.T) {- _, err := StartTunnelClientWithErrors(ctx, &config.Config{+ _, err := StartTunnelClientWithErrors(ctx, &Config{EdgeAgent: true,EdgeTransport: EdgeTransportGRPC,AgentToken: "token",@@ -190,7 +188,7 @@ func TestStartTunnelClientWithErrors_GRPCValidation(t *testing.T) {})t.Run("agent token required", func(t *testing.T) {- _, err := StartTunnelClientWithErrors(ctx, &config.Config{+ _, err := StartTunnelClientWithErrors(ctx, &Config{EdgeAgent: true,EdgeTransport: EdgeTransportGRPC,ManagerApiUrl: "https://manager.example.com/arcane/api",@@ -201,7 +199,7 @@ func TestStartTunnelClientWithErrors_GRPCValidation(t *testing.T) {}func TestTunnelClient_connectAndServeGRPC_EmptyManagerAddress(t *testing.T) {- client := NewTunnelClient(&config.Config{+ client := NewTunnelClient(&Config{EdgeTransport: EdgeTransportGRPC,AgentToken: "valid-token",}, http.NotFoundHandler())@@ -235,7 +233,7 @@ func TestTunnelClient_connectAndServeGRPC_RegistrationRejected(t *testing.T) {managerURL, stopManager := startTestGRPCTunnelServerOnAPIPathInternal(t, ctx, tunnelServer)defer stopManager()- client := NewTunnelClient(&config.Config{+ client := NewTunnelClient(&Config{EdgeTransport: EdgeTransportGRPC,ManagerApiUrl: managerURL,AgentToken: "invalid-token",@@ -257,7 +255,7 @@ func TestTunnelClient_connectAndServeGRPC_TimesOutWithoutRegisterResponse(t *tesmanagerURL, stopManager := startTestTunnelServiceOnAPIPathInternal(t, ctx, service)defer stopManager()- client := NewTunnelClient(&config.Config{+ client := NewTunnelClient(&Config{EdgeTransport: EdgeTransportGRPC,ManagerApiUrl: managerURL,AgentToken: "valid-token",@@ -322,7 +320,7 @@ func TestTunnelClient_GRPC_WebSocketProxyEndToEnd(t *testing.T) {return}- headerTokenCh <- r.Header.Get(remenv.HeaderAPIKey)+ headerTokenCh <- r.Header.Get(HeaderAPIKey)queryCh <- r.URL.RawQueryupgrader := websocket.Upgrader{}@@ -350,7 +348,7 @@ func TestTunnelClient_GRPC_WebSocketProxyEndToEnd(t *testing.T) {_, localPort, err := net.SplitHostPort(parsedLocalURL.Host)require.NoError(t, err)- cfg := &config.Config{+ cfg := &Config{EdgeTransport: EdgeTransportGRPC,ManagerApiUrl: managerURL,AgentToken: "valid-token",@@ -451,7 +449,7 @@ func TestTunnelClient_connectAndServe_WebSocketConfigFallsBackToWebSocket(t *tes}))defer managerServer.Close()- cfg := &config.Config{+ cfg := &Config{EdgeTransport: EdgeTransportWebSocket,ManagerApiUrl: managerServer.URL,AgentToken: "valid-token",@@ -495,7 +493,7 @@ func TestTunnelClient_connectAndServe_AutoTransportFallsBackToWebSocketWhenGRPCU}))defer managerServer.Close()- cfg := &config.Config{+ cfg := &Config{EdgeTransport: EdgeTransportAuto,ManagerApiUrl: managerServer.URL,AgentToken: "valid-token",@@ -539,7 +537,7 @@ func TestTunnelClient_connectAndServe_AutoTransportDerivesWebSocketFallbackURL(t}))defer managerServer.Close()- cfg := &config.Config{+ cfg := &Config{EdgeTransport: EdgeTransportAuto,ManagerApiUrl: managerServer.URL,AgentToken: "valid-token",@@ -580,7 +578,7 @@ func TestTunnelClient_connectAndServe_AutoTransportOpensGRPCWhenAvailable(t *tesmanagerURL, stopManager := startTestGRPCTunnelServerOnAPIPathInternal(t, ctx, tunnelServer)defer stopManager()- client := NewTunnelClient(&config.Config{+ client := NewTunnelClient(&Config{EdgeTransport: EdgeTransportAuto,ManagerApiUrl: managerURL,AgentToken: "valid-token",diff --git a/backend/pkg/libarcane/edge/client_poll_test.go b/backend/pkg/libarcane/edge/client_poll_test.goindex b2e732fad..1b33ac88b 100644--- a/backend/pkg/libarcane/edge/client_poll_test.go+++ b/backend/pkg/libarcane/edge/client_poll_test.go@@ -13,7 +13,6 @@ import ("testing""time"- "github.com/getarcaneapp/arcane/backend/internal/config"tunnelpb "github.com/getarcaneapp/arcane/backend/pkg/libarcane/edge/proto/tunnel/v1""github.com/gorilla/websocket""github.com/stretchr/testify/assert"@@ -48,7 +47,7 @@ func TestTunnelClient_connectAndServePoll_OpensGRPCWhenRequired(t *testing.T) {})defer stopManager()- client := NewTunnelClient(&config.Config{+ client := NewTunnelClient(&Config{EdgeTransport: EdgeTransportPoll,ManagerApiUrl: managerURL,AgentToken: "valid-token",@@ -109,7 +108,7 @@ func TestTunnelClient_connectAndServePoll_OpensWebSocketWhenRequired(t *testing.}))defer managerServer.Close()- client := NewTunnelClient(&config.Config{+ client := NewTunnelClient(&Config{EdgeTransport: EdgeTransportPoll,ManagerApiUrl: managerServer.URL,AgentToken: "valid-token",@@ -148,7 +147,7 @@ func TestTunnelClient_pollTunnelControlInternal_UsesConfiguredHTTPClient(t *testreturn baseClient.Transport.RoundTrip(clone)})- client := NewTunnelClient(&config.Config{AgentToken: "valid-token"}, http.NotFoundHandler())+ client := NewTunnelClient(&Config{AgentToken: "valid-token"}, http.NotFoundHandler())client.httpClient = &http.Client{Transport: rewriteTransport}resp, err := client.pollTunnelControlInternal(context.Background(), "http://127.0.0.1:1/api/tunnel/poll", false)@@ -191,7 +190,7 @@ func TestTunnelClient_connectAndServePoll_DoesNotOpenWebSocketWhenIdle(t *testin}))defer managerServer.Close()- client := NewTunnelClient(&config.Config{+ client := NewTunnelClient(&Config{EdgeTransport: EdgeTransportPoll,ManagerApiUrl: managerServer.URL,AgentToken: "valid-token",@@ -249,7 +248,7 @@ func TestTunnelClient_connectAndServePoll_RetriesAfterTransientPollError(t *test}))defer managerServer.Close()- client := NewTunnelClient(&config.Config{+ client := NewTunnelClient(&Config{EdgeTransport: EdgeTransportPoll,ManagerApiUrl: managerServer.URL,AgentToken: "valid-token",diff --git a/backend/pkg/libarcane/edge/client_test.go b/backend/pkg/libarcane/edge/client_test.goindex 87cc29f61..f750b835b 100644--- a/backend/pkg/libarcane/edge/client_test.go+++ b/backend/pkg/libarcane/edge/client_test.go@@ -13,8 +13,7 @@ import ("testing""time"- "github.com/getarcaneapp/arcane/backend/internal/config"- httputil "github.com/getarcaneapp/arcane/backend/internal/utils/http"+ httputil "github.com/getarcaneapp/arcane/backend/pkg/utils/httpx""github.com/gorilla/websocket""github.com/stretchr/testify/assert""github.com/stretchr/testify/require"@@ -63,7 +62,7 @@ func TestTunnelClient_HandleRequest(t *testing.T) {defer managerServer.Close()// 3. Configure and Start Agent Client- cfg := &config.Config{+ cfg := &Config{EdgeTransport: EdgeTransportWebSocket,ManagerApiUrl: managerServer.URL,AgentToken: "test-token",@@ -141,7 +140,7 @@ func TestTunnelClient_WebSocketProxy(t *testing.T) {defer managerServer.Close()// 3. Configure Agent- cfg := &config.Config{+ cfg := &Config{EdgeTransport: EdgeTransportWebSocket,ManagerApiUrl: managerServer.URL,AgentToken: "test-token",@@ -192,7 +191,7 @@ func TestTunnelClient_HandleRequest_Errors(t *testing.T) {}))defer managerServer.Close()- cfg := &config.Config{+ cfg := &Config{EdgeTransport: EdgeTransportWebSocket,ManagerApiUrl: managerServer.URL,AgentToken: "test-token",@@ -223,7 +222,7 @@ func TestTunnelClient_InternalHelpers(t *testing.T) {}))defer server.Close()- cfg := &config.Config{+ cfg := &Config{ManagerApiUrl: server.URL,AgentToken: "test-token",}@@ -320,7 +319,7 @@ func TestTunnelClient_BuildLocalWebSocketURL(t *testing.T) {for _, testCase := range tests {t.Run(testCase.name, func(t *testing.T) {- cfg := &config.Config{+ cfg := &Config{Listen: testCase.listen,Port: testCase.port,}@@ -335,12 +334,12 @@ func TestTunnelClient_BuildLocalWebSocketURL(t *testing.T) {}func TestTunnelClient_GRPCConnectMethodInternal(t *testing.T) {- client := NewTunnelClient(&config.Config{}, http.NotFoundHandler())+ client := NewTunnelClient(&Config{}, http.NotFoundHandler())assert.Equal(t, "/api/tunnel/connect", client.grpcConnectMethodInternal())}func TestTunnelClient_buildLocalWebSocketHeadersInternal(t *testing.T) {- client := NewTunnelClient(&config.Config{+ client := NewTunnelClient(&Config{AgentToken: "agent-token",}, http.NotFoundHandler())@@ -363,7 +362,7 @@ func TestTunnelClient_buildLocalWebSocketHeadersInternal(t *testing.T) {}func TestTunnelClient_buildLocalWebSocketHeadersInternal_FiltersBrowserHeaders(t *testing.T) {- client := NewTunnelClient(&config.Config{+ client := NewTunnelClient(&Config{AgentToken: "agent-token",}, http.NotFoundHandler())@@ -446,7 +445,7 @@ func TestTunnelClient_DialLocalWebSocket_StripsForwardedBrowserHeaders(t *testinparsedURL, err := url.Parse(localServer.URL)require.NoError(t, err)- client := NewTunnelClient(&config.Config{+ client := NewTunnelClient(&Config{AgentToken: "agent-token",Listen: parsedURL.Hostname(),Port: parsedURL.Port(),@@ -507,7 +506,7 @@ func TestTunnelClient_HandleRequest_GRPCConfigWithWebSocketConnUsesNonStreamingR_, _ = w.Write([]byte(`{"ok":true}`))})- client := NewTunnelClient(&config.Config{+ client := NewTunnelClient(&Config{EdgeTransport: EdgeTransportGRPC,}, localHandler)conn := &capturingTunnelConnForHandleRequest{}diff --git a/backend/pkg/libarcane/edge/client_transport_grpc.go b/backend/pkg/libarcane/edge/client_transport_grpc.goindex 5acb234d5..2c49543e6 100644--- a/backend/pkg/libarcane/edge/client_transport_grpc.go+++ b/backend/pkg/libarcane/edge/client_transport_grpc.go@@ -9,7 +9,6 @@ import ("strings""time"- "github.com/getarcaneapp/arcane/backend/internal/utils/remenv"tunnelpb "github.com/getarcaneapp/arcane/backend/pkg/libarcane/edge/proto/tunnel/v1""google.golang.org/grpc""google.golang.org/grpc/backoff"@@ -59,8 +58,8 @@ func (c *TunnelClient) connectAndServeGRPC(ctx context.Context) error {defer func() { _ = conn.Close() }()streamCtx, streamCancel := context.WithCancel(metadata.NewOutgoingContext(ctx, metadata.Pairs(- strings.ToLower(remenv.HeaderAgentToken), c.cfg.AgentToken,- strings.ToLower(remenv.HeaderAPIKey), c.cfg.AgentToken,+ strings.ToLower(HeaderAgentToken), c.cfg.AgentToken,+ strings.ToLower(HeaderAPIKey), c.cfg.AgentToken,)))defer streamCancel()diff --git a/backend/pkg/libarcane/edge/client_transport_poll.go b/backend/pkg/libarcane/edge/client_transport_poll.goindex 0978ff084..eb536268f 100644--- a/backend/pkg/libarcane/edge/client_transport_poll.go+++ b/backend/pkg/libarcane/edge/client_transport_poll.go@@ -11,8 +11,6 @@ import ("net/http""strings""time"-- "github.com/getarcaneapp/arcane/backend/internal/utils/remenv")const defaultTunnelPollRequestTimeout = 15 * time.Second@@ -176,8 +174,8 @@ func (c *TunnelClient) pollTunnelControlInternal(ctx context.Context, pollURL streturn nil, fmt.Errorf("failed to create poll request: %w", err)}req.Header.Set("Content-Type", "application/json")- req.Header.Set(remenv.HeaderAgentToken, c.cfg.AgentToken)- req.Header.Set(remenv.HeaderAPIKey, c.cfg.AgentToken)+ req.Header.Set(HeaderAgentToken, c.cfg.AgentToken)+ req.Header.Set(HeaderAPIKey, c.cfg.AgentToken)resp, err := c.httpClient.Do(req)if err != nil {diff --git a/backend/pkg/libarcane/edge/client_transport_websocket.go b/backend/pkg/libarcane/edge/client_transport_websocket.goindex 58625b974..8a006daeb 100644--- a/backend/pkg/libarcane/edge/client_transport_websocket.go+++ b/backend/pkg/libarcane/edge/client_transport_websocket.go@@ -8,7 +8,6 @@ import ("net/http""time"- "github.com/getarcaneapp/arcane/backend/internal/utils/remenv""github.com/gorilla/websocket")@@ -25,8 +24,8 @@ func (c *TunnelClient) connectAndServeWebSocket(ctx context.Context) error {}headers := http.Header{}- headers.Set(remenv.HeaderAgentToken, c.cfg.AgentToken)- headers.Set(remenv.HeaderAPIKey, c.cfg.AgentToken)+ headers.Set(HeaderAgentToken, c.cfg.AgentToken)+ headers.Set(HeaderAPIKey, c.cfg.AgentToken)slog.DebugContext(ctx, "Dialing manager for websocket edge tunnel", "url", managerWSURL)diff --git a/backend/pkg/libarcane/edge/grpc_tunnel_integration_test.go b/backend/pkg/libarcane/edge/grpc_tunnel_integration_test.goindex 71cb70a85..7f6777248 100644--- a/backend/pkg/libarcane/edge/grpc_tunnel_integration_test.go+++ b/backend/pkg/libarcane/edge/grpc_tunnel_integration_test.go@@ -8,7 +8,6 @@ import ("testing""time"- "github.com/getarcaneapp/arcane/backend/internal/utils/remenv"tunnelpb "github.com/getarcaneapp/arcane/backend/pkg/libarcane/edge/proto/tunnel/v1""github.com/stretchr/testify/assert""github.com/stretchr/testify/require"@@ -234,7 +233,7 @@ func TestGRPCTunnel_MetadataAuthFallback(t *testing.T) {client := tunnelpb.NewTunnelServiceClient(conn)streamCtx := metadata.NewOutgoingContext(ctx, metadata.Pairs(- strings.ToLower(remenv.HeaderAgentToken), " valid-token ",+ strings.ToLower(HeaderAgentToken), " valid-token ",))stream, err := client.Connect(streamCtx)require.NoError(t, err)@@ -281,7 +280,7 @@ func TestGRPCTunnel_MetadataAPIKeyFallback(t *testing.T) {client := tunnelpb.NewTunnelServiceClient(conn)streamCtx := metadata.NewOutgoingContext(ctx, metadata.Pairs(- strings.ToLower(remenv.HeaderAPIKey), " valid-token ",+ strings.ToLower(HeaderAPIKey), " valid-token ",))stream, err := client.Connect(streamCtx)require.NoError(t, err)diff --git a/backend/pkg/libarcane/edge/poll_control.go b/backend/pkg/libarcane/edge/poll_control.goindex b836b1843..1b95347d1 100644--- a/backend/pkg/libarcane/edge/poll_control.go+++ b/backend/pkg/libarcane/edge/poll_control.go@@ -10,7 +10,6 @@ import ("sync""time"- "github.com/getarcaneapp/arcane/backend/internal/utils/remenv""github.com/gin-gonic/gin")@@ -272,9 +271,9 @@ func (s *TunnelServer) HandlePoll(c *gin.Context) {return}- token := c.GetHeader(remenv.HeaderAgentToken)+ token := c.GetHeader(HeaderAgentToken)if token == "" {- token = c.GetHeader(remenv.HeaderAPIKey)+ token = c.GetHeader(HeaderAPIKey)}if token == "" {slog.WarnContext(ctx, "Edge poll request without token")diff --git a/backend/pkg/libarcane/edge/poll_control_test.go b/backend/pkg/libarcane/edge/poll_control_test.goindex ec0dada96..6f7055609 100644--- a/backend/pkg/libarcane/edge/poll_control_test.go+++ b/backend/pkg/libarcane/edge/poll_control_test.go@@ -10,7 +10,6 @@ import ("testing""time"- "github.com/getarcaneapp/arcane/backend/internal/utils/remenv""github.com/gin-gonic/gin""github.com/stretchr/testify/assert""github.com/stretchr/testify/require"@@ -45,7 +44,7 @@ func TestTunnelServer_HandlePoll(t *testing.T) {TouchTunnelDemand("env-poll-1", time.Minute)req := httptest.NewRequest(http.MethodPost, "/api/tunnel/poll", bytes.NewBufferString(`{"transport":"poll"}`))- req.Header.Set(remenv.HeaderAgentToken, "valid-token")+ req.Header.Set(HeaderAgentToken, "valid-token")rec := httptest.NewRecorder()router.ServeHTTP(rec, req)@@ -64,7 +63,7 @@ func TestTunnelServer_HandlePoll(t *testing.T) {t.Cleanup(func() { registry.Unregister("env-poll-1") })req = httptest.NewRequest(http.MethodPost, "/api/tunnel/poll", bytes.NewBufferString(`{"transport":"poll","connected":true}`))- req.Header.Set(remenv.HeaderAgentToken, "valid-token")+ req.Header.Set(HeaderAgentToken, "valid-token")rec = httptest.NewRecorder()router.ServeHTTP(rec, req)diff --git a/backend/pkg/libarcane/edge/proto/tunnel/v1/tunnel.pb.go b/backend/pkg/libarcane/edge/proto/tunnel/v1/tunnel.pb.goindex a101c3aaf..f20150ce2 100644--- a/backend/pkg/libarcane/edge/proto/tunnel/v1/tunnel.pb.go+++ b/backend/pkg/libarcane/edge/proto/tunnel/v1/tunnel.pb.go@@ -7,11 +7,12 @@package tunnelpbimport (- protoreflect "google.golang.org/protobuf/reflect/protoreflect"- protoimpl "google.golang.org/protobuf/runtime/protoimpl"reflect "reflect"sync "sync"unsafe "unsafe"++ protoreflect "google.golang.org/protobuf/reflect/protoreflect"+ protoimpl "google.golang.org/protobuf/runtime/protoimpl")const (diff --git a/backend/pkg/libarcane/edge/proto/tunnel/v1/tunnel_grpc.pb.go b/backend/pkg/libarcane/edge/proto/tunnel/v1/tunnel_grpc.pb.goindex 4f7424980..ffd4eb2d6 100644--- a/backend/pkg/libarcane/edge/proto/tunnel/v1/tunnel_grpc.pb.go+++ b/backend/pkg/libarcane/edge/proto/tunnel/v1/tunnel_grpc.pb.go@@ -8,6 +8,7 @@ package tunnelpbimport (context "context"+grpc "google.golang.org/grpc"codes "google.golang.org/grpc/codes"status "google.golang.org/grpc/status"diff --git a/backend/pkg/libarcane/edge/proxy_headers_test.go b/backend/pkg/libarcane/edge/proxy_headers_test.goindex fd2dfd372..d7919f6c9 100644--- a/backend/pkg/libarcane/edge/proxy_headers_test.go+++ b/backend/pkg/libarcane/edge/proxy_headers_test.go@@ -8,7 +8,6 @@ import ("net/http/httptest""testing"- "github.com/getarcaneapp/arcane/backend/internal/config""github.com/gin-gonic/gin""github.com/gorilla/websocket""github.com/stretchr/testify/assert"@@ -148,7 +147,7 @@ func TestHandleRequest_SetsHostField(t *testing.T) {_, _ = w.Write([]byte("ok"))})- client := NewTunnelClient(&config.Config{}, localHandler)+ client := NewTunnelClient(&Config{}, localHandler)conn := &capturingTunnelConnForHandleRequest{}client.conn = conn@@ -180,7 +179,7 @@ func TestHandleRequest_ForwardsBody(t *testing.T) {_, _ = w.Write([]byte(`{"id":"p1"}`))})- client := NewTunnelClient(&config.Config{}, localHandler)+ client := NewTunnelClient(&Config{}, localHandler)conn := &capturingTunnelConnForHandleRequest{}client.conn = conn@@ -212,7 +211,7 @@ func TestHandleRequest_NoBrowserHeadersInTunnelMessage(t *testing.T) {w.WriteHeader(http.StatusOK)})- client := NewTunnelClient(&config.Config{}, localHandler)+ client := NewTunnelClient(&Config{}, localHandler)conn := &capturingTunnelConnForHandleRequest{}client.conn = conndiff --git a/backend/internal/utils/remenv/remenv.go b/backend/pkg/libarcane/edge/remenv.gosimilarity index 99%rename from backend/internal/utils/remenv/remenv.gorename to backend/pkg/libarcane/edge/remenv.goindex 9408f1e9a..b52021c2e 100644--- a/backend/internal/utils/remenv/remenv.go+++ b/backend/pkg/libarcane/edge/remenv.go@@ -1,4 +1,4 @@-package remenv+package edgeimport ("io"diff --git a/backend/internal/utils/remenv/remenv_test.go b/backend/pkg/libarcane/edge/remenv_test.gosimilarity index 99%rename from backend/internal/utils/remenv/remenv_test.gorename to backend/pkg/libarcane/edge/remenv_test.goindex 7c387abc7..44316d78c 100644--- a/backend/internal/utils/remenv/remenv_test.go+++ b/backend/pkg/libarcane/edge/remenv_test.go@@ -1,4 +1,4 @@-package remenv+package edgeimport ("bytes"diff --git a/backend/pkg/libarcane/edge/server.go b/backend/pkg/libarcane/edge/server.goindex cf909ea9c..37fea405f 100644--- a/backend/pkg/libarcane/edge/server.go+++ b/backend/pkg/libarcane/edge/server.go@@ -10,7 +10,6 @@ import ("strings""time"- "github.com/getarcaneapp/arcane/backend/internal/utils/remenv"tunnelpb "github.com/getarcaneapp/arcane/backend/pkg/libarcane/edge/proto/tunnel/v1""github.com/gin-gonic/gin""github.com/gorilla/websocket"@@ -99,9 +98,9 @@ func (s *TunnelServer) HandleConnect(c *gin.Context) {callbackCtx := context.WithoutCancel(ctx)// Get agent token from headers.- token := c.GetHeader(remenv.HeaderAgentToken)+ token := c.GetHeader(HeaderAgentToken)if token == "" {- token = c.GetHeader(remenv.HeaderAPIKey)+ token = c.GetHeader(HeaderAPIKey)}if token == "" {slog.WarnContext(ctx, "Edge tunnel connection attempt without token")@@ -187,8 +186,8 @@ func tokenFromMetadata(ctx context.Context) string {return ""}for _, key := range []string{- strings.ToLower(remenv.HeaderAgentToken),- strings.ToLower(remenv.HeaderAPIKey),+ strings.ToLower(HeaderAgentToken),+ strings.ToLower(HeaderAPIKey),} {values := md.Get(key)for _, value := range values {diff --git a/backend/pkg/libarcane/edge/server_test.go b/backend/pkg/libarcane/edge/server_test.goindex 7051a110f..56b7e7a9b 100644--- a/backend/pkg/libarcane/edge/server_test.go+++ b/backend/pkg/libarcane/edge/server_test.go@@ -11,7 +11,6 @@ import ("testing""time"- "github.com/getarcaneapp/arcane/backend/internal/utils/remenv""github.com/gin-gonic/gin""github.com/gorilla/websocket""github.com/stretchr/testify/assert"@@ -52,7 +51,7 @@ func TestTunnelServer_HandleConnect(t *testing.T) {// Test Successurl := "ws" + strings.TrimPrefix(ts.URL, "http") + "/connect"headers := http.Header{}- headers.Set(remenv.HeaderAgentToken, "valid-token")+ headers.Set(HeaderAgentToken, "valid-token")conn, resp, err := websocket.DefaultDialer.Dial(url, headers)require.NoError(t, err)@@ -169,7 +168,7 @@ func TestTunnelServer_HandleConnect_InvalidToken(t *testing.T) {url := "ws" + strings.TrimPrefix(ts.URL, "http") + "/connect"headers := http.Header{}- headers.Set(remenv.HeaderAgentToken, "bad-token")+ headers.Set(HeaderAgentToken, "bad-token")_, resp, err := websocket.DefaultDialer.Dial(url, headers)require.Error(t, err)@@ -262,8 +261,8 @@ func TestTunnelServer_resolveEnvironment_Errors(t *testing.T) {func TestTokenFromMetadata(t *testing.T) {t.Run("prefers agent token and trims whitespace", func(t *testing.T) {ctx := metadata.NewIncomingContext(context.Background(), metadata.Pairs(- strings.ToLower(remenv.HeaderAgentToken), " agent-token ",- strings.ToLower(remenv.HeaderAPIKey), "api-token",+ strings.ToLower(HeaderAgentToken), " agent-token ",+ strings.ToLower(HeaderAPIKey), "api-token",))assert.Equal(t, "agent-token", tokenFromMetadata(ctx))@@ -271,7 +270,7 @@ func TestTokenFromMetadata(t *testing.T) {t.Run("falls back to api key", func(t *testing.T) {ctx := metadata.NewIncomingContext(context.Background(), metadata.Pairs(- strings.ToLower(remenv.HeaderAPIKey), "api-token",+ strings.ToLower(HeaderAPIKey), "api-token",))assert.Equal(t, "api-token", tokenFromMetadata(ctx))diff --git a/backend/pkg/libarcane/edge/transport.go b/backend/pkg/libarcane/edge/transport.goindex 8fffe30d4..8133c7017 100644--- a/backend/pkg/libarcane/edge/transport.go+++ b/backend/pkg/libarcane/edge/transport.go@@ -1,12 +1,62 @@package edgeimport (+ "net/url""strings""time"-- "github.com/getarcaneapp/arcane/backend/internal/config")+// Config contains the public edge-tunnel runtime settings needed by pkg/libarcane/edge.+type Config struct {+ EdgeAgent bool+ EdgeTransport string+ EdgeReconnectInterval int+ ManagerApiUrl string+ AgentToken string+ Port string+ Listen string+}++// GetManagerBaseURL returns the base URL of the manager application.+// It strips any trailing slashes or /api suffix from MANAGER_API_URL.+func (c *Config) GetManagerBaseURL() string {+ if c == nil || c.ManagerApiUrl == "" {+ return ""+ }+ managerURL := strings.TrimRight(c.ManagerApiUrl, "/")+ managerURL = strings.TrimSuffix(managerURL, "/api")+ return managerURL+}++// GetManagerGRPCAddr returns the manager gRPC address in host:port form.+func (c *Config) GetManagerGRPCAddr() string {+ baseURL := c.GetManagerBaseURL()+ if baseURL == "" {+ return ""+ }++ parsed, err := url.Parse(baseURL)+ if err != nil {+ return ""+ }++ host := parsed.Hostname()+ if host == "" {+ return ""+ }++ port := parsed.Port()+ if port == "" {+ if strings.EqualFold(parsed.Scheme, "https") {+ port = "443"+ } else {+ port = "80"+ }+ }++ return host + ":" + port+}+// TunnelRuntimeState describes the live, in-memory state of an active edge tunnel.type TunnelRuntimeState struct {Transport string@@ -45,7 +95,7 @@ func NormalizeEdgeTransport(value string) string {}// UseGRPCEdgeTransport reports whether gRPC managed tunnel mode should be attempted.-func UseGRPCEdgeTransport(cfg *config.Config) bool {+func UseGRPCEdgeTransport(cfg *Config) bool {if cfg == nil {return false}@@ -54,7 +104,7 @@ func UseGRPCEdgeTransport(cfg *config.Config) bool {}// UseWebSocketEdgeTransport reports whether websocket managed tunnel mode is allowed.-func UseWebSocketEdgeTransport(cfg *config.Config) bool {+func UseWebSocketEdgeTransport(cfg *Config) bool {if cfg == nil {return false}@@ -64,7 +114,7 @@ func UseWebSocketEdgeTransport(cfg *config.Config) bool {// UsePollEdgeTransport reports whether the Portainer-style polling control plane// should be used.-func UsePollEdgeTransport(cfg *config.Config) bool {+func UsePollEdgeTransport(cfg *Config) bool {if cfg == nil {return false}diff --git a/backend/pkg/libarcane/edge/transport_test.go b/backend/pkg/libarcane/edge/transport_test.goindex 6635619e1..74c4f0263 100644--- a/backend/pkg/libarcane/edge/transport_test.go+++ b/backend/pkg/libarcane/edge/transport_test.go@@ -5,7 +5,6 @@ import ("sync""testing"- "github.com/getarcaneapp/arcane/backend/internal/config""github.com/stretchr/testify/assert")@@ -21,28 +20,28 @@ func TestNormalizeEdgeTransport(t *testing.T) {func TestUseGRPCEdgeTransport(t *testing.T) {assert.False(t, UseGRPCEdgeTransport(nil))- assert.True(t, UseGRPCEdgeTransport(&config.Config{EdgeTransport: "grpc"}))- assert.True(t, UseGRPCEdgeTransport(&config.Config{EdgeTransport: ""}))- assert.True(t, UseGRPCEdgeTransport(&config.Config{EdgeTransport: "auto"}))- assert.False(t, UseGRPCEdgeTransport(&config.Config{EdgeTransport: "websocket"}))+ assert.True(t, UseGRPCEdgeTransport(&Config{EdgeTransport: "grpc"}))+ assert.True(t, UseGRPCEdgeTransport(&Config{EdgeTransport: ""}))+ assert.True(t, UseGRPCEdgeTransport(&Config{EdgeTransport: "auto"}))+ assert.False(t, UseGRPCEdgeTransport(&Config{EdgeTransport: "websocket"}))}func TestUseWebSocketEdgeTransport(t *testing.T) {assert.False(t, UseWebSocketEdgeTransport(nil))- assert.True(t, UseWebSocketEdgeTransport(&config.Config{EdgeTransport: ""}))- assert.True(t, UseWebSocketEdgeTransport(&config.Config{EdgeTransport: "auto"}))- assert.False(t, UseWebSocketEdgeTransport(&config.Config{EdgeTransport: "grpc"}))- assert.False(t, UseWebSocketEdgeTransport(&config.Config{EdgeTransport: "poll"}))- assert.True(t, UseWebSocketEdgeTransport(&config.Config{EdgeTransport: "websocket"}))+ assert.True(t, UseWebSocketEdgeTransport(&Config{EdgeTransport: ""}))+ assert.True(t, UseWebSocketEdgeTransport(&Config{EdgeTransport: "auto"}))+ assert.False(t, UseWebSocketEdgeTransport(&Config{EdgeTransport: "grpc"}))+ assert.False(t, UseWebSocketEdgeTransport(&Config{EdgeTransport: "poll"}))+ assert.True(t, UseWebSocketEdgeTransport(&Config{EdgeTransport: "websocket"}))}func TestUsePollEdgeTransport(t *testing.T) {assert.False(t, UsePollEdgeTransport(nil))- assert.False(t, UsePollEdgeTransport(&config.Config{EdgeTransport: ""}))- assert.False(t, UsePollEdgeTransport(&config.Config{EdgeTransport: "auto"}))- assert.False(t, UsePollEdgeTransport(&config.Config{EdgeTransport: "grpc"}))- assert.False(t, UsePollEdgeTransport(&config.Config{EdgeTransport: "websocket"}))- assert.True(t, UsePollEdgeTransport(&config.Config{EdgeTransport: "poll"}))+ assert.False(t, UsePollEdgeTransport(&Config{EdgeTransport: ""}))+ assert.False(t, UsePollEdgeTransport(&Config{EdgeTransport: "auto"}))+ assert.False(t, UsePollEdgeTransport(&Config{EdgeTransport: "grpc"}))+ assert.False(t, UsePollEdgeTransport(&Config{EdgeTransport: "websocket"}))+ assert.True(t, UsePollEdgeTransport(&Config{EdgeTransport: "poll"}))}func TestGetActiveTunnelTransport(t *testing.T) {diff --git a/backend/pkg/libarcane/libbuild/builder_buildkit.go b/backend/pkg/libarcane/libbuild/builder_buildkit.goindex 49a538f54..3b76f1020 100644--- a/backend/pkg/libarcane/libbuild/builder_buildkit.go+++ b/backend/pkg/libarcane/libbuild/builder_buildkit.go@@ -8,7 +8,7 @@ import ("path/filepath""strings"- dockerutils "github.com/getarcaneapp/arcane/backend/internal/utils/docker"+ dockerutils "github.com/getarcaneapp/arcane/backend/pkg/dockerutil"imagetypes "github.com/getarcaneapp/arcane/types/image"buildkit "github.com/moby/buildkit/client")diff --git a/backend/pkg/libarcane/libbuild/builder_core.go b/backend/pkg/libarcane/libbuild/builder_core.goindex 06206d75f..25de3658b 100644--- a/backend/pkg/libarcane/libbuild/builder_core.go+++ b/backend/pkg/libarcane/libbuild/builder_core.go@@ -11,8 +11,8 @@ import ("github.com/docker/cli/cli/config"configtypes "github.com/docker/cli/cli/config/types"- utilsregistry "github.com/getarcaneapp/arcane/backend/internal/utils/registry"- "github.com/getarcaneapp/arcane/backend/internal/utils/timeouts"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"+ utilsregistry "github.com/getarcaneapp/arcane/backend/pkg/utils/registry"buildtypes "github.com/getarcaneapp/arcane/types/builds"imagetypes "github.com/getarcaneapp/arcane/types/image"buildkit "github.com/moby/buildkit/client"diff --git a/backend/pkg/libarcane/libbuild/builder_core_test.go b/backend/pkg/libarcane/libbuild/builder_core_test.goindex d53c18881..cd4d17ca8 100644--- a/backend/pkg/libarcane/libbuild/builder_core_test.go+++ b/backend/pkg/libarcane/libbuild/builder_core_test.go@@ -6,7 +6,7 @@ import ("testing"configtypes "github.com/docker/cli/cli/config/types"- utilsregistry "github.com/getarcaneapp/arcane/backend/internal/utils/registry"+ utilsregistry "github.com/getarcaneapp/arcane/backend/pkg/utils/registry""github.com/moby/buildkit/session/auth/authprovider"dockerregistry "github.com/moby/moby/api/types/registry""github.com/stretchr/testify/assert"diff --git a/backend/pkg/libarcane/libbuild/builder_docker.go b/backend/pkg/libarcane/libbuild/builder_docker.goindex 7edee9e72..93a3c221e 100644--- a/backend/pkg/libarcane/libbuild/builder_docker.go+++ b/backend/pkg/libarcane/libbuild/builder_docker.go@@ -12,7 +12,7 @@ import ("strconv""strings"- dockerutils "github.com/getarcaneapp/arcane/backend/internal/utils/docker"+ dockerutils "github.com/getarcaneapp/arcane/backend/pkg/dockerutil"imagetypes "github.com/getarcaneapp/arcane/types/image""github.com/moby/go-archive"dockercontainer "github.com/moby/moby/api/types/container"diff --git a/backend/internal/utils/bootstrap_util.go b/backend/pkg/libarcane/startup/startup.gosimilarity index 95%rename from backend/internal/utils/bootstrap_util.gorename to backend/pkg/libarcane/startup/startup.goindex cd1e78a4e..7ce34f95b 100644--- a/backend/internal/utils/bootstrap_util.go+++ b/backend/pkg/libarcane/startup/startup.go@@ -1,4 +1,4 @@-package utils+package startupimport ("context"@@ -9,10 +9,17 @@ import ("time""github.com/getarcaneapp/arcane/backend/buildables"- "github.com/getarcaneapp/arcane/backend/internal/config")-func LoadAgentToken(ctx context.Context, cfg *config.Config, getSettingFunc func(context.Context, string, string) string) {+type RuntimeConfig struct {+ AgentMode bool+ AgentToken string+ Environment string+ EncryptionKey string+ AutoLoginUsername string+}++func LoadAgentToken(ctx context.Context, cfg *RuntimeConfig, getSettingFunc func(context.Context, string, string) string) {if cfg.AgentMode && cfg.AgentToken == "" {if tok := getSettingFunc(ctx, "agentToken", ""); tok != "" {cfg.AgentToken = tok@@ -21,7 +28,7 @@ func LoadAgentToken(ctx context.Context, cfg *config.Config, getSettingFunc func}}-func EnsureEncryptionKey(ctx context.Context, cfg *config.Config, ensureKeyFunc func(context.Context) (string, error)) {+func EnsureEncryptionKey(ctx context.Context, cfg *RuntimeConfig, ensureKeyFunc func(context.Context) (string, error)) {if cfg.AgentMode || cfg.Environment != "production" {key, err := ensureKeyFunc(ctx)if err != nil {@@ -47,7 +54,7 @@ type IntervalMigrationItem struct {RawValue string}-func InitializeDefaultSettings(ctx context.Context, cfg *config.Config, settingsMgr SettingsManager) {+func InitializeDefaultSettings(ctx context.Context, cfg *RuntimeConfig, settingsMgr SettingsManager) {slog.InfoContext(ctx, "Ensuring default settings are initialized")if err := settingsMgr.EnsureDefaultSettings(ctx); err != nil {@@ -75,7 +82,7 @@ func TestDockerConnection(ctx context.Context, testFunc func(context.Context) er}}-func InitializeNonAgentFeatures(ctx context.Context, cfg *config.Config, createAdminFunc func(context.Context) error, autoLoginInitFunc func(context.Context) error, migrateOidcFunc func(context.Context) error, migrateDiscordFunc func(context.Context) error) {+func InitializeNonAgentFeatures(ctx context.Context, cfg *RuntimeConfig, createAdminFunc func(context.Context) error, autoLoginInitFunc func(context.Context) error, migrateOidcFunc func(context.Context) error, migrateDiscordFunc func(context.Context) error) {if cfg.AgentMode {return}@@ -103,7 +110,7 @@ func InitializeNonAgentFeatures(ctx context.Context, cfg *config.Config, createA}}-func InitializeAutoLogin(ctx context.Context, cfg *config.Config) {+func InitializeAutoLogin(ctx context.Context, cfg *RuntimeConfig) {if !buildables.HasBuildFeature("autologin") {return}diff --git a/backend/internal/utils/bootstrap_util_test.go b/backend/pkg/libarcane/startup/startup_test.gosimilarity index 97%rename from backend/internal/utils/bootstrap_util_test.gorename to backend/pkg/libarcane/startup/startup_test.goindex 3624cb73a..82128fc0f 100644--- a/backend/internal/utils/bootstrap_util_test.go+++ b/backend/pkg/libarcane/startup/startup_test.go@@ -1,4 +1,4 @@-package utils+package startupimport ("context"@@ -6,7 +6,6 @@ import ("testing""time"- "github.com/getarcaneapp/arcane/backend/internal/config""github.com/stretchr/testify/assert")@@ -48,7 +47,7 @@ func TestLoadAgentToken(t *testing.T) {ctx := context.Background()t.Run("loads token when agent mode and token empty", func(t *testing.T) {- cfg := &config.Config{+ cfg := &RuntimeConfig{AgentMode: true,AgentToken: "",}@@ -65,7 +64,7 @@ func TestLoadAgentToken(t *testing.T) {})t.Run("does not load when not in agent mode", func(t *testing.T) {- cfg := &config.Config{+ cfg := &RuntimeConfig{AgentMode: false,AgentToken: "",}@@ -79,7 +78,7 @@ func TestLoadAgentToken(t *testing.T) {})t.Run("does not override existing token", func(t *testing.T) {- cfg := &config.Config{+ cfg := &RuntimeConfig{AgentMode: true,AgentToken: "existing-token",}@@ -93,7 +92,7 @@ func TestLoadAgentToken(t *testing.T) {})t.Run("handles empty token from database", func(t *testing.T) {- cfg := &config.Config{+ cfg := &RuntimeConfig{AgentMode: true,AgentToken: "",}@@ -111,7 +110,7 @@ func TestEnsureEncryptionKey(t *testing.T) {ctx := context.Background()t.Run("sets key in agent mode", func(t *testing.T) {- cfg := &config.Config{+ cfg := &RuntimeConfig{AgentMode: true,EncryptionKey: "",}@@ -125,7 +124,7 @@ func TestEnsureEncryptionKey(t *testing.T) {})t.Run("sets key in non-production", func(t *testing.T) {- cfg := &config.Config{+ cfg := &RuntimeConfig{AgentMode: false,Environment: "development",EncryptionKey: "",@@ -140,7 +139,7 @@ func TestEnsureEncryptionKey(t *testing.T) {})t.Run("does not set key in production when not agent", func(t *testing.T) {- cfg := &config.Config{+ cfg := &RuntimeConfig{AgentMode: false,Environment: "production",EncryptionKey: "",@@ -155,7 +154,7 @@ func TestEnsureEncryptionKey(t *testing.T) {})t.Run("handles error gracefully", func(t *testing.T) {- cfg := &config.Config{+ cfg := &RuntimeConfig{AgentMode: true,EncryptionKey: "",}@@ -171,7 +170,7 @@ func TestEnsureEncryptionKey(t *testing.T) {func TestInitializeDefaultSettings(t *testing.T) {ctx := context.Background()- cfg := &config.Config{}+ cfg := &RuntimeConfig{}t.Run("calls all initialization methods", func(t *testing.T) {mgr := &mockSettingsManager{}@@ -255,7 +254,7 @@ func TestInitializeNonAgentFeatures(t *testing.T) {ctx := context.Background()t.Run("skips in agent mode", func(t *testing.T) {- cfg := &config.Config{AgentMode: true}+ cfg := &RuntimeConfig{AgentMode: true}createAdminCalled := falsecreateAdminFunc := func(ctx context.Context) error {createAdminCalled = true@@ -268,7 +267,7 @@ func TestInitializeNonAgentFeatures(t *testing.T) {})t.Run("calls all functions in non-agent mode", func(t *testing.T) {- cfg := &config.Config{AgentMode: false}+ cfg := &RuntimeConfig{AgentMode: false}createAdminCalled := falsemigrateOidcCalled := falsemigrateDiscordCalled := false@@ -300,7 +299,7 @@ func TestInitializeNonAgentFeatures(t *testing.T) {})t.Run("handles errors gracefully", func(t *testing.T) {- cfg := &config.Config{AgentMode: false}+ cfg := &RuntimeConfig{AgentMode: false}autoLoginInitFunc := func(ctx context.Context) error {return errors.New("autologin init failed")}diff --git a/backend/internal/utils/timeouts/timeouts.go b/backend/pkg/libarcane/timeouts/timeouts.gosimilarity index 100%rename from backend/internal/utils/timeouts/timeouts.gorename to backend/pkg/libarcane/timeouts/timeouts.godiff --git a/backend/pkg/libarcane/updater/digest.go b/backend/pkg/libarcane/updater/digest.goindex 720f04365..03afa21bd 100644--- a/backend/pkg/libarcane/updater/digest.go+++ b/backend/pkg/libarcane/updater/digest.go@@ -9,7 +9,7 @@ import ("github.com/moby/moby/client"ref "go.podman.io/image/v5/docker/reference"- "github.com/getarcaneapp/arcane/backend/internal/utils/registry"+ "github.com/getarcaneapp/arcane/backend/pkg/utils/registry")type remoteDigestResolver interface {diff --git a/backend/internal/utils/ws/benchmark_test.go b/backend/pkg/libarcane/ws/benchmark_test.gosimilarity index 100%rename from backend/internal/utils/ws/benchmark_test.gorename to backend/pkg/libarcane/ws/benchmark_test.godiff --git a/backend/internal/utils/ws/bridge.go b/backend/pkg/libarcane/ws/bridge.gosimilarity index 100%rename from backend/internal/utils/ws/bridge.gorename to backend/pkg/libarcane/ws/bridge.godiff --git a/backend/internal/utils/ws/bridge_test.go b/backend/pkg/libarcane/ws/bridge_test.gosimilarity index 100%rename from backend/internal/utils/ws/bridge_test.gorename to backend/pkg/libarcane/ws/bridge_test.godiff --git a/backend/internal/utils/ws/client.go b/backend/pkg/libarcane/ws/client.gosimilarity index 100%rename from backend/internal/utils/ws/client.gorename to backend/pkg/libarcane/ws/client.godiff --git a/backend/internal/utils/ws/client_test.go b/backend/pkg/libarcane/ws/client_test.gosimilarity index 100%rename from backend/internal/utils/ws/client_test.gorename to backend/pkg/libarcane/ws/client_test.godiff --git a/backend/internal/utils/ws/cpu_regression_test.go b/backend/pkg/libarcane/ws/cpu_regression_test.gosimilarity index 100%rename from backend/internal/utils/ws/cpu_regression_test.gorename to backend/pkg/libarcane/ws/cpu_regression_test.godiff --git a/backend/internal/utils/ws/diagnostics.go b/backend/pkg/libarcane/ws/diagnostics.gosimilarity index 100%rename from backend/internal/utils/ws/diagnostics.gorename to backend/pkg/libarcane/ws/diagnostics.godiff --git a/backend/internal/utils/ws/goroutine_leak_test.go b/backend/pkg/libarcane/ws/goroutine_leak_test.gosimilarity index 100%rename from backend/internal/utils/ws/goroutine_leak_test.gorename to backend/pkg/libarcane/ws/goroutine_leak_test.godiff --git a/backend/internal/utils/ws/hub.go b/backend/pkg/libarcane/ws/hub.gosimilarity index 100%rename from backend/internal/utils/ws/hub.gorename to backend/pkg/libarcane/ws/hub.godiff --git a/backend/internal/utils/ws/hub_client_count_test.go b/backend/pkg/libarcane/ws/hub_client_count_test.gosimilarity index 100%rename from backend/internal/utils/ws/hub_client_count_test.gorename to backend/pkg/libarcane/ws/hub_client_count_test.godiff --git a/backend/internal/utils/ws/hub_test.go b/backend/pkg/libarcane/ws/hub_test.gosimilarity index 100%rename from backend/internal/utils/ws/hub_test.gorename to backend/pkg/libarcane/ws/hub_test.godiff --git a/backend/internal/utils/ws/parse.go b/backend/pkg/libarcane/ws/parse.gosimilarity index 100%rename from backend/internal/utils/ws/parse.gorename to backend/pkg/libarcane/ws/parse.godiff --git a/backend/internal/utils/ws/parse_test.go b/backend/pkg/libarcane/ws/parse_test.gosimilarity index 100%rename from backend/internal/utils/ws/parse_test.gorename to backend/pkg/libarcane/ws/parse_test.godiff --git a/backend/internal/utils/ws/proxy.go b/backend/pkg/libarcane/ws/proxy.gosimilarity index 100%rename from backend/internal/utils/ws/proxy.gorename to backend/pkg/libarcane/ws/proxy.godiff --git a/backend/internal/utils/ws/proxy_test.go b/backend/pkg/libarcane/ws/proxy_test.gosimilarity index 100%rename from backend/internal/utils/ws/proxy_test.gorename to backend/pkg/libarcane/ws/proxy_test.godiff --git a/backend/internal/utils/pagination/db_utils.go b/backend/pkg/pagination/db_utils.gosimilarity index 100%rename from backend/internal/utils/pagination/db_utils.gorename to backend/pkg/pagination/db_utils.godiff --git a/backend/internal/utils/pagination/filters.go b/backend/pkg/pagination/filters.gosimilarity index 100%rename from backend/internal/utils/pagination/filters.gorename to backend/pkg/pagination/filters.godiff --git a/backend/internal/utils/pagination/pagination.go b/backend/pkg/pagination/pagination.gosimilarity index 100%rename from backend/internal/utils/pagination/pagination.gorename to backend/pkg/pagination/pagination.godiff --git a/backend/internal/utils/pagination/pagination_test.go b/backend/pkg/pagination/pagination_test.gosimilarity index 100%rename from backend/internal/utils/pagination/pagination_test.gorename to backend/pkg/pagination/pagination_test.godiff --git a/backend/internal/utils/pagination/params.go b/backend/pkg/pagination/params.gosimilarity index 100%rename from backend/internal/utils/pagination/params.gorename to backend/pkg/pagination/params.godiff --git a/backend/internal/utils/pagination/reflect.go b/backend/pkg/pagination/reflect.gosimilarity index 97%rename from backend/internal/utils/pagination/reflect.gorename to backend/pkg/pagination/reflect.goindex b47366df2..d1856526b 100644--- a/backend/internal/utils/pagination/reflect.go+++ b/backend/pkg/pagination/reflect.go@@ -4,7 +4,7 @@ import ("reflect""strconv"- "github.com/getarcaneapp/arcane/backend/internal/utils/stringutils"+ stringutils "github.com/getarcaneapp/arcane/backend/pkg/utils""gorm.io/gorm""gorm.io/gorm/clause")diff --git a/backend/internal/utils/pagination/search.go b/backend/pkg/pagination/search.gosimilarity index 100%rename from backend/internal/utils/pagination/search.gorename to backend/pkg/pagination/search.godiff --git a/backend/internal/utils/pagination/sort.go b/backend/pkg/pagination/sort.gosimilarity index 100%rename from backend/internal/utils/pagination/sort.gorename to backend/pkg/pagination/sort.godiff --git a/backend/internal/utils/pagination/types.go b/backend/pkg/pagination/types.gosimilarity index 100%rename from backend/internal/utils/pagination/types.gorename to backend/pkg/pagination/types.godiff --git a/backend/pkg/projects/env.go b/backend/pkg/projects/env.goindex cd0eee82d..dc6bd797d 100644--- a/backend/pkg/projects/env.go+++ b/backend/pkg/projects/env.go@@ -14,7 +14,7 @@ import ("time""github.com/compose-spec/compose-go/v2/dotenv"- "github.com/getarcaneapp/arcane/backend/internal/common"+ pkgutils "github.com/getarcaneapp/arcane/backend/pkg/utils")const (@@ -104,10 +104,10 @@ func (l *EnvLoader) ensureGlobalEnvFile(ctx context.Context, path string) errorif _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {header := fmt.Sprintf(globalEnvHeader, time.Now().Format(time.RFC3339))dir := filepath.Dir(path)- if err := os.MkdirAll(dir, common.DirPerm); err != nil {+ if err := os.MkdirAll(dir, pkgutils.DirPerm); err != nil {return fmt.Errorf("create dir: %w", err)}- if err := os.WriteFile(path, []byte(header), common.FilePerm); err != nil {+ if err := os.WriteFile(path, []byte(header), pkgutils.FilePerm); err != nil {return fmt.Errorf("write file: %w", err)}slog.InfoContext(ctx, "Created global env file", "path", path)diff --git a/backend/pkg/projects/env_test.go b/backend/pkg/projects/env_test.goindex c45a3bfe1..0afadb11f 100644--- a/backend/pkg/projects/env_test.go+++ b/backend/pkg/projects/env_test.go@@ -6,7 +6,7 @@ import ("path/filepath""testing"- "github.com/getarcaneapp/arcane/backend/internal/common"+ pkgutils "github.com/getarcaneapp/arcane/backend/pkg/utils""github.com/stretchr/testify/assert""github.com/stretchr/testify/require")@@ -17,17 +17,17 @@ func TestLoadEnvironment(t *testing.T) {projectsDir := filepath.Join(tmpDir, "projects")workdir := filepath.Join(projectsDir, "myproject")- err := os.MkdirAll(workdir, common.DirPerm)+ err := os.MkdirAll(workdir, pkgutils.DirPerm)require.NoError(t, err)// Create .env.globalglobalEnvContent := "GLOBAL_VAR=global_value\nSHARED_VAR=global_shared"- err = os.WriteFile(filepath.Join(projectsDir, ".env.global"), []byte(globalEnvContent), common.FilePerm)+ err = os.WriteFile(filepath.Join(projectsDir, ".env.global"), []byte(globalEnvContent), pkgutils.FilePerm)require.NoError(t, err)// Create .envprojectEnvContent := "PROJECT_VAR=project_value\nSHARED_VAR=project_shared"- err = os.WriteFile(filepath.Join(workdir, ".env"), []byte(projectEnvContent), common.FilePerm)+ err = os.WriteFile(filepath.Join(workdir, ".env"), []byte(projectEnvContent), pkgutils.FilePerm)require.NoError(t, err)t.Run("AutoInjectEnv=false", func(t *testing.T) {@@ -140,7 +140,7 @@ func TestBuildOverrideEnvContent(t *testing.T) {func TestReadProjectEnvState(t *testing.T) {t.Run("direct mode uses .env as editable source", func(t *testing.T) {projectDir := t.TempDir()- require.NoError(t, os.WriteFile(filepath.Join(projectDir, EffectiveEnvFileName), []byte("FOO=bar\n"), common.FilePerm))+ require.NoError(t, os.WriteFile(filepath.Join(projectDir, EffectiveEnvFileName), []byte("FOO=bar\n"), pkgutils.FilePerm))state, err := ReadProjectEnvState(projectDir)require.NoError(t, err)@@ -153,9 +153,9 @@ func TestReadProjectEnvState(t *testing.T) {t.Run("override mode exposes project.env and git source separately", func(t *testing.T) {projectDir := t.TempDir()- require.NoError(t, os.WriteFile(filepath.Join(projectDir, EffectiveEnvFileName), []byte("A=1\nB=2\n"), common.FilePerm))- require.NoError(t, os.WriteFile(filepath.Join(projectDir, GitSourceEnvFileName), []byte("A=1\n"), common.FilePerm))- require.NoError(t, os.WriteFile(filepath.Join(projectDir, OverrideEnvFileName), []byte("B=2\n"), common.FilePerm))+ require.NoError(t, os.WriteFile(filepath.Join(projectDir, EffectiveEnvFileName), []byte("A=1\nB=2\n"), pkgutils.FilePerm))+ require.NoError(t, os.WriteFile(filepath.Join(projectDir, GitSourceEnvFileName), []byte("A=1\n"), pkgutils.FilePerm))+ require.NoError(t, os.WriteFile(filepath.Join(projectDir, OverrideEnvFileName), []byte("B=2\n"), pkgutils.FilePerm))state, err := ReadProjectEnvState(projectDir)require.NoError(t, err)diff --git a/backend/internal/utils/template/parser.go b/backend/pkg/projects/env_variables.gosimilarity index 98%rename from backend/internal/utils/template/parser.gorename to backend/pkg/projects/env_variables.goindex 4e83bfd38..999b07845 100644--- a/backend/internal/utils/template/parser.go+++ b/backend/pkg/projects/env_variables.go@@ -1,4 +1,4 @@-package template+package projectsimport ("bufio"diff --git a/backend/internal/utils/fs/fs_templates.go b/backend/pkg/projects/fs_templates.gosimilarity index 96%rename from backend/internal/utils/fs/fs_templates.gorename to backend/pkg/projects/fs_templates.goindex a2a0940f6..17ea68869 100644--- a/backend/internal/utils/fs/fs_templates.go+++ b/backend/pkg/projects/fs_templates.go@@ -1,4 +1,4 @@-package fs+package projectsimport ("context"@@ -8,7 +8,7 @@ import ("regexp""strings"- "github.com/getarcaneapp/arcane/backend/internal/common"+ pkgutils "github.com/getarcaneapp/arcane/backend/pkg/utils")func ReadFolderComposeTemplate(baseDir, folder string) (string, *string, string, bool, error) {@@ -57,7 +57,7 @@ func EnsureTemplateDir(ctx context.Context, base string) (dir, composePath, envPreturn "", "", "", fmt.Errorf("ensure templates dir: %w", derr)}dir = filepath.Join(baseDir, base)- if err := os.MkdirAll(dir, common.DirPerm); err != nil {+ if err := os.MkdirAll(dir, pkgutils.DirPerm); err != nil {return "", "", "", fmt.Errorf("failed to create template directory: %w", err)}composePath = filepath.Join(dir, "compose.yaml")diff --git a/backend/internal/utils/fs/fs_util.go b/backend/pkg/projects/fs_util.gosimilarity index 89%rename from backend/internal/utils/fs/fs_util.gorename to backend/pkg/projects/fs_util.goindex f28757ee7..c9cd0221e 100644--- a/backend/internal/utils/fs/fs_util.go+++ b/backend/pkg/projects/fs_util.go@@ -1,4 +1,4 @@-package fs+package projectsimport ("context"@@ -8,9 +8,7 @@ import ("path/filepath""strings"- "github.com/getarcaneapp/arcane/backend/internal/common"- "github.com/getarcaneapp/arcane/backend/internal/utils/pathmapper"- "github.com/getarcaneapp/arcane/backend/pkg/projects"+ pkgutils "github.com/getarcaneapp/arcane/backend/pkg/utils")func GetProjectsDirectory(ctx context.Context, projectsDir string) (string, error) {@@ -21,7 +19,7 @@ func GetProjectsDirectory(ctx context.Context, projectsDir string) (string, erro// Handle mapping format: "container_path:host_path"if parts := strings.SplitN(projectsDirectory, ":", 2); len(parts) == 2 {- if !pathmapper.IsWindowsDrivePath(projectsDirectory) && strings.HasPrefix(parts[0], "/") { // First part must be absolute container path+ if !IsWindowsDrivePath(projectsDirectory) && strings.HasPrefix(parts[0], "/") { // First part must be absolute container pathprojectsDirectory = parts[0]}}@@ -37,7 +35,7 @@ func GetProjectsDirectory(ctx context.Context, projectsDir string) (string, erro}if _, err := os.Stat(projectsDirectory); os.IsNotExist(err) {- if err := os.MkdirAll(projectsDirectory, common.DirPerm); err != nil {+ if err := os.MkdirAll(projectsDirectory, pkgutils.DirPerm); err != nil {return "", err}slog.InfoContext(ctx, "Created projects directory", "path", projectsDirectory)@@ -47,7 +45,7 @@ func GetProjectsDirectory(ctx context.Context, projectsDir string) (string, erro}func ReadProjectFiles(projectPath string) (composeContent, envContent string, err error) {- if composeFile, derr := projects.DetectComposeFile(projectPath); derr == nil && composeFile != "" {+ if composeFile, derr := DetectComposeFile(projectPath); derr == nil && composeFile != "" {if content, rerr := os.ReadFile(composeFile); rerr == nil {composeContent = string(content)}@@ -64,7 +62,7 @@ func ReadProjectFiles(projectPath string) (composeContent, envContent string, erfunc GetTemplatesDirectory(ctx context.Context) (string, error) {templatesDir := filepath.Join("data", "templates")if _, err := os.Stat(templatesDir); os.IsNotExist(err) {- if err := os.MkdirAll(templatesDir, common.DirPerm); err != nil {+ if err := os.MkdirAll(templatesDir, pkgutils.DirPerm); err != nil {return "", err}slog.InfoContext(ctx, "Created templates directory", "path", templatesDir)diff --git a/backend/internal/utils/fs/fs_writer.go b/backend/pkg/projects/fs_writer.gosimilarity index 91%rename from backend/internal/utils/fs/fs_writer.gorename to backend/pkg/projects/fs_writer.goindex b4710d957..7517fcf3f 100644--- a/backend/internal/utils/fs/fs_writer.go+++ b/backend/pkg/projects/fs_writer.go@@ -1,4 +1,4 @@-package fs+package projectsimport ("errors"@@ -7,7 +7,7 @@ import ("path/filepath""strings"- "github.com/getarcaneapp/arcane/backend/internal/common"+ pkgutils "github.com/getarcaneapp/arcane/backend/pkg/utils")var composeFileCandidates = []string{@@ -53,7 +53,7 @@ func WriteComposeFile(projectsRoot, dirPath, content string) error {return fmt.Errorf("refusing to write compose file: path outside projects root")}- if err := os.MkdirAll(dirPath, common.DirPerm); err != nil {+ if err := os.MkdirAll(dirPath, pkgutils.DirPerm); err != nil {return fmt.Errorf("failed to create directory: %w", err)}@@ -64,7 +64,7 @@ func WriteComposeFile(projectsRoot, dirPath, content string) error {composePath = filepath.Join(dirPath, "compose.yaml")}- if err := os.WriteFile(composePath, []byte(content), common.FilePerm); err != nil {+ if err := os.WriteFile(composePath, []byte(content), pkgutils.FilePerm); err != nil {return fmt.Errorf("failed to write compose file: %w", err)}@@ -90,7 +90,7 @@ func WriteProjectFile(projectsRoot, dirPath, fileName, content string) error {return fmt.Errorf("refusing to write project file: path outside projects root")}- if err := os.MkdirAll(dirPath, common.DirPerm); err != nil {+ if err := os.MkdirAll(dirPath, pkgutils.DirPerm); err != nil {return fmt.Errorf("failed to create directory: %w", err)}@@ -99,7 +99,7 @@ func WriteProjectFile(projectsRoot, dirPath, fileName, content string) error {}targetPath := filepath.Join(dirPath, fileName)- if err := os.WriteFile(targetPath, []byte(content), common.FilePerm); err != nil {+ if err := os.WriteFile(targetPath, []byte(content), pkgutils.FilePerm); err != nil {return fmt.Errorf("failed to write project file %s: %w", fileName, err)}@@ -180,11 +180,11 @@ func WriteProjectFiles(projectsRoot, dirPath, composeContent string, envContent// WriteTemplateFile writes a template file (like .compose.template or .env.template)func WriteTemplateFile(filePath, content string) error {dir := filepath.Dir(filePath)- if err := os.MkdirAll(dir, common.DirPerm); err != nil {+ if err := os.MkdirAll(dir, pkgutils.DirPerm); err != nil {return fmt.Errorf("failed to create template directory: %w", err)}- if err := os.WriteFile(filePath, []byte(content), common.FilePerm); err != nil {+ if err := os.WriteFile(filePath, []byte(content), pkgutils.FilePerm); err != nil {return fmt.Errorf("failed to write template file: %w", err)}@@ -194,7 +194,7 @@ func WriteTemplateFile(filePath, content string) error {// WriteFileWithPerm is a generic file writer with custom permissionsfunc WriteFileWithPerm(filePath, content string, perm os.FileMode) error {dir := filepath.Dir(filePath)- if err := os.MkdirAll(dir, common.DirPerm); err != nil {+ if err := os.MkdirAll(dir, pkgutils.DirPerm); err != nil {return fmt.Errorf("failed to create directory: %w", err)}diff --git a/backend/internal/utils/fs/fs_writer_test.go b/backend/pkg/projects/fs_writer_test.gosimilarity index 92%rename from backend/internal/utils/fs/fs_writer_test.gorename to backend/pkg/projects/fs_writer_test.goindex 23433ea91..f7017c116 100644--- a/backend/internal/utils/fs/fs_writer_test.go+++ b/backend/pkg/projects/fs_writer_test.go@@ -1,4 +1,4 @@-package fs+package projectsimport ("os"@@ -6,18 +6,18 @@ import ("runtime""testing"- "github.com/getarcaneapp/arcane/backend/internal/common"+ pkgutils "github.com/getarcaneapp/arcane/backend/pkg/utils""github.com/stretchr/testify/assert""github.com/stretchr/testify/require")func TestWriteFilesPermissions(t *testing.T) {// Save original perms- origFilePerm := common.FilePerm- origDirPerm := common.DirPerm+ origFilePerm := pkgutils.FilePerm+ origDirPerm := pkgutils.DirPermdefer func() {- common.FilePerm = origFilePerm- common.DirPerm = origDirPerm+ pkgutils.FilePerm = origFilePerm+ pkgutils.DirPerm = origDirPerm}()tmpDir := t.TempDir()@@ -25,8 +25,8 @@ func TestWriteFilesPermissions(t *testing.T) {projectDir := filepath.Join(tmpDir, "test-project")t.Run("WriteComposeFile uses custom permissions", func(t *testing.T) {- common.FilePerm = 0o600- common.DirPerm = 0o700+ pkgutils.FilePerm = 0o600+ pkgutils.DirPerm = 0o700err := WriteComposeFile(projectsRoot, projectDir, "services: {}")require.NoError(t, err)@@ -45,8 +45,8 @@ func TestWriteFilesPermissions(t *testing.T) {})t.Run("WriteEnvFile uses custom permissions", func(t *testing.T) {- common.FilePerm = 0o600- common.DirPerm = 0o700+ pkgutils.FilePerm = 0o600+ pkgutils.DirPerm = 0o700err := WriteEnvFile(projectsRoot, projectDir, "VAR=VAL")require.NoError(t, err)diff --git a/backend/pkg/projects/includes.go b/backend/pkg/projects/includes.goindex 2f1373076..3bafc4c19 100644--- a/backend/pkg/projects/includes.go+++ b/backend/pkg/projects/includes.go@@ -7,7 +7,7 @@ import ("path/filepath""strings"- "github.com/getarcaneapp/arcane/backend/internal/common"+ pkgutils "github.com/getarcaneapp/arcane/backend/pkg/utils""github.com/goccy/go-yaml")@@ -190,12 +190,12 @@ func WriteIncludeFile(projectDir, includePath, content string) error {// Only create directory if it doesn't existif _, err := os.Stat(dir); errors.Is(err, os.ErrNotExist) {- if err := os.MkdirAll(dir, common.DirPerm); err != nil {+ if err := os.MkdirAll(dir, pkgutils.DirPerm); err != nil {return fmt.Errorf("failed to create directory: %w", err)}}- if err := os.WriteFile(validatedPath, []byte(content), common.FilePerm); err != nil {+ if err := os.WriteFile(validatedPath, []byte(content), pkgutils.FilePerm); err != nil {return fmt.Errorf("failed to write include file: %w", err)}diff --git a/backend/pkg/projects/includes_test.go b/backend/pkg/projects/includes_test.goindex 3991dcd2f..2e147af19 100644--- a/backend/pkg/projects/includes_test.go+++ b/backend/pkg/projects/includes_test.go@@ -6,16 +6,16 @@ import ("runtime""testing"- "github.com/getarcaneapp/arcane/backend/internal/common"+ pkgutils "github.com/getarcaneapp/arcane/backend/pkg/utils")func TestWriteIncludeFilePermissions(t *testing.T) {// Save original perms- origFilePerm := common.FilePerm- origDirPerm := common.DirPerm+ origFilePerm := pkgutils.FilePerm+ origDirPerm := pkgutils.DirPermdefer func() {- common.FilePerm = origFilePerm- common.DirPerm = origDirPerm+ pkgutils.FilePerm = origFilePerm+ pkgutils.DirPerm = origDirPerm}()projectDir := t.TempDir()@@ -23,8 +23,8 @@ func TestWriteIncludeFilePermissions(t *testing.T) {content := "services: {}\n"t.Run("Uses custom permissions", func(t *testing.T) {- common.FilePerm = 0o600- common.DirPerm = 0o700+ pkgutils.FilePerm = 0o600+ pkgutils.DirPerm = 0o700if err := WriteIncludeFile(projectDir, includePath, content); err != nil {t.Fatalf("WriteIncludeFile() returned error: %v", err)diff --git a/backend/pkg/projects/load.go b/backend/pkg/projects/load.goindex 9d8df604f..a1218a87e 100644--- a/backend/pkg/projects/load.go+++ b/backend/pkg/projects/load.go@@ -12,7 +12,6 @@ import ("github.com/compose-spec/compose-go/v2/loader"composetypes "github.com/compose-spec/compose-go/v2/types""github.com/docker/compose/v5/pkg/api"- "github.com/getarcaneapp/arcane/backend/internal/utils/pathmapper")var ProjectFileCandidates = []string{@@ -51,7 +50,7 @@ func DetectComposeFile(dir string) (string, error) {return compose, nil}-func LoadComposeProject(ctx context.Context, composeFile, projectName, projectsDirectory string, autoInjectEnv bool, pathMapper *pathmapper.PathMapper) (*composetypes.Project, error) {+func LoadComposeProject(ctx context.Context, composeFile, projectName, projectsDirectory string, autoInjectEnv bool, pathMapper *PathMapper) (*composetypes.Project, error) {return loadComposeProjectInternal(ctx, composeFile, projectName, projectsDirectory, autoInjectEnv, pathMapper, nil, nil)}@@ -61,7 +60,7 @@ func loadComposeProjectInternal(projectName string,projectsDirectory string,autoInjectEnv bool,- pathMapper *pathmapper.PathMapper,+ pathMapper *PathMapper,envOverride EnvMap,configureLoader func(*loader.Options),) (project *composetypes.Project, err error) {@@ -172,7 +171,7 @@ func injectServiceConfiguration(project *composetypes.Project, injectionVars Env}}-func LoadComposeProjectFromDir(ctx context.Context, dir, projectName, projectsDirectory string, autoInjectEnv bool, pathMapper *pathmapper.PathMapper) (*composetypes.Project, string, error) {+func LoadComposeProjectFromDir(ctx context.Context, dir, projectName, projectsDirectory string, autoInjectEnv bool, pathMapper *PathMapper) (*composetypes.Project, string, error) {composeFile, err := DetectComposeFile(dir)if err != nil {return nil, "", errdiff --git a/backend/internal/utils/pathmapper/path_mapper.go b/backend/pkg/projects/path_mapper.gosimilarity index 99%rename from backend/internal/utils/pathmapper/path_mapper.gorename to backend/pkg/projects/path_mapper.goindex f510ea133..4a6965dba 100644--- a/backend/internal/utils/pathmapper/path_mapper.go+++ b/backend/pkg/projects/path_mapper.go@@ -1,4 +1,4 @@-package pathmapper+package projectsimport ("fmt"diff --git a/backend/internal/utils/pathmapper/path_mapper_test.go b/backend/pkg/projects/path_mapper_test.gosimilarity index 99%rename from backend/internal/utils/pathmapper/path_mapper_test.gorename to backend/pkg/projects/path_mapper_test.goindex 23cddf25d..55a19ede9 100644--- a/backend/internal/utils/pathmapper/path_mapper_test.go+++ b/backend/pkg/projects/path_mapper_test.go@@ -1,4 +1,4 @@-package pathmapper+package projectsimport ("testing"diff --git a/backend/pkg/scheduler/filesystem_watcher_job.go b/backend/pkg/scheduler/filesystem_watcher_job.goindex a6900c336..8c58c7231 100644--- a/backend/pkg/scheduler/filesystem_watcher_job.go+++ b/backend/pkg/scheduler/filesystem_watcher_job.go@@ -6,15 +6,16 @@ import ("time""github.com/getarcaneapp/arcane/backend/internal/services"- "github.com/getarcaneapp/arcane/backend/internal/utils/fs"+ "github.com/getarcaneapp/arcane/backend/pkg/fswatch"+ "github.com/getarcaneapp/arcane/backend/pkg/projects")type FilesystemWatcherJob struct {projectService *services.ProjectServicetemplateService *services.TemplateServicesettingsService *services.SettingsService- projectsWatcher *fs.Watcher- templatesWatcher *fs.Watcher+ projectsWatcher *fswatch.Watcher+ templatesWatcher *fswatch.Watcher}func NewFilesystemWatcherJob(@@ -47,12 +48,12 @@ func (j *FilesystemWatcherJob) Start(ctx context.Context) error {if err != nil {return err}- projectsDirectory, err := fs.GetProjectsDirectory(ctx, settings.ProjectsDirectory.Value)+ projectsDirectory, err := projects.GetProjectsDirectory(ctx, settings.ProjectsDirectory.Value)if err != nil {return err}- sw, err := fs.NewWatcher(projectsDirectory, fs.WatcherOptions{+ sw, err := fswatch.NewWatcher(projectsDirectory, fswatch.WatcherOptions{Debounce: 3 * time.Second, // Wait 3 seconds after last change before syncingOnChange: j.handleFilesystemChange,MaxDepth: 1,@@ -63,13 +64,13 @@ func (j *FilesystemWatcherJob) Start(ctx context.Context) error {j.projectsWatcher = sw- templatesDir, err := fs.GetTemplatesDirectory(ctx)+ templatesDir, err := projects.GetTemplatesDirectory(ctx)if err != nil {return err}if j.templateService != nil {- tw, err := fs.NewWatcher(templatesDir, fs.WatcherOptions{+ tw, err := fswatch.NewWatcher(templatesDir, fswatch.WatcherOptions{Debounce: 3 * time.Second,OnChange: j.handleTemplatesChange,MaxDepth: 1,@@ -167,13 +168,13 @@ func (j *FilesystemWatcherJob) RestartProjectsWatcher(ctx context.Context) errorif err != nil {return err}- projectsDirectory, err := fs.GetProjectsDirectory(ctx, settings.ProjectsDirectory.Value)+ projectsDirectory, err := projects.GetProjectsDirectory(ctx, settings.ProjectsDirectory.Value)if err != nil {return err}// Create a new watcher with the updated path- sw, err := fs.NewWatcher(projectsDirectory, fs.WatcherOptions{+ sw, err := fswatch.NewWatcher(projectsDirectory, fswatch.WatcherOptions{Debounce: 3 * time.Second,OnChange: j.handleFilesystemChange,MaxDepth: 1,diff --git a/backend/internal/utils/cache/cache_util.go b/backend/pkg/utils/cache/cache_util.gosimilarity index 100%rename from backend/internal/utils/cache/cache_util.gorename to backend/pkg/utils/cache/cache_util.godiff --git a/backend/internal/utils/cookie/cookie_util.go b/backend/pkg/utils/cookie/cookie_util.gosimilarity index 100%rename from backend/internal/utils/cookie/cookie_util.gorename to backend/pkg/utils/cookie/cookie_util.godiff --git a/backend/internal/utils/http/client.go b/backend/pkg/utils/httpx/client.gosimilarity index 98%rename from backend/internal/utils/http/client.gorename to backend/pkg/utils/httpx/client.goindex 27966fca8..644180e99 100644--- a/backend/internal/utils/http/client.go+++ b/backend/pkg/utils/httpx/client.go@@ -1,4 +1,4 @@-package http+package httpximport ("net/http"diff --git a/backend/internal/utils/http/request.go b/backend/pkg/utils/httpx/request.gosimilarity index 99%rename from backend/internal/utils/http/request.gorename to backend/pkg/utils/httpx/request.goindex 7804dbe3e..9d2f386f0 100644--- a/backend/internal/utils/http/request.go+++ b/backend/pkg/utils/httpx/request.go@@ -1,4 +1,4 @@-package http+package httpximport ("fmt"diff --git a/backend/internal/utils/image/image_util.go b/backend/pkg/utils/image/image_util.gosimilarity index 100%rename from backend/internal/utils/image/image_util.gorename to backend/pkg/utils/image/image_util.godiff --git a/backend/internal/utils/crypto/jwt.go b/backend/pkg/utils/jwtclaims/jwt.gosimilarity index 99%rename from backend/internal/utils/crypto/jwt.gorename to backend/pkg/utils/jwtclaims/jwt.goindex f140ef494..9b0bb992f 100644--- a/backend/internal/utils/crypto/jwt.go+++ b/backend/pkg/utils/jwtclaims/jwt.go@@ -1,4 +1,4 @@-package crypto+package jwtclaimsimport ("crypto/rand"diff --git a/backend/internal/utils/mapper/mapper.go b/backend/pkg/utils/mapper/mapper.gosimilarity index 100%rename from backend/internal/utils/mapper/mapper.gorename to backend/pkg/utils/mapper/mapper.godiff --git a/backend/pkg/utils/perms.go b/backend/pkg/utils/perms.gonew file mode 100644index 000000000..1044496ec--- /dev/null+++ b/backend/pkg/utils/perms.go@@ -0,0 +1,8 @@+package utils++import "os"++var (+ FilePerm os.FileMode = 0o644+ DirPerm os.FileMode = 0o755+)diff --git a/backend/internal/utils/ptr_util.go b/backend/pkg/utils/ptr_util.gosimilarity index 100%rename from backend/internal/utils/ptr_util.gorename to backend/pkg/utils/ptr_util.godiff --git a/backend/internal/utils/reflection.go b/backend/pkg/utils/reflection.gosimilarity index 100%rename from backend/internal/utils/reflection.gorename to backend/pkg/utils/reflection.godiff --git a/backend/internal/utils/registry/constants.go b/backend/pkg/utils/registry/constants.gosimilarity index 100%rename from backend/internal/utils/registry/constants.gorename to backend/pkg/utils/registry/constants.godiff --git a/backend/internal/utils/registry/helpers.go b/backend/pkg/utils/registry/helpers.gosimilarity index 100%rename from backend/internal/utils/registry/helpers.gorename to backend/pkg/utils/registry/helpers.godiff --git a/backend/internal/utils/registry/helpers_test.go b/backend/pkg/utils/registry/helpers_test.gosimilarity index 100%rename from backend/internal/utils/registry/helpers_test.gorename to backend/pkg/utils/registry/helpers_test.godiff --git a/backend/internal/utils/signals/signals.go b/backend/pkg/utils/signals/signals.gosimilarity index 100%rename from backend/internal/utils/signals/signals.gorename to backend/pkg/utils/signals/signals.godiff --git a/backend/pkg/utils/stdcopy/stdcopy.go b/backend/pkg/utils/stdcopy/stdcopy.godeleted file mode 100644index 51b4e3be1..000000000--- a/backend/pkg/utils/stdcopy/stdcopy.go+++ /dev/null@@ -1,205 +0,0 @@-// Package stdcopy is derived from Moby's stdcopy implementation.-//-// Source: https://github.com/moby/moby/blob/v28.5.2/pkg/stdcopy/stdcopy.go-// License: Apache License 2.0-// SPDX-License-Identifier: Apache-2.0-//-// Modified to fix lint errors-// This local copy is vendored to avoid pulling conflicting module variants-// during dependency resolution in this monorepo.-package stdcopy--import (- "bytes"- "encoding/binary"- "errors"- "fmt"- "io"- "math"- "sync"-)--// StdType is the type of standard stream-// a writer can multiplex to.-type StdType byte--const (- // Stdin represents standard input stream type.- Stdin StdType = iota- // Stdout represents standard output stream type.- Stdout- // Stderr represents standard error steam type.- Stderr- // Systemerr represents errors originating from the system that make it- // into the multiplexed stream.- Systemerr-- stdWriterPrefixLen = 8- stdWriterFdIndex = 0- stdWriterSizeIndex = 4-- startingBufLen = 32*1024 + stdWriterPrefixLen + 1-)--var bufPool = &sync.Pool{New: func() any { return bytes.NewBuffer(nil) }}--// stdWriter is wrapper of io.Writer with extra customized info.-type stdWriter struct {- io.Writer- prefix byte-}--// Write sends the buffer to the underneath writer.-// It inserts the prefix header before the buffer,-// so stdcopy.StdCopy knows where to multiplex the output.-// It makes stdWriter to implement io.Writer.-func (w *stdWriter) Write(p []byte) (int, error) {- if w == nil || w.Writer == nil {- return 0, errors.New("writer not instantiated")- }- if p == nil {- return 0, nil- }- frameSize := uint64(len(p))- if frameSize > math.MaxUint32 {- return 0, fmt.Errorf("message too large for stdcopy frame: %d bytes", frameSize)- }-- header := [stdWriterPrefixLen]byte{stdWriterFdIndex: w.prefix}- binary.BigEndian.PutUint32(header[stdWriterSizeIndex:], uint32(frameSize))- buf := bufPool.Get().(*bytes.Buffer)- buf.Write(header[:])- buf.Write(p)-- n, err := w.Writer.Write(buf.Bytes())- n -= stdWriterPrefixLen- if n < 0 {- n = 0- }-- buf.Reset()- bufPool.Put(buf)- return n, err-}--// NewStdWriter instantiates a new Writer.-// Everything written to it will be encapsulated using a custom format,-// and written to the underlying `w` stream.-// This allows multiple write streams (e.g. stdout and stderr) to be muxed into a single connection.-// `t` indicates the id of the stream to encapsulate.-// It can be stdcopy.Stdin, stdcopy.Stdout, stdcopy.Stderr.-func NewStdWriter(w io.Writer, t StdType) io.Writer {- return &stdWriter{- Writer: w,- prefix: byte(t),- }-}--// StdCopy is a modified version of io.Copy.-//-// StdCopy will demultiplex `src`, assuming that it contains two streams,-// previously multiplexed together using a StdWriter instance.-// As it reads from `src`, StdCopy will write to `dstout` and `dsterr`.-//-// StdCopy will read until it hits EOF on `src`. It will then return a nil error.-// In other words: if `err` is non nil, it indicates a real underlying error.-//-// `written` will hold the total number of bytes written to `dstout` and `dsterr`.-func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, _ error) {- var (- buf = make([]byte, startingBufLen)- nr int- )-- for {- nextNr, err := readUntil(src, buf, nr, stdWriterPrefixLen)- if err != nil {- if errors.Is(err, io.EOF) {- return written, nil- }- return 0, err- }- nr = nextNr-- stream := StdType(buf[stdWriterFdIndex])- out, err := streamWriter(stream, dstout, dsterr)- if err != nil {- return 0, err- }-- // Retrieve the size of the frame- frameSize := int(binary.BigEndian.Uint32(buf[stdWriterSizeIndex : stdWriterSizeIndex+4]))-- // Check if the buffer is big enough to read the frame.- // Extend it if necessary.- required := frameSize + stdWriterPrefixLen- if required > len(buf) {- buf = append(buf, make([]byte, required-len(buf)+1)...)- }-- nextNr, err = readUntil(src, buf, nr, required)- if err != nil {- if errors.Is(err, io.EOF) {- return written, nil- }- return 0, err- }- nr = nextNr-- // we might have an error from the source mixed up in our multiplexed- // stream. if we do, return it.- payload := buf[stdWriterPrefixLen:required]- if stream == Systemerr {- return written, fmt.Errorf("error from daemon in stream: %s", string(payload))- }-- // Write the retrieved frame (without header)- nw, err := out.Write(payload)- if err != nil {- return 0, err- }-- // If the frame has not been fully written: error- if nw != frameSize {- return 0, io.ErrShortWrite- }- written += int64(nw)-- // Move the rest of the buffer to the beginning- copy(buf, buf[required:nr])- // Move the index- nr -= required- }-}--func readUntil(src io.Reader, buf []byte, current, required int) (int, error) {- n := current- for n < required {- nr, err := src.Read(buf[n:])- n += nr- if errors.Is(err, io.EOF) {- if n < required {- return n, io.EOF- }- return n, nil- }- if err != nil {- return n, err- }- }-- return n, nil-}--func streamWriter(stream StdType, dstout, dsterr io.Writer) (io.Writer, error) {- switch stream {- case Stdin, Stdout:- return dstout, nil- case Stderr:- return dsterr, nil- case Systemerr:- return nil, nil- default:- return nil, fmt.Errorf("unrecognized input header: %d", stream)- }-}diff --git a/backend/pkg/utils/strings.go b/backend/pkg/utils/strings.goindex c5efa55de..71f5e57d6 100644--- a/backend/pkg/utils/strings.go+++ b/backend/pkg/utils/strings.go@@ -1,7 +1,8 @@-// New string utilties, will move the rest over time.package utilsimport (+ "crypto/rand"+ "encoding/base64""fmt""strings")@@ -108,3 +109,51 @@ func FirstNonEmpty(values ...string) string {}return ""}++func CapitalizeFirstLetter(str string) string {+ if len(str) == 0 {+ return str+ }+ return strings.ToUpper(str[:1]) + str[1:]+}++func CamelCaseToSnakeCase(str string) string {+ var result strings.Builder+ for i, r := range str {+ if i > 0 && r >= 'A' && r <= 'Z' {+ result.WriteRune('_')+ }+ result.WriteRune(r)+ }+ return strings.ToLower(result.String())+}++func CamelCaseToScreamingSnakeCase(s string) string {+ return strings.ToUpper(CamelCaseToSnakeCase(s))+}++func GenerateRandomString(length int) string {+ bytes := make([]byte, length)+ if _, err := rand.Read(bytes); err != nil {+ panic(err)+ }+ return base64.URLEncoding.EncodeToString(bytes)[:length]+}++func TrimQuotes(s string) string {+ if len(s) >= 2 {+ if (s[0] == '"' && s[len(s)-1] == '"') || (s[0] == '\'' && s[len(s)-1] == '\'') {+ return s[1 : len(s)-1]+ }+ }+ return s+}++func GetStringOrDefault(m map[string]any, key, defaultValue string) string {+ if val, ok := m[key]; ok {+ if str, ok := val.(string); ok {+ return str+ }+ }+ return defaultValue+}diff --git a/backend/internal/utils/stringutils/stringutils_test.go b/backend/pkg/utils/strings_test.gosimilarity index 99%rename from backend/internal/utils/stringutils/stringutils_test.gorename to backend/pkg/utils/strings_test.goindex ec7fad347..8a73ab9ad 100644--- a/backend/internal/utils/stringutils/stringutils_test.go+++ b/backend/pkg/utils/strings_test.go@@ -1,4 +1,4 @@-package stringutils+package utilsimport ("testing"diff --git a/backend/internal/utils/update_value_util.go b/backend/pkg/utils/update_value_util.gosimilarity index 100%rename from backend/internal/utils/update_value_util.gorename to backend/pkg/utils/update_value_util.godiff --git a/backend/internal/utils/update_value_util_test.go b/backend/pkg/utils/update_value_util_test.gosimilarity index 100%rename from backend/internal/utils/update_value_util_test.gorename to backend/pkg/utils/update_value_util_test.godiff --git a/backend/internal/utils/validation/email.go b/backend/pkg/utils/validation/email.gosimilarity index 100%rename from backend/internal/utils/validation/email.gorename to backend/pkg/utils/validation/email.godiff --git a/backend/internal/utils/validation/email_test.go b/backend/pkg/utils/validation/email_test.gosimilarity index 100%rename from backend/internal/utils/validation/email_test.gorename to backend/pkg/utils/validation/email_test.godiff --git a/backend/internal/models/converter.go b/types/system/docker_run.gosimilarity index 99%rename from backend/internal/models/converter.gorename to types/system/docker_run.goindex 5a793a1b4..70f2910bd 100644--- a/backend/internal/models/converter.go+++ b/types/system/docker_run.go@@ -1,4 +1,4 @@-package models+package systemtype DockerRunCommand struct {Image string `json:"image"`