-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #1086
- Loading branch information
Showing
14 changed files
with
130 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add a `gpgkey` field to the ansible repository to ease verification of collection signatures. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Removed ``keyring`` attribute from repositories in favor of ``gpgkey``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
pulp_ansible/app/migrations/0042_ansiblerepository_gpgkey.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Generated by Django 3.2.13 on 2022-07-01 10:19 | ||
|
||
import gnupg | ||
import tempfile | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def migrate_keyring_to_gpgkey_on_repository_up(apps, schema_editor): | ||
AnsibleRepository = apps.get_model('ansible', 'AnsibleRepository') | ||
changed_repos = [] | ||
with tempfile.TemporaryDirectory() as gnupghome: | ||
for repository in AnsibleRepository.objects.filter(keyring__isnull=False): | ||
try: | ||
gpg = gnupg.GPG(gnupghome=gnupghome, keyring=repository.keyring) | ||
repository.gpgkey = gpg.export_keys("*") | ||
changed_repos.append(repository) | ||
except Exception as e: | ||
# Make the migration resilient | ||
print(f"Repository {repository.pk} failed to migrate it's keyring. {e}") | ||
pass | ||
|
||
if len(changed_repos) >= 1024: | ||
AnsibleRepository.objects.bulk_update(changed_repos, ['gpgkey']) | ||
changed_repos.clear() | ||
# Flush the rest | ||
AnsibleRepository.objects.bulk_update(changed_repos, ['gpgkey']) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('ansible', '0041_alter_collectionversion_collection'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='ansiblerepository', | ||
name='gpgkey', | ||
field=models.TextField(null=True), | ||
), | ||
migrations.RunPython( | ||
code=migrate_keyring_to_gpgkey_on_repository_up, | ||
reverse_code=migrations.RunPython.noop, | ||
elidable=True, | ||
), | ||
migrations.RemoveField( | ||
model_name='ansiblerepository', | ||
name='keyring', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters