MCPcopy Create free account
hub / github.com/containerd/nerdctl / newNerdCommand

Function newNerdCommand

pkg/testutil/nerdtest/command.go:53–95  ·  view source on GitHub ↗
(conf test.Config, t tig.T)

Source from the content-addressed store, hash-verified

51}
52
53func newNerdCommand(conf test.Config, t tig.T) *nerdCommand {
54 // Decide what binary we are running
55 var err error
56 var binary string
57 trgt := getTarget()
58
59 binary, err = exec.LookPath(trgt)
60 if err != nil {
61 t.Log(fmt.Sprintf("unable to find binary %q: %v", trgt, err))
62 t.FailNow()
63 }
64
65 if isTargetNerdish() {
66 // Any target but docker is considered a nerdctl variant, either gomodjail, or homegrown cli based on the
67 // nerdctl codebase as a library.
68 // Set the default namespace if we do not have one explicitly set already
69 if conf.Read(Namespace) == "" {
70 conf.Write(Namespace, defaultNamespace)
71 }
72 } else {
73 if err = exec.Command(binary, "compose", "version").Run(); err != nil {
74 t.Log(fmt.Sprintf("docker does not support compose: %v", err))
75 t.FailNow()
76 }
77 }
78
79 // Create the base command, with the right binary, t
80 ret := &nerdCommand{
81 GenericCommand: *(test.NewGenericCommand().(*test.GenericCommand)),
82 }
83
84 ret.WithBinary(binary)
85 ret.WithWhitelist([]string{
86 "PATH",
87 "HOME",
88 "XDG_*",
89 // Windows needs ProgramData, AppData, etc
90 "Program*",
91 "PROGRAM*",
92 "APPDATA",
93 })
94 return ret
95}
96
97type nerdCommand struct {
98 test.GenericCommand

Callers 1

CustomCommandMethod · 0.85

Calls 10

getTargetFunction · 0.85
isTargetNerdishFunction · 0.85
WithWhitelistMethod · 0.80
LogMethod · 0.65
FailNowMethod · 0.65
ReadMethod · 0.65
WriteMethod · 0.65
RunMethod · 0.65
CommandMethod · 0.65
WithBinaryMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…