Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: serve webhooks from the manager and close edge command allowlist gaps (#2922)
Kyle Mendell61620c3696b5
diff --git a/backend/api/handlers/projects.go b/backend/api/handlers/projects.goindex 4c9622c2e..c3146b1e4 100644--- a/backend/api/handlers/projects.go+++ b/backend/api/handlers/projects.go@@ -160,6 +160,18 @@ type RestartProjectOutput struct {Body base.ApiResponse[base.MessageResponse]}+type UpdateProjectServicesInput struct {+ EnvironmentID string `path:"id" doc:"Environment ID"`+ ProjectID string `path:"projectId" doc:"Project ID"`+ Body *struct {+ Services []string `json:"services,omitempty" doc:"Service names to update; empty updates all services"`+ }+}++type UpdateProjectServicesOutput struct {+ Body base.ApiResponse[base.MessageResponse]+}+type ArchiveProjectInput struct {EnvironmentID string `path:"id" doc:"Environment ID"`ProjectID string `path:"projectId" doc:"Project ID"`@@ -441,6 +453,20 @@ func RegisterProjects(api huma.API, projectService *services.ProjectService, actMiddlewares: humamw.RequirePermission(api, authz.PermProjectsRestart),}, h.RestartProject)+ huma.Register(api, huma.Operation{+ OperationID: "update-project-services",+ Method: http.MethodPost,+ Path: "/environments/{id}/projects/{projectId}/update-services",+ Summary: "Update project services",+ Description: "Pull latest images and recreate the given services (all services when none are specified)",+ Tags: []string{"Projects"},+ Security: []map[string][]string{+ {"BearerAuth": {}},+ {"ApiKeyAuth": {}},+ },+ Middlewares: humamw.RequirePermission(api, authz.PermProjectsUpdate),+ }, h.UpdateProjectServices)+huma.Register(api, huma.Operation{OperationID: "archive-project",Method: http.MethodPost,@@ -1000,6 +1026,23 @@ func (h *ProjectHandler) RestartProject(ctx context.Context, input *RestartProje}, nil}+// UpdateProjectServices pulls the latest images for the given services and recreates them.+func (h *ProjectHandler) UpdateProjectServices(ctx context.Context, input *UpdateProjectServicesInput) (*UpdateProjectServicesOutput, error) {+ var services []string+ if input.Body != nil {+ services = input.Body.Services+ }++ response, err := h.runProjectActivityActionResponseInternal(ctx, input.EnvironmentID, input.ProjectID, h.updateProjectServicesActivityConfigInternal(services))+ if err != nil {+ return nil, err+ }++ return &UpdateProjectServicesOutput{+ Body: response,+ }, nil+}+type projectActivityActionConfigInternal struct {ActivityType models.ActivityTypeStep string@@ -1030,6 +1073,24 @@ func (h *ProjectHandler) redeployProjectActivityConfigInternal(options *project.}}+func (h *ProjectHandler) updateProjectServicesActivityConfigInternal(services []string) projectActivityActionConfigInternal {+ return projectActivityActionConfigInternal{+ ActivityType: models.ActivityTypeAutoUpdate,+ Step: "Updating project services",+ StartMessage: "Project services update requested",+ WriterStep: "Updating project services",+ FailureMessage: "Project services update failed",+ SuccessComplete: "Project services updated",+ SuccessMessage: "Project services updated successfully",+ Action: func(runtimeCtx context.Context, projectID string, user models.User) error {+ return h.projectService.UpdateProjectServices(runtimeCtx, projectID, services, user)+ },+ Error: projectArchivedActionErrorInternal(func(err error) error {+ return huma.Error400BadRequest((&common.ProjectUpdateError{Err: err}).Error())+ }),+ }+}+func (h *ProjectHandler) restartProjectActivityConfigInternal() projectActivityActionConfigInternal {return projectActivityActionConfigInternal{ActivityType: models.ActivityTypeProjectRestart,diff --git a/backend/internal/di/wire_gen.go b/backend/internal/di/wire_gen.goindex 1b6032f6d..4734de85d 100644--- a/backend/internal/di/wire_gen.go+++ b/backend/internal/di/wire_gen.go@@ -64,7 +64,7 @@ func InitializeServices(ctx context.Context, db *database.DB, cfg *config.ConfigupdaterService := provideUpdaterServiceInternal(db, settingsService, dockerClientService, projectService, imageUpdateService, containerRegistryService, eventService, imageService, notificationService, systemUpgradeService, activityService)federatedCredentialService := provideFederatedCredentialServiceInternal(db, authService, userService, settingsService, eventService, httpClient, roleService)gitOpsSyncService := services.NewGitOpsSyncService(db, gitRepositoryService, projectService, swarmService, eventService, settingsService)- webhookService := services.NewWebhookService(db, containerService, updaterService, projectService, gitOpsSyncService, eventService)+ webhookService := services.NewWebhookService(db, containerService, updaterService, projectService, gitOpsSyncService, eventService, environmentService)dashboardService := services.NewDashboardService(db, dockerClientService, containerService, projectService, imageService, settingsService, vulnerabilityService, environmentService, versionService)authMiddleware := provideAuthMiddlewareInternal(authService, apiKeyService, environmentService, roleService, cfg)diServices := &Services{diff --git a/backend/internal/middleware/environment_middleware.go b/backend/internal/middleware/environment_middleware.goindex dfaa5066b..6120e2c68 100644--- a/backend/internal/middleware/environment_middleware.go+++ b/backend/internal/middleware/environment_middleware.go@@ -208,6 +208,12 @@ func isManagementPathInternal(suffix string) bool {return true}+ // Webhooks are managed centrally: rows live in the manager DB (keyed by the+ // real environment ID) and the public trigger endpoint resolves tokens there.+ if suffix == "/webhooks" || strings.HasPrefix(suffix, "/webhooks/") {+ return true+ }+if strings.HasPrefix(suffix, "/deployment/mtls/") {return true}diff --git a/backend/internal/middleware/environment_middleware_test.go b/backend/internal/middleware/environment_middleware_test.goindex 6a84730a8..729fc80d4 100644--- a/backend/internal/middleware/environment_middleware_test.go+++ b/backend/internal/middleware/environment_middleware_test.go@@ -144,6 +144,51 @@ func TestEnvironmentMiddleware_KeepsNotificationEndpointsLocal(t *testing.T) {assert.True(t, localHandlerHit)}+func TestEnvironmentMiddleware_KeepsWebhookEndpointsLocal(t *testing.T) {+ tests := []struct {+ name string+ method string+ route string+ path string+ }{+ {+ name: "list webhooks",+ method: http.MethodGet,+ route: "/environments/:id/webhooks",+ path: "/api/environments/env-edge/webhooks",+ },+ {+ name: "delete webhook",+ method: http.MethodDelete,+ route: "/environments/:id/webhooks/:webhookId",+ path: "/api/environments/env-edge/webhooks/wh-1",+ },+ }++ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ middleware := newTestEnvironmentMiddleware()+ router := echo.New()+ api := attachMiddleware(router, middleware)++ localHandlerHit := false+ api.Add(tt.method, tt.route, func(c echo.Context) error {+ localHandlerHit = true+ return c.JSON(http.StatusOK, map[string]any{"success": true})+ })++ req := httptest.NewRequest(tt.method, tt.path, nil)+ recorder := httptest.NewRecorder()++ router.ServeHTTP(recorder, req)++ assert.Equal(t, http.StatusOK, recorder.Code)+ assert.Contains(t, recorder.Body.String(), "\"success\":true")+ assert.True(t, localHandlerHit)+ })+ }+}+func TestEnvironmentMiddleware_KeepsActivityEndpointsLocal(t *testing.T) {tests := []struct {name stringdiff --git a/backend/internal/services/webhook_service.go b/backend/internal/services/webhook_service.goindex 4a6de12e2..ddc52f572 100644--- a/backend/internal/services/webhook_service.go+++ b/backend/internal/services/webhook_service.go@@ -8,12 +8,16 @@ import ("encoding/hex""errors""fmt"+ "net/http"+ "net/url""strings""time""github.com/getarcaneapp/arcane/backend/v2/internal/database""github.com/getarcaneapp/arcane/backend/v2/internal/models"libcrypto "github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/crypto"+ "github.com/getarcaneapp/arcane/types/v2"+ "github.com/getarcaneapp/arcane/types/v2/base""github.com/getarcaneapp/arcane/types/v2/updater"webhooktypes "github.com/getarcaneapp/arcane/types/v2/webhook""gorm.io/gorm"@@ -35,25 +39,33 @@ const ()type WebhookService struct {- db *database.DB- containerService *ContainerService- updaterService *UpdaterService- projectService *ProjectService- gitOpsSyncService *GitOpsSyncService- eventService *EventService+ db *database.DB+ containerService *ContainerService+ updaterService *UpdaterService+ projectService *ProjectService+ gitOpsSyncService *GitOpsSyncService+ eventService *EventService+ environmentService *EnvironmentService}-func NewWebhookService(db *database.DB, containerService *ContainerService, updaterService *UpdaterService, projectService *ProjectService, gitOpsSyncService *GitOpsSyncService, eventService *EventService) *WebhookService {+func NewWebhookService(db *database.DB, containerService *ContainerService, updaterService *UpdaterService, projectService *ProjectService, gitOpsSyncService *GitOpsSyncService, eventService *EventService, environmentService *EnvironmentService) *WebhookService {return &WebhookService{- db: db,- containerService: containerService,- updaterService: updaterService,- projectService: projectService,- gitOpsSyncService: gitOpsSyncService,- eventService: eventService,+ db: db,+ containerService: containerService,+ updaterService: updaterService,+ projectService: projectService,+ gitOpsSyncService: gitOpsSyncService,+ eventService: eventService,+ environmentService: environmentService,}}+// isRemoteWebhookEnvironmentInternal reports whether environmentID refers to a+// remote environment (anything but the local Docker environment).+func isRemoteWebhookEnvironmentInternal(environmentID string) bool {+ return environmentID != "" && environmentID != types.LOCAL_DOCKER_ENVIRONMENT_ID+}+// generateWebhookTokenInternal creates a new random webhook token and returns the raw token// (to be shown to the user once), its SHA-256 hash, and the lookup prefix.func generateWebhookTokenInternal() (raw, hash, prefix string, err error) {@@ -170,7 +182,9 @@ func (s *WebhookService) CreateWebhook(ctx context.Context, name, targetType, acreturn nil, "", ErrWebhookMissingTarget}- if targetType == models.WebhookTargetTypeContainer {+ // Container references can only be resolved against the local Docker daemon;+ // remote-environment webhooks keep the raw target and resolve on trigger.+ if targetType == models.WebhookTargetTypeContainer && !isRemoteWebhookEnvironmentInternal(environmentID) {targetRef, err = s.resolveContainerWebhookTargetRefInternal(ctx, targetID)if err != nil {return nil, "", err@@ -258,6 +272,13 @@ func (s *WebhookService) ListWebhookSummaries(ctx context.Context, environmentIDfunc (s *WebhookService) resolveWebhookTargetNameInternal(ctx context.Context, wh *models.Webhook) string {switch wh.TargetType {case models.WebhookTargetTypeContainer:+ // Remote containers cannot be resolved against the local Docker daemon.+ if isRemoteWebhookEnvironmentInternal(wh.EnvironmentID) {+ if strings.TrimSpace(wh.TargetRef) != "" {+ return wh.TargetRef+ }+ return wh.TargetID+ }if strings.TrimSpace(wh.TargetRef) != "" {if s.containerService == nil {return wh.TargetRef@@ -438,6 +459,12 @@ func (s *WebhookService) TriggerByToken(ctx context.Context, rawToken string) (*}func (s *WebhookService) executeWebhookActionInternal(ctx context.Context, wh *models.Webhook, actionType string) (*updater.Result, error) {+ // Webhooks are stored and triggered on the manager; actions against remote+ // environments are forwarded through the environment proxy.+ if isRemoteWebhookEnvironmentInternal(wh.EnvironmentID) {+ return s.executeRemoteWebhookActionInternal(ctx, wh, actionType)+ }+switch wh.TargetType {case models.WebhookTargetTypeContainer:return s.executeContainerWebhookActionInternal(ctx, wh, actionType)@@ -452,6 +479,81 @@ func (s *WebhookService) executeWebhookActionInternal(ctx context.Context, wh *m}}+// remoteWebhookRequestInternal maps a webhook action to the env-scoped API+// request forwarded to the remote environment. Paths use the agent-local+// environment ID, matching the environment proxy's path-rewriting convention.+// wantResult reports whether the response carries an updater.Result payload.+func remoteWebhookRequestInternal(wh *models.Webhook, actionType string) (method, path string, wantResult bool, err error) {+ apiPrefix := "/api/environments/" + types.LOCAL_DOCKER_ENVIRONMENT_ID++ switch wh.TargetType {+ case models.WebhookTargetTypeContainer:+ ref := strings.TrimSpace(wh.TargetRef)+ if ref == "" {+ ref = strings.TrimSpace(wh.TargetID)+ }+ if ref == "" {+ return "", "", false, ErrWebhookMissingTarget+ }+ containerPath := apiPrefix + "/containers/" + url.PathEscape(ref)+ switch actionType {+ case models.WebhookActionTypeUpdate:+ return http.MethodPost, containerPath + "/update", true, nil+ case models.WebhookActionTypeStart, models.WebhookActionTypeStop, models.WebhookActionTypeRestart, models.WebhookActionTypeRedeploy:+ return http.MethodPost, containerPath + "/" + actionType, false, nil+ }+ return "", "", false, ErrWebhookInvalidAction+ case models.WebhookTargetTypeProject:+ projectPath := apiPrefix + "/projects/" + url.PathEscape(wh.TargetID)+ switch actionType {+ case models.WebhookActionTypeUpdate:+ return http.MethodPost, projectPath + "/update-services", false, nil+ case models.WebhookActionTypeUp, models.WebhookActionTypeDown, models.WebhookActionTypeRestart, models.WebhookActionTypeRedeploy:+ return http.MethodPost, projectPath + "/" + actionType, false, nil+ }+ return "", "", false, ErrWebhookInvalidAction+ case models.WebhookTargetTypeUpdater:+ if actionType != models.WebhookActionTypeRun {+ return "", "", false, ErrWebhookInvalidAction+ }+ return http.MethodPost, apiPrefix + "/updater/run", true, nil+ case models.WebhookTargetTypeGitOps:+ if actionType != models.WebhookActionTypeSync {+ return "", "", false, ErrWebhookInvalidAction+ }+ return http.MethodPost, apiPrefix + "/gitops-syncs/" + url.PathEscape(wh.TargetID) + "/sync", false, nil+ default:+ return "", "", false, ErrWebhookInvalidType+ }+}++func (s *WebhookService) executeRemoteWebhookActionInternal(ctx context.Context, wh *models.Webhook, actionType string) (*updater.Result, error) {+ if s.environmentService == nil {+ return nil, s.wrapWebhookActionErrorInternal(ctx, wh, wh.TargetType, actionType, errors.New("environment service not available"))+ }++ method, path, wantResult, err := remoteWebhookRequestInternal(wh, actionType)+ if err != nil {+ return nil, err+ }++ var result *updater.Result+ if wantResult {+ var out base.ApiResponse[*updater.Result]+ if err := s.environmentService.ProxyJSONRequest(ctx, wh.EnvironmentID, method, path, nil, &out); err != nil {+ return nil, s.wrapWebhookActionErrorInternal(ctx, wh, wh.TargetType, actionType, err)+ }+ result = out.Data+ } else {+ var out base.ApiResponse[any]+ if err := s.environmentService.ProxyJSONRequest(ctx, wh.EnvironmentID, method, path, nil, &out); err != nil {+ return nil, s.wrapWebhookActionErrorInternal(ctx, wh, wh.TargetType, actionType, err)+ }+ }++ return result, nil+}+func (s *WebhookService) executeContainerWebhookActionInternal(ctx context.Context, wh *models.Webhook, actionType string) (*updater.Result, error) {containerID, err := s.resolveContainerWebhookTargetIDInternal(ctx, wh)if err != nil {diff --git a/backend/internal/services/webhook_service_test.go b/backend/internal/services/webhook_service_test.goindex 5d6e4507c..8f44d15ab 100644--- a/backend/internal/services/webhook_service_test.go+++ b/backend/internal/services/webhook_service_test.go@@ -10,6 +10,7 @@ import ("testing"libcrypto "github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/crypto"+ "github.com/getarcaneapp/arcane/types/v2"glsqlite "github.com/glebarez/sqlite""github.com/stretchr/testify/assert""github.com/stretchr/testify/require"@@ -590,7 +591,7 @@ func TestTriggerByToken_ContainerType_NilServiceReturnsError(t *testing.T) {svc := newTestWebhookService(db) // updaterService is nilrawToken := "arc_wh_ccddeeff01020304aabbccdd0102030405060708090a0b0c0d0e0f1011121314"- insertWebhookDirect(t, ctx, db, rawToken, models.WebhookTargetTypeContainer, models.WebhookActionTypeUpdate, "container-id", "env-1")+ insertWebhookDirect(t, ctx, db, rawToken, models.WebhookTargetTypeContainer, models.WebhookActionTypeUpdate, "container-id", types.LOCAL_DOCKER_ENVIRONMENT_ID)assert.Panics(t, func() {_, _ = svc.TriggerByToken(ctx, rawToken) //nolint:errcheck@@ -603,7 +604,7 @@ func TestTriggerByToken_UpdaterType_NilServiceReturnsError(t *testing.T) {svc := newTestWebhookService(db) // updaterService is nilrawToken := "arc_wh_1122334401020304aabbccdd0102030405060708090a0b0c0d0e0f1011121314"- insertWebhookDirect(t, ctx, db, rawToken, models.WebhookTargetTypeUpdater, models.WebhookActionTypeRun, "", "env-1")+ insertWebhookDirect(t, ctx, db, rawToken, models.WebhookTargetTypeUpdater, models.WebhookActionTypeRun, "", types.LOCAL_DOCKER_ENVIRONMENT_ID)// nil updaterService causes a panic, which we verify the dispatch path is reached// by recovering — in production the service is always non-nil@@ -618,7 +619,7 @@ func TestTriggerByToken_GitOpsType_NilServiceReturnsError(t *testing.T) {svc := newTestWebhookService(db) // gitOpsSyncService is nilrawToken := "arc_wh_aabbccdd11223344aabbccdd0102030405060708090a0b0c0d0e0f1011121314"- insertWebhookDirect(t, ctx, db, rawToken, models.WebhookTargetTypeGitOps, models.WebhookActionTypeSync, "sync-id", "env-1")+ insertWebhookDirect(t, ctx, db, rawToken, models.WebhookTargetTypeGitOps, models.WebhookActionTypeSync, "sync-id", types.LOCAL_DOCKER_ENVIRONMENT_ID)assert.Panics(t, func() {_, _ = svc.TriggerByToken(ctx, rawToken) //nolint:errcheck@@ -651,3 +652,73 @@ func TestTriggerByToken_UnknownActionType_ReturnsInvalidAction(t *testing.T) {_, err := svc.TriggerByToken(ctx, rawToken)assert.ErrorIs(t, err, ErrWebhookInvalidAction)}++func TestRemoteWebhookRequestInternal(t *testing.T) {+ tests := []struct {+ name string+ wh models.Webhook+ actionType string+ wantMethod string+ wantPath string+ wantResult bool+ wantErr error+ }{+ {+ name: "container update prefers target ref",+ wh: models.Webhook{TargetType: models.WebhookTargetTypeContainer, TargetID: "abc123", TargetRef: "my-app"},+ actionType: models.WebhookActionTypeUpdate,+ wantMethod: "POST",+ wantPath: "/api/environments/0/containers/my-app/update",+ wantResult: true,+ },+ {+ name: "container start falls back to target id",+ wh: models.Webhook{TargetType: models.WebhookTargetTypeContainer, TargetID: "abc123"},+ actionType: models.WebhookActionTypeStart,+ wantMethod: "POST",+ wantPath: "/api/environments/0/containers/abc123/start",+ },+ {+ name: "project update maps to update-services",+ wh: models.Webhook{TargetType: models.WebhookTargetTypeProject, TargetID: "p1"},+ actionType: models.WebhookActionTypeUpdate,+ wantMethod: "POST",+ wantPath: "/api/environments/0/projects/p1/update-services",+ },+ {+ name: "gitops sync",+ wh: models.Webhook{TargetType: models.WebhookTargetTypeGitOps, TargetID: "sync-1"},+ actionType: models.WebhookActionTypeSync,+ wantMethod: "POST",+ wantPath: "/api/environments/0/gitops-syncs/sync-1/sync",+ },+ {+ name: "updater run carries result",+ wh: models.Webhook{TargetType: models.WebhookTargetTypeUpdater},+ actionType: models.WebhookActionTypeRun,+ wantMethod: "POST",+ wantPath: "/api/environments/0/updater/run",+ wantResult: true,+ },+ {+ name: "invalid action rejected",+ wh: models.Webhook{TargetType: models.WebhookTargetTypeContainer, TargetID: "abc"},+ actionType: models.WebhookActionTypeSync,+ wantErr: ErrWebhookInvalidAction,+ },+ }++ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ method, path, wantResult, err := remoteWebhookRequestInternal(&tt.wh, tt.actionType)+ if tt.wantErr != nil {+ assert.ErrorIs(t, err, tt.wantErr)+ return+ }+ require.NoError(t, err)+ assert.Equal(t, tt.wantMethod, method)+ assert.Equal(t, tt.wantPath, path)+ assert.Equal(t, tt.wantResult, wantResult)+ })+ }+}diff --git a/backend/pkg/libarcane/edge/commands.go b/backend/pkg/libarcane/edge/commands.goindex 0f2a0f130..89b207c0b 100644--- a/backend/pkg/libarcane/edge/commands.go+++ b/backend/pkg/libarcane/edge/commands.go@@ -31,6 +31,9 @@ var commandRoutes = []commandRoute{{Method: http.MethodPost, PathPattern: "/api/environments/{id}/containers/{containerId}/redeploy", CommandName: "container.redeploy"},{Method: http.MethodDelete, PathPattern: "/api/environments/{id}/containers/{containerId}", CommandName: "container.delete"},{Method: http.MethodPost, PathPattern: "/api/environments/{id}/containers/{containerId}/update", CommandName: "container.update"},+ {Method: http.MethodPut, PathPattern: "/api/environments/{id}/containers/{containerId}/auto-update", CommandName: "container.auto_update.set"},++ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/ports", CommandName: "port.list"},{Method: http.MethodGet, PathPattern: "/api/environments/{id}/images", CommandName: "image.list"},{Method: http.MethodGet, PathPattern: "/api/environments/{id}/images/counts", CommandName: "image.counts"},@@ -49,6 +52,7 @@ var commandRoutes = []commandRoute{{Method: http.MethodPost, PathPattern: "/api/environments/{id}/image-updates/check-batch", CommandName: "image_update.check_batch"},{Method: http.MethodPost, PathPattern: "/api/environments/{id}/image-updates/check-all", CommandName: "image_update.check_all"},{Method: http.MethodGet, PathPattern: "/api/environments/{id}/image-updates/summary", CommandName: "image_update.summary"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/image-updates/by-refs", CommandName: "image_update.by_refs"},{Method: http.MethodGet, PathPattern: "/api/environments/{id}/activities", CommandName: "activity.list"},{Method: http.MethodGet, PathPattern: "/api/environments/{id}/activities/{activityId}", CommandName: "activity.inspect"},@@ -84,6 +88,7 @@ var commandRoutes = []commandRoute{{Method: http.MethodPut, PathPattern: "/api/environments/{id}/projects/{projectId}", CommandName: "project.update"},{Method: http.MethodPut, PathPattern: "/api/environments/{id}/projects/{projectId}/includes", CommandName: "project.includes"},{Method: http.MethodPost, PathPattern: "/api/environments/{id}/projects/{projectId}/restart", CommandName: "project.restart"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/projects/{projectId}/update-services", CommandName: "project.update_services"},{Method: http.MethodPost, PathPattern: "/api/environments/{id}/projects/{projectId}/pull", CommandName: "project.pull"},{Method: http.MethodPost, PathPattern: "/api/environments/{id}/projects/{projectId}/build", CommandName: "project.build"},{Method: http.MethodPost, PathPattern: "/api/environments/{id}/projects/{projectId}/archive", CommandName: "project.archive"},@@ -136,6 +141,10 @@ var commandRoutes = []commandRoute{{Method: http.MethodGet, PathPattern: "/api/environments/{id}/networks/{networkId}", CommandName: "network.inspect"},{Method: http.MethodDelete, PathPattern: "/api/environments/{id}/networks/{networkId}", CommandName: "network.delete"},{Method: http.MethodPost, PathPattern: "/api/environments/{id}/networks/prune", CommandName: "network.prune"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/networks/topology", CommandName: "network.topology"},++ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/templates/variables", CommandName: "template.variables.get"},+ {Method: http.MethodPut, PathPattern: "/api/environments/{id}/templates/variables", CommandName: "template.variables.update"},{Method: http.MethodGet, PathPattern: "/api/environments/{id}/settings/public", CommandName: "settings.public.get"},{Method: http.MethodGet, PathPattern: "/api/environments/{id}/settings", CommandName: "settings.get"},@@ -169,6 +178,53 @@ var commandRoutes = []commandRoute{{Method: http.MethodGet, PathPattern: "/api/environments/{id}/system/upgrade/check", CommandName: "system.upgrade.check"},{Method: http.MethodPost, PathPattern: "/api/environments/{id}/system/upgrade", CommandName: "system.upgrade.run"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/services", CommandName: "swarm.service.list"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/swarm/services", CommandName: "swarm.service.create"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/services/{serviceId}", CommandName: "swarm.service.inspect"},+ {Method: http.MethodPut, PathPattern: "/api/environments/{id}/swarm/services/{serviceId}", CommandName: "swarm.service.update"},+ {Method: http.MethodDelete, PathPattern: "/api/environments/{id}/swarm/services/{serviceId}", CommandName: "swarm.service.delete"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/services/{serviceId}/tasks", CommandName: "swarm.service.tasks"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/swarm/services/{serviceId}/rollback", CommandName: "swarm.service.rollback"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/swarm/services/{serviceId}/scale", CommandName: "swarm.service.scale"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/nodes", CommandName: "swarm.node.list"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/nodes/{nodeId}", CommandName: "swarm.node.inspect"},+ {Method: http.MethodPatch, PathPattern: "/api/environments/{id}/swarm/nodes/{nodeId}", CommandName: "swarm.node.update"},+ {Method: http.MethodDelete, PathPattern: "/api/environments/{id}/swarm/nodes/{nodeId}", CommandName: "swarm.node.delete"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/swarm/nodes/{nodeId}/agent/deployment", CommandName: "swarm.node.agent_deployment"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/swarm/nodes/{nodeId}/promote", CommandName: "swarm.node.promote"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/swarm/nodes/{nodeId}/demote", CommandName: "swarm.node.demote"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/nodes/{nodeId}/tasks", CommandName: "swarm.node.tasks"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/tasks", CommandName: "swarm.task.list"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/stacks", CommandName: "swarm.stack.list"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/swarm/stacks", CommandName: "swarm.stack.deploy"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/stacks/{name}", CommandName: "swarm.stack.inspect"},+ {Method: http.MethodDelete, PathPattern: "/api/environments/{id}/swarm/stacks/{name}", CommandName: "swarm.stack.delete"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/stacks/{name}/source", CommandName: "swarm.stack.source.get"},+ {Method: http.MethodPut, PathPattern: "/api/environments/{id}/swarm/stacks/{name}/source", CommandName: "swarm.stack.source.update"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/stacks/{name}/services", CommandName: "swarm.stack.services"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/stacks/{name}/tasks", CommandName: "swarm.stack.tasks"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/swarm/stacks/config/render", CommandName: "swarm.stack.config.render"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/status", CommandName: "swarm.status"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/info", CommandName: "swarm.info"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/swarm/init", CommandName: "swarm.init"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/swarm/join", CommandName: "swarm.join"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/swarm/leave", CommandName: "swarm.leave"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/swarm/unlock", CommandName: "swarm.unlock"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/unlock-key", CommandName: "swarm.unlock_key"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/join-tokens", CommandName: "swarm.join_tokens.get"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/swarm/join-tokens/rotate", CommandName: "swarm.join_tokens.rotate"},+ {Method: http.MethodPut, PathPattern: "/api/environments/{id}/swarm/spec", CommandName: "swarm.spec.update"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/configs", CommandName: "swarm.config.list"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/swarm/configs", CommandName: "swarm.config.create"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/configs/{configId}", CommandName: "swarm.config.inspect"},+ {Method: http.MethodPut, PathPattern: "/api/environments/{id}/swarm/configs/{configId}", CommandName: "swarm.config.update"},+ {Method: http.MethodDelete, PathPattern: "/api/environments/{id}/swarm/configs/{configId}", CommandName: "swarm.config.delete"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/secrets", CommandName: "swarm.secret.list"},+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/swarm/secrets", CommandName: "swarm.secret.create"},+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/swarm/secrets/{secretId}", CommandName: "swarm.secret.inspect"},+ {Method: http.MethodPut, PathPattern: "/api/environments/{id}/swarm/secrets/{secretId}", CommandName: "swarm.secret.update"},+ {Method: http.MethodDelete, PathPattern: "/api/environments/{id}/swarm/secrets/{secretId}", CommandName: "swarm.secret.delete"},+{PathPattern: "/api/environments/{id}/ws/projects/{projectId}/logs", CommandName: "project.logs.stream", Stream: true},{PathPattern: "/api/environments/{id}/ws/containers/{containerId}/logs", CommandName: "container.logs.stream", Stream: true},{PathPattern: "/api/environments/{id}/ws/containers/{containerId}/stats", CommandName: "container.stats.stream", Stream: true},diff --git a/backend/pkg/libarcane/edge/commands_test.go b/backend/pkg/libarcane/edge/commands_test.goindex bf02ef673..370972dbf 100644--- a/backend/pkg/libarcane/edge/commands_test.go+++ b/backend/pkg/libarcane/edge/commands_test.go@@ -31,6 +31,11 @@ func TestResolveEdgeCommandName(t *testing.T) {{name: "activity history clear", method: "DELETE", path: "/api/environments/0/activities/history", command: "activity.history.clear", shouldHit: true},{name: "health", method: "HEAD", path: "/api/environments/0/system/health", command: "system.health", shouldHit: true},{name: "swarm node identity", method: "GET", path: "/api/swarm/node-identity", command: "swarm.node_identity", shouldHit: true},+ {name: "ports list", method: "GET", path: "/api/environments/0/ports?limit=20", command: "port.list", shouldHit: true},+ {name: "network topology", method: "GET", path: "/api/environments/0/networks/topology", command: "network.topology", shouldHit: true},+ {name: "container auto-update", method: "PUT", path: "/api/environments/0/containers/abc/auto-update", command: "container.auto_update.set", shouldHit: true},+ {name: "project update services", method: "POST", path: "/api/environments/0/projects/p1/update-services", command: "project.update_services", shouldHit: true},+ {name: "swarm services list", method: "GET", path: "/api/environments/0/swarm/services", command: "swarm.service.list", shouldHit: true},{name: "unknown", method: "PATCH", path: "/api/environments/0/containers", shouldHit: false},}