Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Commit 9b5633a

Browse files
author
Hao Zhang
committed
feat(image): support docker-compose pull cmd
1 parent 10a04c9 commit 9b5633a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

compose/internal/composebinary/composebinary.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ func (wrapper *ComposeWrapper) Remove(ctx context.Context, workingDir, host, pro
5151
return err
5252
}
5353

54+
// Pull an image associated with a service defined in a docker-compose.yml or docker-stack.yml file,
55+
// but does not start containers based on those images.
56+
func (wrapper *ComposeWrapper) Pull(ctx context.Context, workingDir, host, projectName string, filePaths []string) error {
57+
output, err := wrapper.Command(newPullCommand(filePaths), workingDir, host, projectName, "")
58+
if len(output) != 0 {
59+
log.Printf("[libstack,composebinary] [message: finish deploying] [output: %s] [err: %s]", output, err)
60+
}
61+
62+
return err
63+
}
64+
5465
// Command executes a docker-compose command
5566
func (wrapper *ComposeWrapper) Command(command composeCommand, workingDir, host, projectName, envFilePath string) ([]byte, error) {
5667
program := utils.ProgramPath(wrapper.binaryPath, "docker-compose")
@@ -111,6 +122,10 @@ func newDownCommand(filePaths []string) composeCommand {
111122
return newCommand([]string{"down", "--remove-orphans"}, filePaths)
112123
}
113124

125+
func newPullCommand(filePaths []string) composeCommand {
126+
return newCommand([]string{"pull"}, filePaths)
127+
}
128+
114129
func (command *composeCommand) WithProjectName(projectName string) {
115130
command.args = append(command.args, "-p", projectName)
116131
}

libstack.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ import (
77
type Deployer interface {
88
Deploy(ctx context.Context, workingDir, host, projectName string, filePaths []string, envFilePath string) error
99
Remove(ctx context.Context, workingDir, host, projectName string, filePaths []string) error
10+
Pull(ctx context.Context, workingDir, host, projectName string, filePaths []string) error
1011
}

0 commit comments

Comments
 (0)