Skip to content

Commit

Permalink
fed up with the requirements managemnt
Browse files Browse the repository at this point in the history
  • Loading branch information
jrybicki-jsc committed Dec 21, 2023
1 parent dcfaa4e commit 12cd4e8
Showing 1 changed file with 38 additions and 45 deletions.
83 changes: 38 additions & 45 deletions gitlab2ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,43 @@
from airflow.decorators import dag, task
from airflow.operators.python import PythonOperator
from airflow.models.param import Param
from decors import remove, setup
from utils import clean_up_vaultid
from decors import get_connection, remove, setup
from utils import walk_dir, clean_up_vaultid

try:
import gitlab
except ImportError:
print("Unable to import gitlab library")


def get_gitlab_client(url):
return gitlab.Gitlab(url)


def get_project(client, name):
fn = [pr for pr in client.projects.list(iterator=True) if pr.name == name]
if not fn:
print("No project for given name found")
return None

return client.projects.get(fn[0].id)


class GitFSC:
def __init__(self, client, **kwargs):
self.client = client

def list(self, path, get_info=True):
if not get_info:
return [
el["name"]
for el in self.client.repository_tree(path=path, get_all=True)
]
return [
{"path": el["path"], "isdir": el["type"] == "tree"}
for el in self.client.repository_tree(path=path, get_all=True)
]


CHNK_SIZE = 1024 * 1000

Expand All @@ -27,50 +62,8 @@
},
)
def git2ssh():
@task.virtualenv(
system_site_packages=True,
requirements=["python-gitlab==3.15.0"]
)
@task
def stream_vupload(connection_id, **kwargs):
from decors import get_connection
from utils import walk_dir

try:
import gitlab
print("Gitlab imported!")
except ImportError:
print("Unable to import gitlab library")


def get_gitlab_client(url):
return gitlab.Gitlab(url)


def get_project(client, name):
fn = [pr for pr in client.projects.list(iterator=True) if pr.name == name]
if not fn:
print("No project for given name found")
return None

return client.projects.get(fn[0].id)


class GitFSC:
def __init__(self, client, **kwargs):
self.client = client

def list(self, path, get_info=True):
if not get_info:
return [
el["name"]
for el in self.client.repository_tree(path=path, get_all=True)
]
return [
{"path": el["path"], "isdir": el["type"] == "tree"}
for el in self.client.repository_tree(path=path, get_all=True)
]


params = kwargs["params"]
target = params.get("target", "/tmp/")
url = params.get("gitlab_url")
Expand Down

0 comments on commit 12cd4e8

Please sign in to comment.