Skip to content

Commit

Permalink
Merge pull request #20 from Mahesh-Binayak/mbupdates
Browse files Browse the repository at this point in the history
[MOSIP-31232]Updated Dockerfile
  • Loading branch information
Mahesh-Binayak authored May 21, 2024
2 parents 5903356 + 26e1d49 commit da574c4
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions certmanager/checkupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,25 +147,45 @@ def upload_certificate_with_token(token, cert_data, partner_id, base_url):
postgres_password = os.environ.get('postgres-password')
base_url = os.environ.get('mosip-api-internal-host')
client_secret = os.environ.get('mosip_pms_client_secret')

# If environment variables are not set, read from bootstrap.properties file
if not all([postgres_host, postgres_port, postgres_user, postgres_password, base_url, client_secret]):
pre_expiry_days = os.environ.get('pre-expiry-days')

missing_env_vars = []

if not postgres_host:
missing_env_vars.append('db-host')
if not postgres_port:
missing_env_vars.append('db-port')
if not postgres_user:
missing_env_vars.append('db-su-user')
if not postgres_password:
missing_env_vars.append('postgres-password')
if not base_url:
missing_env_vars.append('mosip-api-internal-host')
if not client_secret:
missing_env_vars.append('mosip_pms_client_secret')
if not pre_expiry_days:
missing_env_vars.append('pre-expiry-days')

# If any environment variables are not set, read from bootstrap.properties file
if missing_env_vars:
print(f"Missing environment variables: {', '.join(missing_env_vars)}. Falling back to bootstrap.properties.")
config = ConfigParser()
config.read('bootstrap.properties')
postgres_host = config.get('Database', 'db-host', fallback='')
postgres_port = config.get('Database', 'db-port', fallback='')
postgres_user = config.get('Database', 'db-su-user', fallback='')
postgres_password = config.get('Database', 'postgres-password', fallback='')
base_url = config.get('API', 'mosip-api-internal-host', fallback='')
client_secret = config.get('API', 'mosip_pms_client_secret', fallback='')
postgres_host = config.get('Database', 'db-host', fallback=postgres_host)
postgres_port = config.get('Database', 'db-port', fallback=postgres_port)
postgres_user = config.get('Database', 'db-su-user', fallback=postgres_user)
postgres_password = config.get('Database', 'postgres-password', fallback=postgres_password)
base_url = config.get('API', 'mosip-api-internal-host', fallback=base_url)
client_secret = config.get('API', 'mosip_pms_client_secret', fallback=client_secret)
pre_expiry_days = config.get('API', 'pre-expiry-days', fallback=pre_expiry_days)

# Authenticate and get the token
TOKEN = authenticate_and_get_token(base_url, client_secret)

# Check if token is obtained successfully
if TOKEN:
# Read pre-expiry days from bootstrap.properties
PRE_EXPIRY_DAYS = read_bootstrap_properties("pre-expiry-days")
PRE_EXPIRY_DAYS = pre_expiry_days

# PARTNER_IDS read from partner.properties
with open('partner.properties', 'r') as file:
Expand Down

0 comments on commit da574c4

Please sign in to comment.