Merge pull request #20508 from vrothberg/fix-20502
compose: try all possible providers before throwing an error
This commit is contained in:
commit
95fc0044f0
|
@ -17,6 +17,7 @@ import (
|
||||||
|
|
||||||
"github.com/containers/common/pkg/config"
|
"github.com/containers/common/pkg/config"
|
||||||
"github.com/containers/podman/v4/cmd/podman/registry"
|
"github.com/containers/podman/v4/cmd/podman/registry"
|
||||||
|
"github.com/containers/podman/v4/pkg/errorhandling"
|
||||||
"github.com/containers/podman/v4/pkg/machine"
|
"github.com/containers/podman/v4/pkg/machine"
|
||||||
"github.com/containers/podman/v4/pkg/machine/provider"
|
"github.com/containers/podman/v4/pkg/machine/provider"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
@ -85,20 +86,19 @@ func composeProvider() (string, error) {
|
||||||
return "", errors.New("no compose provider specified, please refer to `man podman-compose` for details")
|
return "", errors.New("no compose provider specified, please refer to `man podman-compose` for details")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lookupErrors := make([]error, 0, len(candidates))
|
||||||
for _, candidate := range candidates {
|
for _, candidate := range candidates {
|
||||||
path, err := exec.LookPath(os.ExpandEnv(candidate))
|
path, err := exec.LookPath(os.ExpandEnv(candidate))
|
||||||
if err != nil {
|
if err == nil {
|
||||||
if errors.Is(err, os.ErrNotExist) {
|
// First specified provider "candidate" wins.
|
||||||
continue
|
logrus.Debugf("Found compose provider %q", path)
|
||||||
}
|
return path, nil
|
||||||
return "", err
|
|
||||||
}
|
}
|
||||||
// First specified provider "candidate" wins.
|
logrus.Debugf("Error looking up compose provider %q: %v", path, err)
|
||||||
logrus.Debugf("Found compose provider %q", path)
|
lookupErrors = append(lookupErrors, err)
|
||||||
return path, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", errors.New("no configured compose provider found on system, please refer to the documentation for details")
|
return "", fmt.Errorf("looking up compose provider failed\n%v", errorhandling.JoinErrors(lookupErrors))
|
||||||
}
|
}
|
||||||
|
|
||||||
// composeDockerHost returns the value to be set in the DOCKER_HOST environment
|
// composeDockerHost returns the value to be set in the DOCKER_HOST environment
|
||||||
|
|
Loading…
Reference in New Issue