Skip to content

Commit cf43590

Browse files
committed
chore(controller): using django native JSONFiled
1 parent af13883 commit cf43590

9 files changed

Lines changed: 97 additions & 127 deletions

File tree

rootfs/api/migrations/0001_initial.py

Lines changed: 77 additions & 101 deletions
Large diffs are not rendered by default.

rootfs/api/models/app.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from django.conf import settings
1919
from django.db import models
2020
from rest_framework.exceptions import ValidationError, NotFound
21-
from jsonfield import JSONField
2221

2322
from api.models import get_session
2423
from api.models import UuidAuditedModel, AlreadyExists, DryccException, ServiceUnavailable
@@ -73,8 +72,10 @@ class App(UuidAuditedModel):
7372
id = models.SlugField(max_length=63, unique=True, null=True,
7473
validators=[validate_app_id,
7574
validate_reserved_names])
76-
structure = JSONField(default={}, blank=True, validators=[validate_app_structure])
77-
procfile_structure = JSONField(default={}, blank=True, validators=[validate_app_structure])
75+
structure = models.JSONField(
76+
default=dict, blank=True, validators=[validate_app_structure])
77+
procfile_structure = models.JSONField(
78+
default=dict, blank=True, validators=[validate_app_structure])
7879

7980
class Meta:
8081
verbose_name = 'Application'

rootfs/api/models/appsettings.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from django.db import models
44
from django.db import transaction
55
from django.contrib.postgres.fields import ArrayField
6-
from jsonfield import JSONField
76
from rest_framework.exceptions import NotFound
87

98
from api.utils import dict_diff
@@ -22,8 +21,8 @@ class AppSettings(UuidAuditedModel):
2221
# the default values is None to differentiate from user sending an empty allowlist
2322
# and user just updating other fields meaning the values needs to be copied from prev release
2423
allowlist = ArrayField(models.CharField(max_length=50), default=None)
25-
autoscale = JSONField(default={}, blank=True)
26-
label = JSONField(default={}, blank=True)
24+
autoscale = models.JSONField(default=dict, blank=True)
25+
label = models.JSONField(default=dict, blank=True)
2726

2827
class Meta:
2928
get_latest_by = 'created'

rootfs/api/models/build.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from django.conf import settings
22
from django.db import models
3-
from jsonfield import JSONField
43

54
from api.models import UuidAuditedModel
65
from api.exceptions import DryccException, Conflict
@@ -21,7 +20,7 @@ class Build(UuidAuditedModel):
2120

2221
# optional fields populated by builder
2322
sha = models.CharField(max_length=40, blank=True)
24-
procfile = JSONField(default={}, blank=True)
23+
procfile = models.JSONField(default=dict, blank=True)
2524
dockerfile = models.TextField(blank=True)
2625

2726
class Meta:

rootfs/api/models/config.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import logging
33
from django.conf import settings
44
from django.db import models
5-
from jsonfield import JSONField
65
from api.models.release import Release
76
from api.models import UuidAuditedModel
87
from api.utils import unit_to_bytes, unit_to_millicpu
@@ -20,15 +19,15 @@ class Config(UuidAuditedModel):
2019

2120
owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT)
2221
app = models.ForeignKey('App', on_delete=models.CASCADE)
23-
values = JSONField(default={}, blank=True)
24-
memory = JSONField(default={}, blank=True)
25-
lifecycle_post_start = JSONField(default={}, blank=True)
26-
lifecycle_pre_stop = JSONField(default={}, blank=True)
27-
cpu = JSONField(default={}, blank=True)
28-
tags = JSONField(default={}, blank=True)
29-
registry = JSONField(default={}, blank=True)
30-
healthcheck = JSONField(default={}, blank=True)
31-
termination_grace_period = JSONField(default={}, blank=True)
22+
values = models.JSONField(default=dict, blank=True)
23+
memory = models.JSONField(default=dict, blank=True)
24+
lifecycle_post_start = models.JSONField(default=dict, blank=True)
25+
lifecycle_pre_stop = models.JSONField(default=dict, blank=True)
26+
cpu = models.JSONField(default=dict, blank=True)
27+
tags = models.JSONField(default=dict, blank=True)
28+
registry = models.JSONField(default=dict, blank=True)
29+
healthcheck = models.JSONField(default=dict, blank=True)
30+
termination_grace_period = models.JSONField(default=dict, blank=True)
3231

3332
class Meta:
3433
get_latest_by = 'created'

rootfs/api/models/resource.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
from django.conf import settings
33
from django.db import models, transaction
4-
from jsonfield import JSONField
54
from api.exceptions import DryccException, AlreadyExists, ServiceUnavailable
65
from api.models import UuidAuditedModel, validate_label
76
from scheduler import KubeException
@@ -15,10 +14,10 @@ class Resource(UuidAuditedModel):
1514
app = models.ForeignKey('App', on_delete=models.CASCADE)
1615
name = models.CharField(max_length=63, validators=[validate_label])
1716
plan = models.CharField(max_length=128)
18-
data = JSONField(default={}, blank=True)
17+
data = models.JSONField(default=dict, blank=True)
1918
status = models.TextField(blank=True, null=True)
2019
binding = models.TextField(blank=True, null=True)
21-
options = JSONField(default={}, blank=True)
20+
options = models.JSONField(default=dict, blank=True)
2221

2322
class Meta:
2423
get_latest_by = 'created'

rootfs/api/models/volume.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
from django.db import models, transaction
33
from django.conf import settings
4-
from jsonfield import JSONField
54
from api.utils import unit_to_bytes
65
from api.exceptions import DryccException, ServiceUnavailable, AlreadyExists
76
from api.models import UuidAuditedModel, validate_label
@@ -16,7 +15,7 @@ class Volume(UuidAuditedModel):
1615
app = models.ForeignKey('App', on_delete=models.CASCADE)
1716
name = models.CharField(max_length=63, validators=[validate_label])
1817
size = models.CharField(max_length=128)
19-
path = JSONField(default={}, blank=True)
18+
path = models.JSONField(default=dict, blank=True)
2019

2120
class Meta:
2221
get_latest_by = 'created'

rootfs/api/settings/production.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@
104104
'corsheaders',
105105
'guardian',
106106
'gunicorn',
107-
'jsonfield',
108107
'rest_framework',
109108
'rest_framework.authtoken',
110109
'social_django',
@@ -420,7 +419,7 @@
420419
MINIO_PORT = os.environ.get('DRYCC_MINIO_SERVICE_PORT', 80)
421420
APP_STORAGE = os.environ.get('APP_STORAGE')
422421

423-
DRYCC_DATABASE_URL = os.environ.get('DRYCC_DATABASE_URL', 'postgres://:@:5432/drycc')
422+
DRYCC_DATABASE_URL = os.environ.get('DRYCC_DATABASE_URL', 'postgres://postgres:@:5432/drycc')
424423
DATABASES = {
425424
'default': dj_database_url.config(default=DRYCC_DATABASE_URL, conn_max_age=600)
426425
}

rootfs/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ docker==5.0.0
88
gunicorn==20.1.0
99
idna==3.2
1010
jmespath==0.10.0
11-
jsonfield==3.1.0
1211
jsonschema==3.2.0
1312
morph==0.1.4
1413
ndg-httpsclient==0.5.1

0 commit comments

Comments
 (0)