Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara committed Jan 5, 2022
2 parents f2462a9 + d33dfe4 commit 63b2993
Show file tree
Hide file tree
Showing 23 changed files with 297 additions and 256 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
run: |
python -m pip install --upgrade pip
- name: Build Python wheels
uses: RalfG/[email protected].3-manylinux2010_x86_64
uses: RalfG/[email protected].4-manylinux2010_x86_64
with:
python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39'
python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310'
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand Down
34 changes: 17 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@
*More:* docs_ repo_ docker_images_
====================== =================== =================== ===================

.. _lib: https://github.com/Parakoopa/riptide-lib
.. _cli: https://github.com/Parakoopa/riptide-cli
.. _proxy: https://github.com/Parakoopa/riptide-proxy
.. _configcrunch: https://github.com/Parakoopa/configcrunch
.. _engine_docker: https://github.com/Parakoopa/riptide-engine-docker
.. _db_mysql: https://github.com/Parakoopa/riptide-db-mysql
.. _db_mongo: https://github.com/Parakoopa/riptide-db-mongo
.. _docs: https://github.com/Parakoopa/riptide-docs
.. _repo: https://github.com/Parakoopa/riptide-repo
.. _docker_images: https://github.com/Parakoopa/riptide-docker-images
.. _php_xdebug: https://github.com/Parakoopa/riptide-plugin-php-xdebug
.. _k8s_client: https://github.com/Parakoopa/riptide-k8s-client
.. _k8s_controller: https://github.com/Parakoopa/riptide-k8s-controller
.. _lib: https://github.com/theCapypara/riptide-lib
.. _cli: https://github.com/theCapypara/riptide-cli
.. _proxy: https://github.com/theCapypara/riptide-proxy
.. _configcrunch: https://github.com/theCapypara/configcrunch
.. _engine_docker: https://github.com/theCapypara/riptide-engine-docker
.. _db_mysql: https://github.com/theCapypara/riptide-db-mysql
.. _db_mongo: https://github.com/theCapypara/riptide-db-mongo
.. _docs: https://github.com/theCapypara/riptide-docs
.. _repo: https://github.com/theCapypara/riptide-repo
.. _docker_images: https://github.com/theCapypara/riptide-docker-images
.. _php_xdebug: https://github.com/theCapypara/riptide-plugin-php-xdebug
.. _k8s_client: https://github.com/theCapypara/riptide-k8s-client
.. _k8s_controller: https://github.com/theCapypara/riptide-k8s-controller

|build| |docs| |pypi-version| |pypi-downloads| |pypi-license| |pypi-pyversions| |slack|

.. |build| image:: https://img.shields.io/github/workflow/status/Parakoopa/riptide-lib/Build,%20test%20and%20publish
:target: https://github.com/Parakoopa/riptide-lib/actions
.. |build| image:: https://img.shields.io/github/workflow/status/theCapypara/riptide-lib/Build,%20test%20and%20publish
:target: https://github.com/theCapypara/riptide-lib/actions
:alt: Build Status

.. |docs| image:: https://readthedocs.org/projects/riptide-docs/badge/?version=latest
:target: https://riptide-docs.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. |slack| image:: https://slack.riptide.parakoopa.de/badge.svg
:target: https://slack.riptide.parakoopa.de
.. |slack| image:: https://slack.riptide.theCapypara.de/badge.svg
:target: https://slack.riptide.theCapypara.de
:alt: Join our Slack workspace

.. |pypi-version| image:: https://img.shields.io/pypi/v/riptide-lib
Expand Down
18 changes: 8 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# TEMPORARY, see #2:
idna==2.8
schema==0.7.1
pyyaml==5.1.2
configcrunch==0.3.7
appdirs==1.4.3
janus==0.4.0
psutil==5.6.6
GitPython==3.0.8
schema==0.7.5
pyyaml==5.4
configcrunch==1.0.0
appdirs==1.4.4
janus==0.7.0
psutil==5.8.0
GitPython==3.1.24
pywinpty==0.5.5; sys_platform == 'win32'
python-hosts==0.4.7
python-dotenv==0.19.0
python-dotenv==0.19.2
8 changes: 4 additions & 4 deletions requirements_extra_riptide_from_git.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-e git+https://github.com/Parakoopa/riptide-cli.git#egg=riptide-cli
-e git+https://github.com/Parakoopa/riptide-proxy.git#egg=riptide-proxy
-e git+https://github.com/Parakoopa/riptide-engine-docker.git#egg=riptide-engine_docker
-e git+https://github.com/Parakoopa/riptide-db-mysql.git#egg=riptide-db_mysql
-e git+https://github.com/theCapypara/riptide-cli.git#egg=riptide-cli
-e git+https://github.com/theCapypara/riptide-proxy.git#egg=riptide-proxy
-e git+https://github.com/theCapypara/riptide-engine-docker.git#egg=riptide-engine_docker
-e git+https://github.com/theCapypara/riptide-db-mysql.git#egg=riptide-db_mysql
2 changes: 1 addition & 1 deletion riptide/assets/blank_user_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ riptide:
# List of Riptide repositories.
repos:
# Public Riptide repo by the community
- https://github.com/Parakoopa/riptide-repo.git
- https://github.com/theCapypara/riptide-repo.git

