mirror of
https://github.com/coder/coder.git
synced 2026-09-21 20:51:01 +08:00
Add workspace-side file collection to `coder support bundle` via repeatable --workspace-file flags. The agent resolves the requested paths or globs inside the remote workspace and streams back a tar with a manifest and the collected files; nothing is read from the machine running the command. - Add POST /api/v0/bundle-files to the agent's agentfiles package. - Expand env vars in the agent's environment; paths must then be absolute or start with ~/ (the agent user's home directory). - Support ** globs and tail oversized files. - Record requested patterns, per-path errors, truncation, and the applied limits in a manifest. - Unpack the archive into the bundle under agent/workspace_files/, recording dropped entries in collection_errors.txt. - Write a manifest-only archive marking collection as unsupported for agents that predate the endpoint. - Bound collection: 64 KB request body, 10000 files, 10 MiB per file, 100 MiB total including archive overhead, 110 MiB client-side read cap, 5 minute timeout. Closes #26020
27 lines
722 B
Go
27 lines
722 B
Go
package support
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/coder/coder/v2/codersdk/workspacesdk"
|
|
"github.com/coder/coder/v2/testutil"
|
|
)
|
|
|
|
func TestUnsupportedWorkspaceFilesArchive(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
patterns := []string{"~/a.log", "~/logs/**/*.log"}
|
|
entries := testutil.ReadTar(t, unsupportedWorkspaceFilesArchive(patterns))
|
|
|
|
var manifest workspacesdk.BundleFilesManifest
|
|
require.NoError(t, json.Unmarshal(entries["manifest.json"], &manifest))
|
|
require.Equal(t, patterns, manifest.Requested)
|
|
require.Len(t, manifest.Errors, 1)
|
|
require.Contains(t, manifest.Errors[0].Reason, "not supported")
|
|
require.Empty(t, manifest.Files)
|
|
require.Len(t, entries, 1)
|
|
}
|