-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bugfix: 修复节点快照某些值无法正确序列化的问题 * minor: any 模式下的回滚遵循token校验 * minor: any 模式增加token校验
- Loading branch information
1 parent
6efaf05
commit bdd6a09
Showing
5 changed files
with
94 additions
and
62 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
runtime/bamboo-pipeline/pipeline/contrib/rollback/fields.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,31 @@ | ||
# -*- coding: utf-8 -*- | ||
import codecs | ||
import json | ||
import pickle | ||
|
||
from django.db.models import TextField | ||
|
||
|
||
class SerializerField(TextField): | ||
""" | ||
特定的序列化类,用于兼容json和pickle两种序列化数据 | ||
""" | ||
|
||
def to_python(self, value): | ||
try: | ||
return json.loads(value) | ||
except Exception: | ||
return pickle.loads(codecs.decode(value.encode(), "base64")) | ||
|
||
def from_db_value(self, value, expression, connection, context=None): | ||
try: | ||
return json.loads(value) | ||
except Exception: | ||
return pickle.loads(codecs.decode(value.encode(), "base64")) | ||
|
||
def get_prep_value(self, value): | ||
try: | ||
return json.dumps(value) | ||
except TypeError: | ||
return codecs.encode(pickle.dumps(value), "base64").decode() | ||
pass |
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
29 changes: 29 additions & 0 deletions
29
runtime/bamboo-pipeline/pipeline/contrib/rollback/migrations/0002_auto_20231020_1234.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,29 @@ | ||
# Generated by Django 3.2.18 on 2023-10-20 12:34 | ||
|
||
import pipeline.contrib.rollback.fields | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("rollback", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="rollbacknodesnapshot", | ||
name="context_values", | ||
field=pipeline.contrib.rollback.fields.SerializerField(verbose_name="pipeline context values"), | ||
), | ||
migrations.AlterField( | ||
model_name="rollbacknodesnapshot", | ||
name="inputs", | ||
field=pipeline.contrib.rollback.fields.SerializerField(verbose_name="node inputs"), | ||
), | ||
migrations.AlterField( | ||
model_name="rollbacknodesnapshot", | ||
name="outputs", | ||
field=pipeline.contrib.rollback.fields.SerializerField(verbose_name="node outputs"), | ||
), | ||
] |
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