# Add all project hostnames to the /etc/hosts file automatically, see documentation.
update_hosts_file: true
Expand Down
6 changes: 4 additions & 2 deletions riptide/config/command/in_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ def convert_in_service_to_normal(app: App, command_name: str) -> Command:
env = {}
env.update(service['environment'] if 'environment' in service else {})
env.update(old_cmd['environment'] if 'environment' in old_cmd else {})
new_cmd = Command({
new_cmd = Command.from_dict({
'$name': command_name,
'image': service['image'],
'command': old_cmd['command'],
'additional_volumes': service['additional_volumes'] if 'additional_volumes' in service else {},
'environment': env,
'config_from_roles': [old_cmd['in_service_with_role']]
}, parent=app)
})
new_cmd.parent_doc = app
new_cmd.freeze()
return new_cmd


Expand Down
54 changes: 18 additions & 36 deletions riptide/config/document/app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from schema import Optional, Schema, Or
from typing import List, Union, TYPE_CHECKING
from typing import List, Union, TYPE_CHECKING, Tuple, Type

from configcrunch import YamlConfigDocument, DocReference, ConfigcrunchError, REMOVE
from configcrunch import load_subdocument
from configcrunch.abstract import variable_helper
from configcrunch import variable_helper
from riptide.config.document.command import Command
from riptide.config.document.service import Service

Expand Down Expand Up @@ -120,45 +119,28 @@ def schema(cls) -> Schema:
}
)

@classmethod
def subdocuments(cls) -> List[Tuple[str, Type[YamlConfigDocument]]]:
return [
("services[]", Service),
("commands[]", Command),
]

def validate(self):
"""
Initialise the optional services and command dicts.
Has to be done after validate because of some issues with Schema validation error handling :(
"""
ret_val = super().validate()
if ret_val:
if "services" not in self:
self.doc["services"] = {}

if "commands" not in self:
self.doc["commands"] = {}
if not self.internal_contains("services"):
self.internal_set("services", {})
if not self.internal_contains("commands"):
self.internal_set("commands", {})
return ret_val

def _load_subdocuments(self, lookup_paths: List[str]):
if "services" in self and self["services"] != REMOVE:
for key, servicedoc in self["services"].items():
if servicedoc != REMOVE:
self["services"][key] = load_subdocument(servicedoc, self, Service, lookup_paths)
if not isinstance(self["services"][key].doc, dict):
raise ConfigcrunchError(
f"Error loading Service for App: The service with the name {key} needs to be an object in the source document."
)
self["services"][key]["$name"] = key

if "commands" in self and self["commands"] != REMOVE:
for key, commanddoc in self["commands"].items():
if commanddoc != REMOVE:
self["commands"][key] = load_subdocument(commanddoc, self, Command, lookup_paths)
if not isinstance(self["commands"][key].doc, dict):
raise ConfigcrunchError(
f"Error loading Command for App: The command with the name {key} needs to be an object in the source document."
)
self["commands"][key]["$name"] = key

return self

def error_str(self) -> str:
return f"{self.__class__.__name__}<{(self['name'] if 'name' in self else '???')}>"
return f"{self.__class__.__name__}<{(self.internal_get('name') if self.internal_contains('name') else '???')}>"

@variable_helper
def parent(self) -> 'Project':
Expand Down Expand Up @@ -191,8 +173,8 @@ def get_service_by_role(self, role_name: str) -> Union[Service, None]:
:param role_name: Role to search for
"""
for service in self["services"].values():
if "roles" in service and role_name in service["roles"]:
for service in self.internal_get("services").values():
if service.internal_contains("roles") and role_name in service.internal_get("roles"):
return service
raise ValueError(f"No service with role {role_name} found in the app.")

Expand All @@ -204,7 +186,7 @@ def get_services_by_role(self, role_name: str) -> List[Service]:
:param role_name: Role to search for
"""
services = []
for service in self["services"].values():
if "roles" in service and role_name in service["roles"]:
for service in self.internal_get("services").values():
if service.internal_contains("roles") and role_name in service.internal_get("roles"):
services.append(service)
return services
24 changes: 14 additions & 10 deletions riptide/config/document/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from schema import Schema, Optional, Or
from typing import TYPE_CHECKING, Union

from configcrunch.abstract import variable_helper
from configcrunch import variable_helper
from riptide.config.document.common_service_command import ContainerDefinitionYamlConfigDocument
from riptide.config.files import get_project_meta_folder, CONTAINER_SRC_PATH
from riptide.config.service.config_files import process_config
Expand Down Expand Up @@ -93,7 +93,8 @@ def schema_normal(cls):
into the command container.
[read_env_file]: bool
If enabled, read the environment variables in the ``.env`` file. Default: True
If enabled, read the environment variables in the env-files defined in the project (``env_files``).
Default: True
**Example Document:**
Expand Down Expand Up @@ -156,7 +157,8 @@ def schema_in_service(cls):
Key is the name of the variable, value is the value.
[read_env_file]: bool
If enabled, read the environment variables in the ``.env`` file. Default: True
If enabled, read the environment variables in the env-files defined in the project (``env_files``).
Default: True
**Example Document:**
Expand Down Expand Up @@ -196,14 +198,15 @@ def schema_alias(cls):
'aliases': str
})

