Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ COPY docs/ ./docs/
COPY README.md LICENSE ./

# Copy playground test cases for development/testing
COPY tests/test_cases/passing_template /playground
COPY tests/test_cases/passing_template/api_playground/* /playground/api_config/
COPY tests/test_cases/passing_template/configurations/* /playground/configurations/
COPY tests/test_cases/passing_template/dictionaries/* /playground/dictionaries/
COPY tests/test_cases/passing_template/enumerators/* /playground/enumerators/
COPY tests/test_cases/passing_template/migrations/* /playground/migrations/
COPY tests/test_cases/passing_template/test_data/* /playground/test_data/
COPY tests/test_cases/passing_template/types/* /playground/types/
RUN chmod -R 777 /playground

# Install dependencies
RUN pipenv install --deploy --system
Expand All @@ -34,7 +41,8 @@ RUN pip install gunicorn

# Create non-root user for security
RUN useradd --create-home --shell /bin/bash app && \
chown -R app:app /opt/mongo_configurator
chown -R app:app /opt/mongo_configurator && \
chown -R app:app /playground

# Switch to non-root user
USER app
Expand Down
12 changes: 11 additions & 1 deletion configurator/services/configuration_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from configurator.utils.configurator_exception import ConfiguratorEvent, ConfiguratorException
from configurator.services.enumeration_service import Enumerations
from configurator.services.enumerators import Enumerators
import logging

logger = logging.getLogger(__name__)

class Version:
def __init__(self, collection_name: str, document: dict):
Expand Down Expand Up @@ -54,13 +57,15 @@ def process(self, mongo_io: MongoIO) -> ConfiguratorEvent:
"target_version": self.version_number.get_version_str()
}
event.record_success()
logger.info(f"Version {self.version_str} already implemented")
return event

# Remove schema validation
sub_event = ConfiguratorEvent(event_id="PRO-01", event_type="REMOVE_SCHEMA_VALIDATION")
event.append_events([sub_event])
sub_event.append_events(mongo_io.remove_schema_validation(self.collection_name))
sub_event.record_success()
logger.info(f"Schema validation removed for {self.collection_name}")

# Remove indexes
if self.drop_indexes:
Expand All @@ -69,6 +74,7 @@ def process(self, mongo_io: MongoIO) -> ConfiguratorEvent:
for index_name in self.drop_indexes:
sub_event.append_events(mongo_io.remove_index(self.collection_name, index_name))
sub_event.record_success()
logger.info(f"Indexes removed for {self.collection_name}")

# Execute migrations
if self.migrations:
Expand All @@ -78,6 +84,7 @@ def process(self, mongo_io: MongoIO) -> ConfiguratorEvent:
migration_file = os.path.join(self.config.INPUT_FOLDER, self.config.MIGRATIONS_FOLDER, filename)
sub_event.append_events(mongo_io.execute_migration_from_file(self.collection_name, migration_file))
sub_event.record_success()
logger.info(f"Migrations executed for {self.collection_name}")

# Add indexes
if self.add_indexes:
Expand All @@ -86,6 +93,7 @@ def process(self, mongo_io: MongoIO) -> ConfiguratorEvent:
for index in self.add_indexes:
sub_event.append_events(mongo_io.add_index(self.collection_name, index))
sub_event.record_success()
logger.info(f"Indexes added for {self.collection_name}")

# Apply schema validation
sub_event = ConfiguratorEvent(event_id="PRO-06", event_type="APPLY_SCHEMA_VALIDATION")
Expand All @@ -96,6 +104,7 @@ def process(self, mongo_io: MongoIO) -> ConfiguratorEvent:
# Add schema context to event
sub_event.append_events(mongo_io.apply_schema_validation(self.collection_name, bson_schema))
sub_event.record_success()
logger.info(f"Schema validation applied for {self.collection_name}")

# Load test data
if self.test_data:
Expand All @@ -105,6 +114,7 @@ def process(self, mongo_io: MongoIO) -> ConfiguratorEvent:
sub_event.data = {"test_data_path": test_data_path}
sub_event.append_events(mongo_io.load_json_data(self.collection_name, test_data_path))
sub_event.record_success()
logger.info(f"Test data loaded for {self.collection_name}")

# Update version
sub_event = ConfiguratorEvent(event_id="PRO-08", event_type="UPDATE_VERSION")
Expand All @@ -116,7 +126,7 @@ def process(self, mongo_io: MongoIO) -> ConfiguratorEvent:
)
sub_event.data = result
sub_event.record_success()

logger.info(f"Version {self.version_str} processed")
event.record_success()
return event

Expand Down
1 change: 1 addition & 0 deletions configurator/utils/route_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def wrapper(*args, **kwargs):
try:
result = f(*args, **kwargs)
# Routes are responsible for their own serialization
logger.info(f"Configurator success in {operation_name}")
return result
except ConfiguratorException as e:
logger.error(f"Configurator error in {operation_name}: {str(e)}")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
False
1 change: 1 addition & 0 deletions tests/test_cases/passing_template/api_playground/BUILT_AT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Local
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
False
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mongodb://mongodb:27017/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
playground_database
Loading