Skip to content

Commit

Permalink
flake and pylint, certs back to rsa
Browse files Browse the repository at this point in the history
  • Loading branch information
szachovy committed Oct 11, 2024
1 parent 0a92cb8 commit 849d888
Show file tree
Hide file tree
Showing 17 changed files with 602 additions and 280 deletions.
2 changes: 1 addition & 1 deletion .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
ignored:
- DL3002 # Using gosu in some entrypoints
- DL3002
5 changes: 5 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[FORMAT]
max-line-length = 120
disable =
missing-class-docstring,
missing-function-docstring
45 changes: 27 additions & 18 deletions services/mysql-mgmt/interfaces.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
temp
"""

# pylint: disable=too-few-public-methods
# pylint: disable=invalid-name

import ctypes
import ctypes.util
Expand All @@ -7,38 +13,38 @@

class socket_address(ctypes.Structure):
_fields_ = [
('socket_address_family', ctypes.c_ushort),
('socket_address_code', ctypes.c_byte * 14)
("socket_address_family", ctypes.c_ushort),
("socket_address_code", ctypes.c_byte * 14)
]


class socket_interface(ctypes.Structure):
_fields_ = [
('socket_interface_family', ctypes.c_ushort),
('socket_interface_port', ctypes.c_uint16),
('socket_interface_address', ctypes.c_byte * 4)
("socket_interface_family", ctypes.c_ushort),
("socket_interface_port", ctypes.c_uint16),
("socket_interface_address", ctypes.c_byte * 4)
]


class network_interface_structure(ctypes.Structure):
pass


network_interface_structure._fields_ = [
('next_network_interface', ctypes.POINTER(network_interface_structure)),
('network_interface_name', ctypes.c_char_p),
('network_interface_flags', ctypes.c_uint),
('network_interface_address', ctypes.POINTER(socket_address)),
('network_interface_mask', ctypes.POINTER(socket_address)),
('network_interface_data', ctypes.c_void_p)
network_interface_structure._fields_ = [ # pylint: disable=protected-access
("next_network_interface", ctypes.POINTER(network_interface_structure)),
("network_interface_name", ctypes.c_char_p),
("network_interface_flags", ctypes.c_uint),
("network_interface_address", ctypes.POINTER(socket_address)),
("network_interface_mask", ctypes.POINTER(socket_address)),
("network_interface_data", ctypes.c_void_p)
]


def network_interfaces(network_interface: str) -> str | StopIteration:
clib: ctypes.CDLL = ctypes.CDLL(ctypes.util.find_library('c'))
network_interfaces: ctypes.POINTER = ctypes.POINTER(network_interface_structure)()
if clib.getifaddrs(ctypes.pointer(network_interfaces)) == 0:
current_interface: network_interface_structure = network_interfaces.contents
clib: ctypes.CDLL = ctypes.CDLL(ctypes.util.find_library("c"))
interfaces: ctypes.POINTER = ctypes.POINTER(network_interface_structure)()
if clib.getifaddrs(ctypes.pointer(interfaces)) == 0:
current_interface: network_interface_structure = interfaces.contents
while True:
if current_interface.network_interface_name == network_interface.encode() \
and current_interface.network_interface_data:
Expand All @@ -51,9 +57,12 @@ def network_interfaces(network_interface: str) -> str | StopIteration:
).contents.socket_interface_address
)
if not current_interface.next_network_interface:
clib.freeifaddrs(network_interfaces)
raise StopIteration(f'Provided network interface {network_interface} not found.')
clib.freeifaddrs(interfaces)
raise StopIteration(f"Provided network interface {network_interface} not found")
current_interface = current_interface.next_network_interface.contents
raise ValueError(
f"Network interface {network_interface} cannot be adjusted to be set with provided virtual ip address"
)


if __name__ == "__main__":
Expand Down
5 changes: 0 additions & 5 deletions services/superset/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,5 @@ ENTRYPOINT [ "/bin/bash", "-c", " \
gosu \
superset \
/app/entrypoint.sh \
&& \
chown \
--recursive \
root:root \
/app \
" \
]
15 changes: 11 additions & 4 deletions services/superset/mysql_connect.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
"""
temporary
"""
import json
import os

import superset
import superset.models.core
import superset # pylint: disable=import-error
import superset.models.core # pylint: disable=import-error


def create_mysql_connection():
with open('/run/secrets/mysql_superset_password', 'r') as mysql_superset_password:
with open(
file="/run/secrets/mysql_superset_password",
mode="r",
encoding="utf-8"
) as mysql_superset_password:
if not superset.db.session.query(superset.models.core.Database).filter_by(database_name='MySQL').first():
mysql_connection = superset.models.core.Database(
database_name='MySQL',
allow_run_async=True,
sqlalchemy_uri=f"mysql+mysqlconnector://superset:{mysql_superset_password.read().strip()}@{os.environ.get('VIRTUAL_IP_ADDRESS')}:6446/superset",
sqlalchemy_uri=f"mysql+mysqlconnector://superset:{mysql_superset_password.read().strip()}@{os.environ.get('VIRTUAL_IP_ADDRESS')}:6446/superset", # noqa: E501 pylint: disable=line-too-long
extra=json.dumps({
"async": True,
"engine_params": {},
Expand Down
16 changes: 10 additions & 6 deletions services/superset/superset_config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
"""
temp
"""

import flask_caching.backends.rediscache
import os

import flask_caching.backends.rediscache # pylint: disable=import-error

class CeleryConfig(object):

class CeleryConfig: # pylint: disable=too-few-public-methods
broker_url = "redis://redis:6379/0"
imports = (
"superset.sql_lab",
Expand All @@ -19,14 +23,14 @@ class CeleryConfig(object):
}


with open("/run/secrets/superset_secret_key", "r") as superset_secret_key:
with open(file="/run/secrets/superset_secret_key", mode="r", encoding="utf-8") as superset_secret_key:
SECRET_KEY = superset_secret_key.read().strip()


with open("/run/secrets/mysql_superset_password", "r") as mysql_superset_password:
SQLALCHEMY_DATABASE_URI = f"mysql+mysqlconnector://superset:{mysql_superset_password.read().strip()}@{os.environ.get('VIRTUAL_IP_ADDRESS')}:6446/superset"
with open(file="/run/secrets/mysql_superset_password", mode="r", encoding="utf-8") as mysql_superset_password:
SQLALCHEMY_DATABASE_URI = f"mysql+mysqlconnector://superset:{mysql_superset_password.read().strip()}@{os.environ.get('VIRTUAL_IP_ADDRESS')}:6446/superset" # noqa: E501 pylint: disable=line-too-long

CELERY_CONFIG = CeleryConfig
CELERY_CONFIG = CeleryConfig # pylint: disable=invalid-name
RESULTS_BACKEND = flask_caching.backends.rediscache.RedisCache(host="redis", port=6379, key_prefix="superset_results")
FILTER_STATE_CACHE_CONFIG = {
"CACHE_TYPE": "RedisCache",
Expand Down
Loading

0 comments on commit 849d888

Please sign in to comment.