def _initialize_data_after_variables(self):
def _initialize_data_after_variables(self, data: dict) -> dict:
""" Normalize all host-paths to only use the system-type directory separator """
if "additional_volumes" in self:
for obj in self.doc["additional_volumes"].values():
if "additional_volumes" in data:
for obj in data["additional_volumes"].values():
obj["host"] = cppath.normalize(obj["host"])

if "read_env_file" not in self:
self.doc["read_env_file"] = True
data["read_env_file"] = True
return data

def get_project(self) -> 'Project':
"""
Expand Down Expand Up @@ -304,7 +307,8 @@ def collect_environment(self) -> dict:
env[key] = value

if "read_env_file" not in self or self["read_env_file"]:
env.update(dotenv_values(os.path.join(self.get_project().folder(), '.env')))
for env_file_path in self.get_project()['env_files']:
env.update(dotenv_values(os.path.join(self.get_project().folder(), env_file_path)))

try:
cols, lines = os.get_terminal_size()
Expand Down Expand Up @@ -344,7 +348,7 @@ def get_service(self, app: 'App') -> Union[str, None]:
f"No service with this role found in the app.")

def error_str(self) -> str:
return f"{self.__class__.__name__}<{(self['$name'] if '$name' in self else '???')}>"
return f"{self.__class__.__name__}<{(self.internal_get('$name') if self.internal_contains('$name') else '???')}>"

@variable_helper
def parent(self) -> 'App':
Expand Down Expand Up @@ -381,6 +385,6 @@ def volume_path(self) -> str:
host: '/home/peter/my_projects/project1/_riptide/cmd_data/command_name/command_cache'
container: '/foo/bar/cache'
"""
path = os.path.join(get_project_meta_folder(self.get_project().folder()), 'cmd_data', self["$name"])
path = os.path.join(get_project_meta_folder(self.get_project().folder()), 'cmd_data', self.internal_get("$name"))
os.makedirs(path, exist_ok=True)
return path
4 changes: 4 additions & 0 deletions riptide/config/document/common_service_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@


class ContainerDefinitionYamlConfigDocument(YamlConfigDocument, ABC):
@classmethod
def subdocuments(cls):
return []

@variable_helper
def system_config(self) -> 'Config':
"""
Expand Down
34 changes: 18 additions & 16 deletions riptide/config/document/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def schema(cls) -> Schema:
- 127.0.0.1/32
engine: docker
repos:
- https://github.com/Parakoopa/riptide-repo.git
- https://github.com/theCapypara/riptide-repo.git
update_hosts_file: true
performance:
dont_sync_named_volumes_with_host: auto
Expand Down Expand Up @@ -155,10 +155,11 @@ def schema(cls) -> Schema:
}
)

def _load_subdocuments(self, lookup_paths: List[str]):
@classmethod
def subdocuments(cls):
# Can not contain references to other documents other than
# the "project" reference which is added by the system.
return self
return []

def error_str(self) -> str:
return "System Configuration"
Expand Down Expand Up @@ -197,19 +198,20 @@ def get_plugin_flag(self, inp: str) -> any:
def upgrade(self):
"""Update the system configuration file after Riptide version upgrades. To be run before validation."""
changed = False
if "performance" not in self.doc:
self.doc["performance"] = {}
changed = True
if "dont_sync_named_volumes_with_host" not in self.doc["performance"]:
self.doc["performance"]["dont_sync_named_volumes_with_host"] = "auto"
changed = True
if "dont_sync_unimportant_src" not in self.doc["performance"]:
self.doc["performance"]["dont_sync_unimportant_src"] = "auto"
changed = True

if changed:
with open(riptide_main_config_file(), "w") as f:
f.write(yaml.dump(self.to_dict(), default_flow_style=False, sort_keys=False))
with self.internal_access():
if "performance" not in self.doc:
self.doc["performance"] = {}
changed = True
if "dont_sync_named_volumes_with_host" not in self.doc["performance"]:
self.doc["performance"]["dont_sync_named_volumes_with_host"] = "auto"
changed = True
if "dont_sync_unimportant_src" not in self.doc["performance"]:
self.doc["performance"]["dont_sync_unimportant_src"] = "auto"
changed = True

if changed:
with open(riptide_main_config_file(), "w") as f:
f.write(yaml.dump(self.to_dict(), default_flow_style=False, sort_keys=False))

def load_performance_options(self, engine: 'AbstractEngine'):
"""Initializes performance options set to 'auto' based on the engine used."""
Expand Down
Loading

0 comments on commit 63b2993

Please sign in to comment.