From 9ddbceaf1ab81129d7fab20c3286a8df6f5cf6b8 Mon Sep 17 00:00:00 2001 From: Robert Vojcik Date: Tue, 16 Jun 2020 16:35:16 +0200 Subject: [PATCH] introduce membership option to configuration file #2 --- config.yaml-example | 4 ++++ gitlab-project-export.py | 8 +++++++- lib/gitlab.py | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/config.yaml-example b/config.yaml-example index 1caf958..5253f08 100644 --- a/config.yaml-example +++ b/config.yaml-example @@ -12,6 +12,10 @@ gitlab: projects: - rvojcik/example-project - rvojcik/group/* + # Membership attribute used when searching for projects + # If you want to export all projects from private gitlab instance + # sse False here. In big shared instances or gitlab.com use True + membership: True # Wait Between Exports # How many seconds to wait between projects to export. # This is due rate-limiting in gitlab.com diff --git a/gitlab-project-export.py b/gitlab-project-export.py index 37a1a21..b4de12f 100755 --- a/gitlab-project-export.py +++ b/gitlab-project-export.py @@ -52,6 +52,12 @@ else: wait_between_exports = 0 + # Check if there is membership in config + if 'membership' in c.config["gitlab"]: + membership = c.config["gitlab"]["membership"] + else: + membership = True + # Init gitlab api object if args.debug: print("%s, token" % (gitlab_url)) @@ -61,7 +67,7 @@ export_projects = [] # Get All member projects from gitlab - projects = gitlab.project_list() + projects = gitlab.project_list(membership=str(membership)) if not projects: print("Unable to get projects for your account", file=sys.stderr) sys.exit(1) diff --git a/lib/gitlab.py b/lib/gitlab.py index 99be42a..5564d69 100644 --- a/lib/gitlab.py +++ b/lib/gitlab.py @@ -80,9 +80,9 @@ def __api_import_status(self, project_url): project_url + "/import", headers=self.headers) - def project_list(self, path_glob=""): + def project_list(self, path_glob="", membership="True"): ''' List projects based on glob path ''' - urlpath = '/projects?simple=True&membership=True&per_page=50' + urlpath = '/projects?simple=True&membership=%s&per_page=50' % (membership) page = 1 output = [] if not self.project_array: