Skip to content

Commit 235a3fd

Browse files
committed
chore(dryccfile): migrate to dryccfile v2
1 parent b571c96 commit 235a3fd

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Generated by Django 4.2.15 on 2024-09-06 03:58
2+
3+
from django.db import migrations
4+
from api.models.release import Release
5+
6+
7+
def migration_dryccfile(apps, schema_editor):
8+
for release in Release.objects.all():
9+
build = release.build
10+
if not build or not build.dryccfile or "pipeline" in build.dryccfile:
11+
continue
12+
config, envs = {}, {}
13+
if release.config:
14+
for value in release.config.values:
15+
if "ptype" in value:
16+
if value["ptype"] not in envs:
17+
envs[value["ptype"]] = {}
18+
envs[value["ptype"]][value["name"]] = value["value"]
19+
elif "group" in value:
20+
if value["group"] not in envs:
21+
config[value["group"]] = {}
22+
config[value["group"]][value["name"]] = value["value"]
23+
pipeline = {}
24+
for key, value in build.dryccfile.get('deploy', {}).items():
25+
pipeline.update({
26+
"%s.yaml" % key: {
27+
"kind": "pipeline",
28+
"ptype": key,
29+
"env": envs.get(key, {}),
30+
"deploy": value,
31+
}
32+
})
33+
build.dryccfile = {"config": config, "pipeline": pipeline}
34+
build.save()
35+
36+
37+
class Migration(migrations.Migration):
38+
39+
dependencies = [
40+
('api', '0021_limitplan_runtime_class_name'),
41+
]
42+
43+
operations = [
44+
migrations.RunPython(migration_dryccfile),
45+
]

0 commit comments

Comments
 (0)