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

Add models for ContainerRegistry Sync Config #695

Merged
merged 2 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CHANGES/432.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add models for container registry sync config
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by Django 2.2.19 on 2021-03-18 00:37

from django.db import migrations, models
import django.db.models.deletion
import django_lifecycle.mixins
import galaxy_ng.app.access_control.mixins


class Migration(migrations.Migration):

dependencies = [
('core', '0061_call_handle_artifact_checksums_command'),
('container', '0018_containerdistribution_description'),
('galaxy', '0015_containerdistroreadme'),
]

operations = [
migrations.CreateModel(
name='ContainerRegistryRemote',
fields=[
('remote_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='galaxy_containerregistryremote', serialize=False, to='core.Remote')),
],
options={
'default_related_name': '%(app_label)s_%(model_name)s',
},
bases=('core.remote', django_lifecycle.mixins.LifecycleModelMixin, galaxy_ng.app.access_control.mixins.GroupModelPermissionsMixin),
),
migrations.CreateModel(
name='ContainerSyncTask',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('repository', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='container.ContainerRepository')),
('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Task')),
],
options={
'ordering': ['-task__finished_at'],
},
),
migrations.CreateModel(
name='ContainerRegistryRepos',
fields=[
('repository_remote', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='container.ContainerRemote')),
('registry', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='galaxy.ContainerRegistryRemote')),
],
),
]
38 changes: 37 additions & 1 deletion galaxy_ng/app/models/container.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db import models

from pulpcore.plugin import models as pulp_models
from pulp_container.app import models as container_models
from django_lifecycle import LifecycleModelMixin

Expand All @@ -23,3 +23,39 @@ class ContainerDistroReadme(models.Model):
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True, null=True)
text = models.TextField(blank=True)


class ContainerRegistryRemote(
pulp_models.Remote,
LifecycleModelMixin,
rochacbruno marked this conversation as resolved.
Show resolved Hide resolved
mixins.GroupModelPermissionsMixin,
):

class Meta:
default_related_name = "%(app_label)s_%(model_name)s"


class ContainerRegistryRepos(models.Model):
registry = models.ForeignKey(
ContainerRegistryRemote,
on_delete=models.CASCADE,
)
repository_remote = models.OneToOneField(
container_models.ContainerRemote,
on_delete=models.CASCADE,
primary_key=True,
)


class ContainerSyncTask(models.Model):
repository = models.ForeignKey(
container_models.ContainerRepository,
on_delete=models.CASCADE,
)
task = models.ForeignKey(
pulp_models.Task,
on_delete=models.CASCADE,
)

class Meta:
ordering = ['-task__finished_at']