MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / Import

Method Import

cli/pkg/common/docker.go:69–83  ·  view source on GitHub ↗
(ctx context.Context, file string, image string)

Source from the content-addressed store, hash-verified

67}
68
69func (d Docker) Import(ctx context.Context, file string, image string) (string, error) {
70 f, err := os.Open(file)
71 defer f.Close()
72 if err != nil {
73 return "", err
74 }
75
76 reader, err := d.client.ImageImport(ctx, types.ImageImportSource{Source: f, SourceName: "-"}, image, types.ImageImportOptions{})
77 if err != nil {
78 return "", err
79 }
80 buf := new(bytes.Buffer)
81 _, _ = buf.ReadFrom(reader)
82 return buf.String(), nil
83}
84
85func (d Docker) Run(ctx context.Context, name string, image string, cmd []string, volumes map[string]struct{}, ports nat.PortSet) error {
86 resp, err := d.client.ContainerCreate(ctx, &container.Config{Image: image, Volumes: volumes, ExposedPorts: ports, Cmd: cmd}, nil, nil, nil, name)

Callers

nothing calls this directly

Calls 1

StringMethod · 0.65

Tested by

no test coverage detected