Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Fixed lint issues
  • Loading branch information
markphillips100 committed Jun 14, 2025
commit 3620ed06e4b900e1ade3759dcaf3e051cefb2b4f
12 changes: 0 additions & 12 deletions gitopsconfig.yaml

This file was deleted.

10 changes: 5 additions & 5 deletions src/configuration/gitops_config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
class GitOpsConfig:
def __init__(self,
name,
git_repository_type,
cicd_orchestrator_type,
gitops_operator_type,
gitops_app_url,
name,
git_repository_type,
cicd_orchestrator_type,
gitops_operator_type,
gitops_app_url,
azdo_gitops_repo_name=None,
azdo_pr_repo_name=None,
azdo_org_url=None,
Expand Down
8 changes: 1 addition & 7 deletions src/configuration/gitops_config_operator.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import kopf
import logging
from kubernetes import config as k8s_config
from threading import Thread
from configuration.gitops_config import GitOpsConfig
from typing import Callable, Optional, List
from configuration.gitops_connector_manager import GitOpsConnectorManager

class GitOpsConfigOperator:
Expand Down Expand Up @@ -61,10 +59,6 @@ def parse_config(self, spec, name):
def get_configuration(self, name):
"""Get the configuration object by name."""
return self.configurations.get(name)

# def get_gitops_connector(self, name):
# """Get the gitops_connector object by name."""
# return self.connector_manager.connectors.get(name)

def stop_all(self):
self.connector_manager.stop_all()
self.connector_manager.stop_all()
5 changes: 3 additions & 2 deletions src/configuration/gitops_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
PR_CLEANUP_INTERVAL = 1 * 30
DISABLE_POLLING_PR_TASK = False


# Instance is shared across threads.
class GitopsConnector:

Expand All @@ -29,7 +30,7 @@ def __init__(self, gitops_config: GitOpsConfig):

self.status_thread = None
self.status_thread_running = False

self.cleanup_task = Timeloop()
self.cleanup_task_running = False

Expand All @@ -47,7 +48,7 @@ def pr_polling_thread_worker():

def is_supported_message(self, payload):
return self._gitops_operator.is_supported_message(payload)

def start_background_work(self):
self._start_status_thread()
self._start_cleanup_task()
Expand Down
1 change: 1 addition & 0 deletions src/configuration/gitops_connector_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from configuration.gitops_connector import GitopsConnector
from configuration.gitops_config import GitOpsConfig


class GitOpsConnectorManager:
"""Manages configurations and the lifecycle of GitOpsConnector instances."""
def __init__(self):
Expand Down
10 changes: 4 additions & 6 deletions src/gitops_event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import logging
import kopf
from kubernetes import client, config
from kubernetes.client.rest import ApiException
import atexit
import time
import utils
Expand Down Expand Up @@ -42,11 +41,11 @@
else:
logging.debug('Detected no ENV configuration data. Running in multiple instance configuration mode via gitopsconfig resources.')
try:
cluster_domain=utils.getenv('CLUSTER_DOMAIN')
cluster_domain = utils.getenv('CLUSTER_DOMAIN')
logging.debug(f"cluster domain: '{cluster_domain}'")
config.load_incluster_config() # In-cluster Kubernetes config
api_instance = client.CustomObjectsApi()
instances = api_instance.list_cluster_custom_object(cluster_domain, "v1", "gitopsconfigs")
instances = api_instance.list_cluster_custom_object(cluster_domain, "v1", "gitopsconfigs")
for instance in instances.get("items"):
config_name = instance.get("metadata").get("name")
config_namespace = instance.get("metadata").get("namespace")
Expand Down Expand Up @@ -76,8 +75,6 @@ def run_kopf_operator():
kopf_thread = Thread(target=run_kopf_operator)
kopf_thread.start()



@application.route("/gitopsphase", methods=['POST'])
def gitopsphase():
# Use per process timer to stash the time we got the request
Expand All @@ -99,7 +96,7 @@ def gitopsphase():
logging.debug(f'GitOps phase: {payload}')

gitops_connector = connector_manager.get_supported_gitops_connector(payload)
if gitops_connector != None:
if gitops_connector is not None:
gitops_connector.process_gitops_phase(payload, req_time)

return f'GitOps phase: {payload}', 200
Expand All @@ -108,6 +105,7 @@ def gitopsphase():
def interrupt():
connector_manager.stop_all()


atexit.register(interrupt)


Expand Down