Skip to content

Commit

Permalink
fix(binary options): fix an issue introduced by #141 and force lf
Browse files Browse the repository at this point in the history
  • Loading branch information
darkanakin41 authored Jan 13, 2021
1 parent 2a8142c commit 76c7bf2
Show file tree
Hide file tree
Showing 37 changed files with 3,097 additions and 3,097 deletions.
28 changes: 14 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/.pytest_cache/
/.eggs/
/.coverage
/.python-version
/.tox/
*.egg-info
__pycache__/
*.pyc
*.pyo
./.idea
.idea
/dist/
/build/
/site/
/.pytest_cache/
/.eggs/
/.coverage
/.python-version
/.tox/
*.egg-info
__pycache__/
*.pyc
*.pyo
./.idea
.idea
/dist/
/build/
/site/
/out/
34 changes: 17 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
doc-watch:
docker run --rm -it -p 8000:8000 --user $(id -u):$(id -g) -v ${PWD}:/docs squidfunk/mkdocs-material serve

doc-publish:
docker run --rm -it -p 8000:8000 --user $(id -u):$(id -g) -v ${PWD}/..:/docs -v ${HOME}/.netrc:/.netrc:ro --workdir=/docs/ddb squidfunk/mkdocs-material gh-deploy

git-pre-push:
make style
make test

style:
pylint ddb

test:
pytest

check-manifest:
doc-watch:
docker run --rm -it -p 8000:8000 --user $(id -u):$(id -g) -v ${PWD}:/docs squidfunk/mkdocs-material serve

doc-publish:
docker run --rm -it -p 8000:8000 --user $(id -u):$(id -g) -v ${PWD}/..:/docs -v ${HOME}/.netrc:/.netrc:ro --workdir=/docs/ddb squidfunk/mkdocs-material gh-deploy

git-pre-push:
make style
make test

style:
pylint ddb

test:
pytest

check-manifest:
check-manifest -u -v
78 changes: 39 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
ddb
===

