MCPcopy
hub / github.com/docker/compose / commit

Method commit

pkg/compose/commit.go:35–79  ·  pkg/compose/commit.go::composeService.commit
(ctx context.Context, projectName string, options api.CommitOptions)

Source from the content-addressed store, hash-verified

33}
34
35func (s *composeService) commit(ctx context.Context, projectName string, options api.CommitOptions) error {
36 projectName = strings.ToLower(projectName)
37
38 ctr, err := s.getSpecifiedContainer(ctx, projectName, oneOffInclude, false, options.Service, options.Index)
39 if err != nil {
40 return err
41 }
42
43 name := getCanonicalContainerName(ctr)
44
45 s.events.On(api.Resource{
46 ID: name,
47 Status: api.Working,
48 Text: api.StatusCommitting,
49 })
50
51 if s.dryRun {
52 s.events.On(api.Resource{
53 ID: name,
54 Status: api.Done,
55 Text: api.StatusCommitted,
56 })
57
58 return nil
59 }
60
61 response, err := s.apiClient().ContainerCommit(ctx, ctr.ID, client.ContainerCommitOptions{
62 Reference: options.Reference,
63 Comment: options.Comment,
64 Author: options.Author,
65 Changes: options.Changes.GetSlice(),
66 NoPause: !options.Pause,
67 })
68 if err != nil {
69 return err
70 }
71
72 s.events.On(api.Resource{
73 ID: name,
74 Text: fmt.Sprintf("Committed as %s", response.ID),
75 Status: api.Done,
76 })
77
78 return nil
79}

Callers 1

CommitMethod · 0.95

Calls 5

getSpecifiedContainerMethod · 0.95
apiClientMethod · 0.95
OnMethod · 0.65
ContainerCommitMethod · 0.45

Tested by

no test coverage detected