Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup #2267

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 0 additions & 16 deletions galaxy_ng/app/api/v1/viewsets/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,6 @@ def get_task(self, request, id=None):
'COMPLETED': 'SUCCESS'
}

# generate a message for the response
# FIXME(cutwater): Begin of the code that does nothing
msg = ''
if state == 'SUCCESS':
msg = 'role imported successfully'
elif state == 'RUNNING':
msg = 'running'

if this_task.error and this_task.error.get('traceback'):
msg = (
this_task.error['description']
+ '\n'
+ this_task.error['traceback']
)
# FIXME(cutwater): End of the code that does nothing

task_messages = []

# get messages from the model if this was a role import
Expand Down
1 change: 0 additions & 1 deletion galaxy_ng/app/management/commands/populate-role-tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import django_guid
from django.core.management.base import BaseCommand

# from galaxy_ng.app.api.v1.tasks import legacy_sync_from_upstream
from galaxy_ng.app.api.v1.models import LegacyRole, LegacyRoleTag


Expand Down
2 changes: 1 addition & 1 deletion galaxy_ng/app/management/commands/set-repo-keyring.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def handle(self, *args, **options):
if not options["yes"]:
confirm = input(
f"This will set keyring to {keyring_path} for "
f"{repository} repository, " "Proceed? (Y/n)"
f"{repository} repository, Proceed? (Y/n)"
).lower()
while True:
if confirm not in ("y", "n", "yes", "no"):
Expand Down
15 changes: 0 additions & 15 deletions galaxy_ng/app/metrics_collection/automation_analytics/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,6 @@ def signing_services(since, full_path, **kwargs):
return export_to_csv(full_path, "signing_services", query)


# @register(
# "collection_imports",
# "1.0",
# format="csv",
# description="Data on ansible_collectionimport",
# )
# def collection_imports(since, full_path, until, **kwargs):
# # currently no rows in the table, so no objects to base a query off
# source_query = """COPY (
# SELECT * FROM ansible_collectionimport
# ) TO STDOUT WITH CSV HEADER
# """
# return _simple_csv(full_path, "ansible_collectionimport", source_query)
#

