MCPcopy Index your code
hub / github.com/docker/cli / SetupPlugin

Function SetupPlugin

e2e/testutils/plugins.go:28–58  ·  view source on GitHub ↗

SetupPlugin builds a plugin and creates a temporary directory with the plugin's config.json and rootfs, which will be removed in [t.Cleanup]. It returns the location of the temporary directory.

(t *testing.T, ctx context.Context)

Source from the content-addressed store, hash-verified

26// which will be removed in [t.Cleanup]. It returns
27// the location of the temporary directory.
28func SetupPlugin(t *testing.T, ctx context.Context) (pluginDir string) {
29 t.Helper()
30
31 p := &plugin.Config{
32 Linux: plugin.LinuxConfig{
33 Capabilities: []string{"CAP_SYS_ADMIN"},
34 },
35 Interface: plugin.Interface{
36 Socket: "basic.sock",
37 Types: []plugin.CapabilityID{{
38 Capability: "dummy",
39 Prefix: "docker",
40 Version: "1.0",
41 }},
42 },
43 Entrypoint: []string{"/basic"},
44 }
45 configJSON, err := json.Marshal(p)
46 assert.NilError(t, err)
47
48 binPath, err := buildPlugin(t, ctx)
49 assert.NilError(t, err)
50
51 dir := fs.NewDir(t, "plugin_test",
52 fs.WithFile("config.json", string(configJSON), fs.WithMode(0o644)),
53 fs.WithDir("rootfs", fs.WithMode(0o755)),
54 )
55
56 icmd.RunCommand("/bin/cp", binPath, dir.Join("rootfs", p.Entrypoint[0])).Assert(t, icmd.Success)
57 return dir.Path()
58}
59
60// buildPlugin uses Go to build a plugin from one of the source files in the plugins directory.
61// It returns the path to the built plugin binary.

Callers

nothing calls this directly

Calls 2

buildPluginFunction · 0.85
PathMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…