MCPcopy Index your code
hub / github.com/basecamp/once / run

Method run

internal/command/deploy.go:34–78  ·  view source on GitHub ↗

Private

(ctx context.Context, ns *docker.Namespace, cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

32// Private
33
34func (d *deployCommand) run(ctx context.Context, ns *docker.Namespace, cmd *cobra.Command, args []string) error {
35 imageRef := args[0]
36
37 if err := ns.Setup(ctx); err != nil {
38 return fmt.Errorf("%w: %w", docker.ErrSetupFailed, err)
39 }
40
41 host := d.flags.host
42 if host == "" {
43 host = docker.NameFromImageRef(imageRef) + ".localhost"
44 }
45
46 if ns.HostInUse(host) {
47 return docker.ErrHostnameInUse
48 }
49
50 settings, err := d.flags.buildSettings(imageRef, host)
51 if err != nil {
52 return err
53 }
54
55 baseName := docker.NameFromImageRef(imageRef)
56 name, err := ns.UniqueName(baseName)
57 if err != nil {
58 return fmt.Errorf("generating app name: %w", err)
59 }
60 settings.Name = name
61
62 app := docker.NewApplication(ns, settings)
63
64 return runWithProgress("Deploying "+host, func(progress docker.DeployProgressCallback) error {
65 if err := app.Deploy(ctx, progress); err != nil {
66 if cleanupErr := app.Destroy(context.Background(), true); cleanupErr != nil {
67 slog.Error("Failed to clean up after deploy failure", "app", name, "error", cleanupErr)
68 }
69 return fmt.Errorf("%w: %w", docker.ErrDeployFailed, err)
70 }
71
72 if err := app.VerifyHTTPOrRemove(ctx); err != nil {
73 return err
74 }
75
76 return nil
77 })
78}

Callers

nothing calls this directly

Calls 11

DeployMethod · 0.95
DestroyMethod · 0.95
VerifyHTTPOrRemoveMethod · 0.95
NameFromImageRefFunction · 0.92
NewApplicationFunction · 0.92
runWithProgressFunction · 0.85
SetupMethod · 0.80
HostInUseMethod · 0.80
buildSettingsMethod · 0.80
UniqueNameMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected