-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed ansible-test to use docker if available (#99)
Now all ansible-test commands will make use of docker if docker is detected as present and running. The fallback remains to use the `--venv` option. This also enables users to test against any python versions supported by ansible, even if they do not have it installed locally.
- Loading branch information
Showing
2 changed files
with
32 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import subprocess | ||
from functools import lru_cache | ||
|
||
|
||
@lru_cache() | ||
def use_docker() -> bool: | ||
"""Return true if we should use docker.""" | ||
# docker version command works even if service is not accesible, but | ||
# info should pass only if we have a running service. | ||
try: | ||
result = subprocess.run( | ||
["docker", "info"], | ||
check=False, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
return result.returncode == 0 | ||
except FileNotFoundError: | ||
pass | ||
return False |