mirror of
https://github.com/ansible/galaxy.git
synced 2026-02-05 09:45:11 +01:00
Revert "Added support for Github Enterprise instances (#1972)"
This reverts commit 7ebc88222a.
This commit is contained in:
committed by
GitHub
parent
1b5a47e3cf
commit
eeae11802a
1
AUTHORS
1
AUTHORS
@@ -11,7 +11,6 @@ Christopher Chase <cchase@redhat.com>
|
||||
David Newswanger <dnewswan@redhat.com>
|
||||
David Zager <dzager@redhat.com>
|
||||
Dostonbek <toirovd@berea.edu>
|
||||
Egor Margineanu <egor.margineanu@gmail.com>
|
||||
Ivan <iremizov@gmail.com>
|
||||
Ivan Remizov <iremizov@gmail.com>
|
||||
James Cammarata <jimi@sngx.net>
|
||||
|
||||
@@ -24,7 +24,6 @@ from github.GithubException import GithubException
|
||||
|
||||
from allauth.socialaccount.models import SocialToken
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from galaxy.common.github import get_github_api_url
|
||||
from galaxy.main.models import Provider
|
||||
|
||||
|
||||
@@ -59,8 +58,7 @@ class GithubAPI(object):
|
||||
"User does not have a GitHub OAuth token"
|
||||
)
|
||||
try:
|
||||
client = Github(base_url=get_github_api_url(),
|
||||
login_or_token=gh_token.token)
|
||||
client = Github(gh_token.token)
|
||||
except GithubException as exc:
|
||||
raise Exception("Failed to connect to the GitHub API {0} - {1}"
|
||||
.format(exc.data, exc.status))
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
from django.urls import reverse
|
||||
from rest_framework import serializers as drf_serializers
|
||||
|
||||
from galaxy.common.github import get_github_web_url
|
||||
from galaxy.main.models import Repository
|
||||
from . import serializers
|
||||
|
||||
@@ -165,8 +164,11 @@ class RepositorySerializer(serializers.BaseSerializer):
|
||||
}
|
||||
|
||||
def get_external_url(self, instance):
|
||||
server = ''
|
||||
if instance.provider_namespace.provider.name.lower() == 'github':
|
||||
server = 'https://github.com'
|
||||
return '{0}/{1}/{2}'.format(
|
||||
get_github_web_url(),
|
||||
server,
|
||||
instance.provider_namespace.name,
|
||||
instance.original_name)
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ class BaseRoleSerializer(BaseSerializer):
|
||||
REPOSITORY_MOVED_FIELDS = (
|
||||
'github_user',
|
||||
'github_repo',
|
||||
'github_server',
|
||||
('github_branch', 'import_branch'),
|
||||
'stargazers_count',
|
||||
'forks_count',
|
||||
|
||||
@@ -2,6 +2,7 @@ import logging
|
||||
import requests
|
||||
|
||||
from allauth.socialaccount.models import SocialAccount
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
|
||||
|
||||
@@ -13,7 +14,6 @@ from rest_framework.authentication import SessionAuthentication
|
||||
|
||||
from galaxy.api.views import base_views
|
||||
from galaxy.api.serializers import TokenSerializer
|
||||
from galaxy.common.github import get_github_api_url
|
||||
|
||||
__all__ = [
|
||||
'TokenView',
|
||||
@@ -76,7 +76,7 @@ class TokenView(base_views.APIView):
|
||||
raise ValidationError({'detail': "Invalid request."})
|
||||
|
||||
try:
|
||||
git_status = requests.get(get_github_api_url())
|
||||
git_status = requests.get(settings.GITHUB_SERVER)
|
||||
git_status.raise_for_status()
|
||||
except Exception:
|
||||
raise ValidationError({
|
||||
@@ -86,7 +86,7 @@ class TokenView(base_views.APIView):
|
||||
try:
|
||||
header = dict(Authorization='token ' + github_token)
|
||||
gh_user = requests.get(
|
||||
get_github_api_url() + '/user', headers=header
|
||||
settings.GITHUB_SERVER + '/user', headers=header
|
||||
)
|
||||
gh_user.raise_for_status()
|
||||
gh_user = gh_user.json()
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
# (c) 2012-2018, Ansible by Red Hat
|
||||
#
|
||||
# This file is part of Ansible Galaxy
|
||||
#
|
||||
# Ansible Galaxy is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the Apache License as published by
|
||||
# the Apache Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible Galaxy is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# Apache License for more details.
|
||||
#
|
||||
# You should have received a copy of the Apache License
|
||||
# along with Galaxy. If not, see <http://www.apache.org/licenses/>.
|
||||
|
||||
from allauth.socialaccount import app_settings
|
||||
from allauth.socialaccount.providers.github.provider import GitHubProvider
|
||||
|
||||
provider_id = GitHubProvider.id
|
||||
settings = app_settings.PROVIDERS.get(provider_id, {})
|
||||
|
||||
|
||||
def get_github_web_url():
|
||||
if 'GITHUB_URL' in settings:
|
||||
return settings.get('GITHUB_URL').rstrip('/')
|
||||
else:
|
||||
return 'https://github.com'
|
||||
|
||||
|
||||
def get_github_api_url():
|
||||
if 'GITHUB_URL' in settings:
|
||||
return '{0}/api/v3'.format(get_github_web_url())
|
||||
else:
|
||||
return 'https://api.github.com'
|
||||
@@ -6,7 +6,6 @@ from django.db import models
|
||||
from django.urls import reverse
|
||||
|
||||
from galaxy import constants
|
||||
from galaxy.common.github import get_github_web_url
|
||||
from galaxy.main import fields
|
||||
|
||||
from .base import BaseModel
|
||||
@@ -107,8 +106,7 @@ class Repository(BaseModel):
|
||||
|
||||
@property
|
||||
def clone_url(self):
|
||||
return "{server}/{user}/{repo}.git".format(
|
||||
server=get_github_web_url(),
|
||||
return "https://github.com/{user}/{repo}.git".format(
|
||||
user=self.provider_namespace.name,
|
||||
repo=self.original_name
|
||||
)
|
||||
@@ -121,10 +119,6 @@ class Repository(BaseModel):
|
||||
def github_repo(self):
|
||||
return self.original_name
|
||||
|
||||
@property
|
||||
def github_server(self):
|
||||
return get_github_web_url()
|
||||
|
||||
@property
|
||||
def content_counts(self):
|
||||
return Content.objects \
|
||||
|
||||
@@ -27,7 +27,6 @@ from django.utils import timezone
|
||||
from allauth.socialaccount import models as auth_models
|
||||
|
||||
from galaxy import constants
|
||||
from galaxy.common.github import get_github_api_url
|
||||
from galaxy.importer import repository as i_repo
|
||||
from galaxy.importer import exceptions as i_exc
|
||||
from galaxy.main import models
|
||||
@@ -91,15 +90,12 @@ def _import_repository(import_task, logger):
|
||||
logger.info(' ')
|
||||
|
||||
token = _get_social_token(import_task)
|
||||
gh_api = github.Github(base_url=get_github_api_url(),
|
||||
login_or_token=token)
|
||||
gh_api = github.Github(token)
|
||||
gh_repo = gh_api.get_repo(repo_full_name)
|
||||
|
||||
try:
|
||||
repo_info = i_repo.import_repository(
|
||||
gh_repo.clone_url.replace("https://", "https://{token}@".format(
|
||||
token=token
|
||||
)),
|
||||
repository.clone_url,
|
||||
branch=import_task.import_branch,
|
||||
temp_dir=settings.CONTENT_DOWNLOAD_DIR,
|
||||
logger=logger)
|
||||
@@ -319,8 +315,8 @@ def _update_repo_info(repository, gh_repo, commit_info, repo_description):
|
||||
repository.commit = commit_info.sha
|
||||
repository.commit_message = commit_info.message[:255]
|
||||
repository.commit_url = \
|
||||
'{0}/repos/{1}/git/commits/{2}'.format(
|
||||
get_github_api_url(), gh_repo.full_name, commit_info.sha)
|
||||
'https://api.github.com/repos/{0}/git/commits/{1}'.format(
|
||||
gh_repo.full_name, commit_info.sha)
|
||||
repository.commit_created = commit_info.committer_date
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user