Skip to content

Commit

Permalink
Corrected environment type as few exceptions encountered in env type
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandhya1874 committed Jan 19, 2025
1 parent 1216894 commit be5326c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions github_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from slack_sdk.errors import SlackApiError
import base64
import jwt
import time
from github import Github, Auth
from datetime import datetime, timedelta
from github.GithubException import UnknownObjectException
Expand Down Expand Up @@ -1284,15 +1283,25 @@ def get_github_kubernetes_environment_variables(repo_name):
for env in repo.get_environments():
repo_env_data = repo.get_environment(env.name)
env_vars = repo_env_data.get_variables()
print(f"values: {env_vars}")
env_name = None
for var in env_vars:
env_name = env.name
if env_name.lower() == 'staging': #added for hmpps-visit-allocation-api as it has staging environment
env_name = 'stage'
elif env_name.lower() == 'production':
env_name = 'prod'
elif env_name.lower() == 'development':
env_name = 'dev'
elif env_name.lower() == 'preprod':
env_name = 'preprod'
if var.name == 'KUBE_NAMESPACE':
if circleci_context_k8s_namespace is None:
circleci_context_k8s_namespace = var.value
result["circleci_context_k8s_namespace"] = var.value
# adding list based on enum values in SC for environment type field
circleci_context_k8s_namespaces.append({
"env_name": env.name,
"env_type": env.name,
"env_name": env_name,
"env_type": env_name,
"namespace": var.value
})
result["circleci_context_k8s_namespaces"] = circleci_context_k8s_namespaces
Expand Down

0 comments on commit be5326c

Please sign in to comment.