Add the initial package

pull/1/head
Raoul Snyman 2022-11-23 23:42:11 -07:00
parent 1a81d068d0
commit 93c7c623d9
9 changed files with 154 additions and 4 deletions

18
.editorconfig 100644
View File

@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{html,js,json,py,yaml,yml}]
indent_style = space
[*.py]
indent_size = 4
continuation_indent_size = 8
max_line_length = 120
[*.{html,js,json,yaml,yml}]
indent_size = 2

3
.flake8 100644
View File

@ -0,0 +1,3 @@
[flake8]
max-line-length = 120
ignore = E402,W503,W504

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) <year> <copyright holders>
Copyright (c) 2022-present Raoul Snyman <raoul@libertytechforce.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@ -1,3 +0,0 @@
# pyinfra-docker-compose
A pyinfra module to install the Docker Compose plugin.

27
README.rst 100644
View File

@ -0,0 +1,27 @@
pyinfra-docker-compose
======================
.. image:: https://img.shields.io/pypi/v/pyinfra
:alt: PyPI - Version
-----
A pyinfra module to install the Docker Compose plugin.
.. contents:: Table of Contents
:depth: 1
Installation
------------
.. code-block:: shell
pip install pyinfra-docker-compose
License
-------
``pyinfra-docker-compose`` is distributed under the terms of the `MIT`_ license.
.. MIT:: https://spdx.org/licenses/MIT.html

View File

@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: 2022-present Raoul Snyman <raoul@libertytechforce.com>
#
# SPDX-License-Identifier: MIT
from pyinfra_docker_compose.docker_compose import deploy_docker_compose # noqa

View File

@ -0,0 +1,40 @@
# SPDX-FileCopyrightText: 2022-present Raoul Snyman <raoul@libertytechforce.com>
#
# SPDX-License-Identifier: MIT
from pyinfra import host
from pyinfra.api.deploy import deploy
from pyinfra.api.exceptions import DeployError
from pyinfra.facts.deb import DebPackages
from pyinfra.facts.rpm import RpmPackages
from pyinfra.facts.server import Which
from pyinfra.operations import apt, dnf, yum
def _apt_install():
apt.packages(
name='Install Docker Compose plugin via apt',
packages='docker-compose-plugin',
update=True
)
def _yum_or_dnf_install(yum_or_dnf):
yum_or_dnf.packages(
name='Install Docker Compose plugin via yum',
packages=['docker-compose-plugin']
)
@deploy('Deploy Docker Compose')
def deploy_docker_compose():
"""
Install the Docker Compose plugin on the target machine.
"""
if host.get_fact(DebPackages):
_apt_install()
elif host.get_fact(RpmPackages):
_yum_or_dnf_install(dnf if host.get_fact(Which, command='dnf') else yum)
else:
raise DeployError('Neither apt or yum were found, pyinfra-docker-compose cannot provision this machine!')

58
pyproject.toml 100644
View File

@ -0,0 +1,58 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
[project]
name = "pyinfra-docker-compose"
description = ''
readme = "README.md"
requires-python = ">=3.7"
license = "MIT"
keywords = []
authors = [
{ name = "Raoul Snyman", email = "raoul@libertytechforce.com" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = ["pyinfra-docker"]
dynamic = ["version"]
[project.urls]
Documentation = "https://git.libertytechforce.com/libertytechforce/pyinfra-docker-compose#readme"
Issues = "https://git.libertytechforce.com/libertytechforce/pyinfra-docker-compose/issues"
Source = "https://git.libertytechforce.com/libertytechforce/pyinfra-docker-compose"
[tool.hatch.version]
source = "vcs"
[tool.hatch.envs.default]
dependencies = [
"pytest",
"pytest-cov",
]
[tool.hatch.envs.default.scripts]
cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=pyinfra_docker_compose --cov=tests"
no-cov = "cov --no-cov"
[[tool.hatch.envs.test.matrix]]
python = ["37", "38", "39", "310", "311"]
[tool.coverage.run]
branch = true
parallel = true
[tool.coverage.report]
exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]

View File

@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2022-present Raoul Snyman <raoul@libertytechforce.com>
#
# SPDX-License-Identifier: MIT