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

Commit cec58db

Browse files
Merge pull request #18 from portainer/fix/EE-1975/image-name-not-available
fix(download-plugin): Image name not available when using watchtower or similar EE-1975
2 parents 6569596 + ef0677b commit cec58db

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

compose/internal/composeplugin/composeplugin.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,22 @@ func NewPluginWrapper(binaryPath, configPath string) (libstack.Deployer, error)
4040
}
4141

4242
dockerPluginsPath := path.Join(configPath, "cli-plugins")
43-
if !utils.IsBinaryPresent(utils.ProgramPath(dockerPluginsPath, "docker-compose")) {
44-
pluginPath := utils.ProgramPath(binaryPath, "docker-compose.plugin")
45-
if !utils.IsBinaryPresent(pluginPath) {
46-
return nil, MissingDockerComposePluginErr
43+
pluginPath := utils.ProgramPath(binaryPath, "docker-compose.plugin")
44+
45+
if utils.IsBinaryPresent(pluginPath) {
46+
if !utils.IsBinaryPresent(utils.ProgramPath(dockerPluginsPath, "docker-compose")) {
47+
err := os.MkdirAll(dockerPluginsPath, 0755)
48+
if err != nil {
49+
return nil, errors.WithMessage(err, "failed creating plugins path")
50+
}
4751
}
4852

49-
err := os.MkdirAll(dockerPluginsPath, 0755)
50-
if err != nil {
51-
return nil, errors.WithMessage(err, "failed creating plugins path")
52-
}
53-
54-
err = utils.Copy(pluginPath, utils.ProgramPath(dockerPluginsPath, "docker-compose"))
53+
err := utils.Move(pluginPath, utils.ProgramPath(dockerPluginsPath, "docker-compose"))
5554
if err != nil {
5655
return nil, err
5756
}
58-
57+
} else if !utils.IsBinaryPresent(utils.ProgramPath(dockerPluginsPath, "docker-compose")) {
58+
return nil, MissingDockerComposePluginErr
5959
}
6060

6161
return &PluginWrapper{binaryPath: binaryPath, configPath: configPath}, nil

compose/internal/utils/utils.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,16 @@ func Copy(sourcePath, destinationPath string) error {
4545

4646
return nil
4747
}
48+
49+
// Move sourcePath to destinationPath
50+
func Move(sourcePath, destinationPath string) error {
51+
if err := Copy(sourcePath, destinationPath); err != nil {
52+
return err
53+
}
54+
55+
if err := os.Remove(sourcePath); err != nil {
56+
return err
57+
}
58+
59+
return nil
60+
}

0 commit comments

Comments
 (0)