1+ """
2+ Shared dependencies and configuration for Cloud Pak Deployer API.
3+
4+ This module contains global variables and configuration used across multiple services.
5+ """
6+
7+ import os
8+ import logging
9+ from pathlib import Path
10+
11+ # Configure logger
12+ logger = logging .getLogger (__name__ )
13+
14+ # Deployer directory and paths
15+ deployer_dir = Path (os .path .dirname (os .path .realpath (__file__ ))).parent .parent
16+ logger .info (f'Deployer directory: { deployer_dir } ' )
17+
18+ cp_base_config_path = os .path .join (deployer_dir , 'sample-configurations/sample-dynamic/config-samples' )
19+ ocp_base_config_path = os .path .join (deployer_dir , 'sample-configurations/sample-dynamic/config-samples' )
20+
21+ # Runtime context
22+ running_context = str (os .getenv ('CPD_CONTEXT' , default = 'local' ))
23+ logger .info (f'Deployer context: { running_context } ' )
24+ logger .info (f'Logging level (CPD_WIZARD_LOG_LEVEL): { str (os .getenv ("CPD_WIZARD_LOG_LEVEL" , default = "INFO" ))} ' )
25+
26+ # OpenShift project/namespace
27+ deployer_project = str (os .getenv ('CPD_DEPLOYER_PROJECT' , default = 'cloud-pak-deployer' ))
28+
29+ # Configuration and status directories
30+ config_dir = str (os .getenv ('CONFIG_DIR' ))
31+ status_dir = str (os .getenv ('STATUS_DIR' ))
32+
33+
34+ def get_deployer_dir () -> Path :
35+ """Get the deployer directory path."""
36+ return deployer_dir
37+
38+
39+ def get_running_context () -> str :
40+ """Get the current running context ('local' or 'openshift')."""
41+ return running_context
42+
43+
44+ def get_deployer_project () -> str :
45+ """Get the OpenShift deployer project/namespace name."""
46+ return deployer_project
47+
48+
49+ def get_config_dir () -> str :
50+ """Get the configuration directory path."""
51+ return config_dir
52+
53+
54+ def get_status_dir () -> str :
55+ """Get the status directory path."""
56+ return status_dir
57+
58+
59+ def get_cp_base_config_path () -> str :
60+ """Get the Cloud Pak base configuration path."""
61+ return cp_base_config_path
62+
63+
64+ def get_ocp_base_config_path () -> str :
65+ """Get the OpenShift base configuration path."""
66+ return ocp_base_config_path
0 commit comments