[![PyPI](https://img.shields.io/pypi/v/docker-devbox-ddb)](https://pypi.org/project/docker-devbox-ddb/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/docker-devbox-ddb)](https://pypi.org/project/docker-devbox-ddb/)
[![PyPI - License](https://img.shields.io/pypi/l/docker-devbox-ddb)](https://github.com/gfi-centre-ouest/docker-devbox-ddb/blob/develop/LICENSE)
[![Build Status](https://github.com/gfi-centre-ouest/docker-devbox-ddb/workflows/build/badge.svg)](https://github.com/gfi-centre-ouest/docker-devbox-ddb/actions?query=workflow%3Abuild)
[![Code coverage](https://img.shields.io/coveralls/github/gfi-centre-ouest/docker-devbox-ddb)](https://coveralls.io/github/gfi-centre-ouest/docker-devbox-ddb)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/relekang/python-semantic-release)

**[Erase environment differences, make developers happy !](https://gfi-centre-ouest.github.io/docker-devbox-ddb)**

**ddb** automates application configuration so differences between development, staging and production environment can
be erased. It provides features to generate, activate and adjust configuration files based on a single overridable and
extendable configuration, while enhancing the developer experience and reducing manual operations.

Primarly designed for [docker-compose](https://docs.docker.com/compose/) and [docker-devbox](https://github.com/gfi-centre-ouest/docker-devbox),
this tool makes the developer forget about the docker hard stuff by providing commands right into it's PATH, so it's
experience looks like everything is native and locally installed.

Thanks to a pluggable, event based and easy to extend architecture, it can bring powerful configuration automation to
any technical context.

Install
-------

**ddb** is supported on Linux and Windows. MacOS is still unsupported, but it should come soon.

You can [download binary releases on github](https://github.com/gfi-centre-ouest/docker-devbox-ddb/releases), or
install on Python >= 3.5 with pip.

```
pip install docker-devbox-ddb
```

Docs
----

[Documentation is available here](https://gfi-centre-ouest.github.io/docker-devbox-ddb)
ddb
===

[![PyPI](https://img.shields.io/pypi/v/docker-devbox-ddb)](https://pypi.org/project/docker-devbox-ddb/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/docker-devbox-ddb)](https://pypi.org/project/docker-devbox-ddb/)
[![PyPI - License](https://img.shields.io/pypi/l/docker-devbox-ddb)](https://github.com/gfi-centre-ouest/docker-devbox-ddb/blob/develop/LICENSE)
[![Build Status](https://github.com/gfi-centre-ouest/docker-devbox-ddb/workflows/build/badge.svg)](https://github.com/gfi-centre-ouest/docker-devbox-ddb/actions?query=workflow%3Abuild)
[![Code coverage](https://img.shields.io/coveralls/github/gfi-centre-ouest/docker-devbox-ddb)](https://coveralls.io/github/gfi-centre-ouest/docker-devbox-ddb)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/relekang/python-semantic-release)

**[Erase environment differences, make developers happy !](https://gfi-centre-ouest.github.io/docker-devbox-ddb)**

**ddb** automates application configuration so differences between development, staging and production environment can
be erased. It provides features to generate, activate and adjust configuration files based on a single overridable and
extendable configuration, while enhancing the developer experience and reducing manual operations.

Primarly designed for [docker-compose](https://docs.docker.com/compose/) and [docker-devbox](https://github.com/gfi-centre-ouest/docker-devbox),
this tool makes the developer forget about the docker hard stuff by providing commands right into it's PATH, so it's
experience looks like everything is native and locally installed.

Thanks to a pluggable, event based and easy to extend architecture, it can bring powerful configuration automation to
any technical context.

Install
-------

**ddb** is supported on Linux and Windows. MacOS is still unsupported, but it should come soon.

You can [download binary releases on github](https://github.com/gfi-centre-ouest/docker-devbox-ddb/releases), or
install on Python >= 3.5 with pip.

```
pip install docker-devbox-ddb
```

Docs
----

[Documentation is available here](https://gfi-centre-ouest.github.io/docker-devbox-ddb)
206 changes: 103 additions & 103 deletions ddb/binary/binary.py
Original file line number Diff line number Diff line change
@@ -1,103 +1,103 @@
# -*- coding: utf-8 -*-
from abc import abstractmethod, ABC
from typing import Iterable, Tuple

from ddb.registry import RegistryObject


class Binary(RegistryObject, ABC):
"""
Wraps a binary on the system.
"""

@property
@abstractmethod
def name(self) -> str:
"""
Name of the binary.
"""

@abstractmethod
def command(self, *args) -> Iterable[str]:
"""
Get the binary command.
"""

@abstractmethod
def should_run(self, *args) -> bool:
"""
Check if this binary should run.
"""

@abstractmethod
def priority(self) -> int:
"""
Priority of this binary amoung binaries with the same name that should run.
"""

@abstractmethod
def before_run(self, *args) -> None:
"""
Add action to be executed before running the command.
"""

@abstractmethod
def __eq__(self, other) -> bool:
pass

@abstractmethod
def __hash__(self):
pass


class AbstractBinary(Binary, ABC):
"""
Abstract implementation for binary.
"""

def __init__(self, name: str):
self._name = name

@property
def name(self) -> str:
return self._name

def before_run(self, *args) -> None:
return None

def should_run(self, *args) -> bool:
return True

def priority(self) -> int:
return 0

def __eq__(self, other) -> bool:
if not isinstance(other, AbstractBinary):
return False
return self.name == other.name

def __hash__(self):
return hash((self.name,))


class DefaultBinary(AbstractBinary):
"""
Default implementation for binary.
"""

def __init__(self, name: str, command: Iterable[str]):
super().__init__(name)
self._command = tuple(command)

def command(self, *args) -> Tuple[str]:
return self._command

def __eq__(self, other) -> bool:
if not super().__eq__(other):
return False
if not isinstance(other, DefaultBinary):
return False
return self.command() == other.command()

def __hash__(self):
return hash((super().__hash__(), self.command()))
# -*- coding: utf-8 -*-
from abc import abstractmethod, ABC
from typing import Iterable, Tuple

from ddb.registry import RegistryObject


class Binary(RegistryObject, ABC):
"""
Wraps a binary on the system.
"""

@property
@abstractmethod
def name(self) -> str:
"""
Name of the binary.
"""

@abstractmethod
def command(self, *args) -> Iterable[str]:
"""
Get the binary command.
"""

@abstractmethod
def should_run(self, *args) -> bool:
"""
Check if this binary should run.
"""

@abstractmethod
def priority(self) -> int:
"""
Priority of this binary amoung binaries with the same name that should run.
"""

@abstractmethod
def before_run(self, *args) -> None:
"""
Add action to be executed before running the command.
"""

@abstractmethod
def __eq__(self, other) -> bool:
pass

@abstractmethod
def __hash__(self):
pass


class AbstractBinary(Binary, ABC):
"""
Abstract implementation for binary.
"""

def __init__(self, name: str):
self._name = name

@property
def name(self) -> str:
return self._name

def before_run(self, *args) -> None:
return None

def should_run(self, *args) -> bool:
return True

def priority(self) -> int:
return 0

def __eq__(self, other) -> bool:
if not isinstance(other, AbstractBinary):
return False
return self.name == other.name

def __hash__(self):
return hash((self.name,))


class DefaultBinary(AbstractBinary):
"""
Default implementation for binary.
"""

def __init__(self, name: str, command: Iterable[str]):
super().__init__(name)
self._command = tuple(command)

def command(self, *args) -> Tuple[str]:
return self._command

def __eq__(self, other) -> bool:
if not super().__eq__(other):
return False
if not isinstance(other, DefaultBinary):
return False
return self.command() == other.command()

def __hash__(self):
return hash((super().__hash__(), self.command()))
2 changes: 1 addition & 1 deletion ddb/feature/docker/binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def command(self, *args) -> Iterable[str]:
command = effective_command("docker-compose", *params)
return command

def add_options_to_params(self, params, options, condition, *args): # pylint: disable=no-self-use
def add_options_to_params(self, params, options, condition, *args):
"""
Add options to params if condition is fulfilled
:param params: the list of parameters
Expand Down
Loading

0 comments on commit 76c7bf2

Please sign in to comment.