@register(
"collection_download_logs",
"1.0",
Expand Down
7 changes: 0 additions & 7 deletions galaxy_ng/app/migrations/0038_namespace_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ def add_pulp_ansible_namespace_metadata_objects(apps, schema_editor):
AnsibleNamespace = apps.get_model('ansible', 'AnsibleNamespace')
Namespace = apps.get_model('galaxy', 'Namespace')

# ContentType = apps.get_model("contenttypes", "ContentType")
# GroupRole = apps.get_model("core", "GroupRole")
# old_ns_type = ContentType.objects.get(app_label="galaxy", model="namespace")
# new_ns_type = ContentType.objects.get(app_label="ansible", model="ansiblenamespace")


for old_ns in Namespace.objects.all():
new_ns = AnsibleNamespace.objects.create(name=old_ns.name)
links = {l.name: l.url for l in old_ns.links.all()}
Expand Down Expand Up @@ -97,7 +91,6 @@ def add_namespace_metadata_to_published_repository(apps, schema_editor):
RepositoryContent = apps.get_model('core', 'RepositoryContent')
RepositoryVersion = apps.get_model('core', 'RepositoryVersion')
RepositoryVersionContentDetails = apps.get_model('core', 'RepositoryVersionContentDetails')
RepositoryVersionContentDetails = apps.get_model('core', 'RepositoryVersionContentDetails')

repo = AnsibleDistribution.objects.get(base_path="published").repository
repo_v = RepositoryVersion.objects.filter(repository=repo).order_by("-number").first()
Expand Down
2 changes: 1 addition & 1 deletion galaxy_ng/app/migrations/_dab_rbac.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def create_permissions_as_operation(apps, schema_editor):
for app_label in {'ansible', 'container', 'core', 'galaxy'}:
create_dab_permissions(global_apps.get_app_config(app_label), apps=apps)

print(f'FINISHED CREATING PERMISSIONS')
print('FINISHED CREATING PERMISSIONS')


def split_pulp_roles(apps, schema_editor):
Expand Down
4 changes: 0 additions & 4 deletions galaxy_ng/app/models/collectionimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ class CollectionImport(LifecycleModel):
Relations:
namespace: Reference to a namespace.
"""
# task_id = models.UUIDField(primary_key=True)
task_id = models.OneToOneField(PulpCollectionImport,
primary_key=True,
on_delete=models.CASCADE,
db_column='task_id',
related_name='galaxy_import')
# pulp_task = models.ForeignKey(Task, on_delete=models.CASCADE, default=task_id)

created_at = models.DateTimeField()

namespace = models.ForeignKey(Namespace, on_delete=models.CASCADE)
name = models.CharField(max_length=64, editable=False)
version = models.CharField(max_length=32, editable=False)
Expand Down
2 changes: 0 additions & 2 deletions galaxy_ng/app/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@
from .registry_sync import launch_container_remote_sync, sync_all_repos_in_registry # noqa: F401
from .signing import call_sign_and_move_task, call_sign_task # noqa: F401
from .namespaces import dispatch_create_pulp_namespace_metadata # noqa: F401

# from .synchronizing import synchronize # noqa
1 change: 0 additions & 1 deletion galaxy_ng/app/utils/galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ def upstream_role_iterator(
role_upstream_url = _baseurl + f'/api/v1/roles/{remote_id}/'
logger.info(f'fetch {role_upstream_url}')

# role_page = requests.get(role_upstream_url)
role_page = safe_fetch(role_upstream_url)
if role_page.status_code == 404:
continue
Expand Down
6 changes: 3 additions & 3 deletions galaxy_ng/app/utils/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ def get_tag_commit_date(git_url, tag, checkout_path=None):
def get_tag_commit_hash(git_url, tag, checkout_path=None):
if checkout_path is None:
checkout_path = tempfile.mkdtemp()
pid = subprocess.run(f'git clone {git_url} {checkout_path}', shell=True)
pid = subprocess.run(
subprocess.run(f'git clone {git_url} {checkout_path}', shell=True)
proc = subprocess.run(
"git log -1 --format='%H'",
shell=True,
cwd=checkout_path,
stdout=subprocess.PIPE
)
commit_hash = pid.stdout.decode('utf-8').strip()
commit_hash = proc.stdout.decode('utf-8').strip()
return commit_hash
12 changes: 6 additions & 6 deletions galaxy_ng/openapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ class GalaxySchemaGenerator(PulpSchemaGenerator):

def convert_endpoint_path_params(self, path, view, schema):
"""Bypass variable-ization of paths if not a pulp route"""
if hasattr(self, '_input_request'):
if (
self._input_request.path.startswith(settings.GALAXY_API_PATH_PREFIX)
and not self._input_request.path.startswith(settings.API_ROOT)
):
return path
if (
hasattr(self, '_input_request')
and self._input_request.path.startswith(settings.GALAXY_API_PATH_PREFIX)
and not self._input_request.path.startswith(settings.API_ROOT)
):
return path
return super().convert_endpoint_path_params(path, view, schema)

def get_schema(self, request=None, public=False):
Expand Down
24 changes: 1 addition & 23 deletions galaxy_ng/social/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
from django.db import transaction
from social_core.backends.github import GithubOAuth2

# from galaxy_ng.app.models.auth import Group, User
from galaxy_ng.app.models import Namespace
from galaxy_ng.app.api.v1.models import LegacyNamespace
from galaxy_ng.app.utils import rbac
# from galaxy_ng.app.utils import namespaces as ns_utils

from galaxy_importer.constants import NAME_REGEXP

Expand Down Expand Up @@ -42,7 +40,6 @@ def get_session_state(self):
def do_auth(self, access_token, *args, **kwargs):
"""Finish the auth process once the access_token was retrieved"""

# userdata = id, login, access_token
data = self.get_github_user(access_token)

# extract the login now to prevent mutation
Expand Down Expand Up @@ -213,17 +210,6 @@ def transform_namespace_name(self, name):
"""Convert namespace name to valid v3 name."""
return name.replace('-', '_').lower()

'''
def _ensure_group(self, namespace_name, user):
"""Create a group in the form of <namespace>:<namespace_name>"""
with transaction.atomic():
group, created = \
Group.objects.get_or_create_identity('namespace', namespace_name)
if created:
rbac.add_user_to_group(user, group)
return group, created
'''

def _ensure_namespace(self, namespace_name, user):
"""Create an auto v3 namespace for the account"""

Expand All @@ -239,17 +225,9 @@ def _ensure_namespace(self, namespace_name, user):
def _ensure_legacynamespace(self, login, v3_namespace):
"""Create an auto legacynamespace for the account"""

'''
# userdata = id, login, access_token
user = User.objects.filter(username=login).first()
'''

# make the namespace
with transaction.atomic():
legacy_namespace, created = \
LegacyNamespace.objects.get_or_create(
name=login
)
legacy_namespace, created = LegacyNamespace.objects.get_or_create(name=login)

# bind the v3 namespace
if created or not legacy_namespace.namespace:
Expand Down
Loading