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

Function runCreate

cli/command/context/create.go:65–84  ·  view source on GitHub ↗

runCreate creates a Docker context

(dockerCLI command.Cli, name string, opts createOptions)

Source from the content-addressed store, hash-verified

63
64// runCreate creates a Docker context
65func runCreate(dockerCLI command.Cli, name string, opts createOptions) error {
66 s := dockerCLI.ContextStore()
67 err := checkContextNameForCreation(s, name)
68 if err != nil {
69 return err
70 }
71 switch {
72 case opts.from == "" && opts.endpoint == nil:
73 err = createFromExistingContext(s, name, dockerCLI.CurrentContext(), opts)
74 case opts.from != "":
75 err = createFromExistingContext(s, name, opts.from, opts)
76 default:
77 err = createNewContext(s, name, opts)
78 }
79 if err == nil {
80 _, _ = fmt.Fprintln(dockerCLI.Out(), name)
81 _, _ = fmt.Fprintf(dockerCLI.Err(), "Successfully created context %q\n", name)
82 }
83 return err
84}
85
86func createNewContext(contextStore store.ReaderWriter, name string, opts createOptions) error {
87 if opts.endpoint == nil {

Callers 11

TestCreateFunction · 0.70
TestCreateFromContextFunction · 0.70
TestCreateFromCurrentFunction · 0.70
createTestContextFunction · 0.70
newCreateCommandFunction · 0.70
TestUseFunction · 0.70
TestUseHostOverrideFunction · 0.70
TestUseHostOverrideEmptyFunction · 0.70

Calls 7

createNewContextFunction · 0.85
ContextStoreMethod · 0.65
CurrentContextMethod · 0.65
OutMethod · 0.65
ErrMethod · 0.65

Tested by 10

TestCreateFunction · 0.56
TestCreateFromContextFunction · 0.56
TestCreateFromCurrentFunction · 0.56
createTestContextFunction · 0.56
TestUseFunction · 0.56
TestUseHostOverrideFunction · 0.56
TestUseHostOverrideEmptyFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…