def helper_resolve_visibility(labbook, info): # TODO: Future work will look up remote in LabBook data, allowing user to select remote. default_remote = labbook.client_config.config['git']['default_remote'] admin_service = None for remote in labbook.client_config.config['git']['remotes']: if default_remote == remote: admin_service = labbook.client_config.config['git']['remotes'][ remote]['admin_service'] break # Extract valid Bearer token if "HTTP_AUTHORIZATION" in info.context.headers.environ: token = parse_token( info.context.headers.environ["HTTP_AUTHORIZATION"]) else: raise ValueError( "Authorization header not provided. Must have a valid session to query for collaborators" ) # Get collaborators from remote service mgr = GitLabManager(default_remote, admin_service, token) try: owner = InventoryManager().query_owner(labbook) d = mgr.repo_details(namespace=owner, repository_name=labbook.name) assert 'visibility' in d.keys( ), 'Visibility is not in repo details response keys' return d.get('visibility') except ValueError: return "local"
def resolve_visibility(self, info): app_config = Configuration().config default_remote = app_config['git']['default_remote'] admin_service = None for remote in Configuration().config['git']['remotes']: if default_remote == remote: admin_service = app_config['git']['remotes'][remote]['admin_service'] break # Extract valid Bearer token if "HTTP_AUTHORIZATION" in info.context.headers.environ: token = parse_token(info.context.headers.environ["HTTP_AUTHORIZATION"]) else: raise ValueError("Authorization header not provided. Must have a valid session to query for collaborators") # Get collaborators from remote service mgr = GitLabManager(default_remote, admin_service, token) try: d = mgr.repo_details(namespace=self.owner, repository_name=self.name) return d.get('visibility') except ValueError: return "unknown"