Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, config_path=None):
configuration = ConfigurationCore(config_path)
self.url = configuration.get("gitlab|url", environ.get("GITLAB_URL"))
self.token = configuration.get("gitlab|token", environ.get("GITLAB_TOKEN"))
self.ssl_verify = configuration.get("gitlab|ssl_verify", True)
self.session = requests.Session()
retries = Retry(total=3,
backoff_factor=0.25,
status_forcelist=[500, 502, 503, 504])
self.session.mount('http://', HTTPAdapter(max_retries=retries))
self.session.mount('https://', HTTPAdapter(max_retries=retries))
self.session.verify = self.ssl_verify
try:
version = self._make_requests_to_api("version")
import logging
from gitlabform.configuration.core import ConfigurationCore, KeyNotFoundException
logger = logging.getLogger(__name__)
class ConfigurationProjectsAndGroups(ConfigurationCore):
def get_projects(self) -> list:
"""
:return: sorted list of projects with configs
"""
try:
return sorted(self.get("project_settings", {}).keys())
except KeyNotFoundException:
raise ConfigNotFoundException
def get_effective_config_for_project(self, group_and_project) -> dict:
"""
:param group_and_project: "project_group/project_name"
:return: merged configuration for this project, from common, group/subgroup and project level.
If project belongs to a subgroup, like "x/y/z", then it gets config from both group "x" as well
as subgroup "y".