Skip to content

Commit

Permalink
feature: 插件支持默认版本标记
Browse files Browse the repository at this point in the history
  • Loading branch information
normal-wls committed Dec 7, 2023
1 parent 1335400 commit e3a2952
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
11 changes: 10 additions & 1 deletion runtime/bamboo-pipeline/pipeline/component_framework/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def __new__(cls, name, bases, attrs):
if not getattr(new_class, "version", None):
setattr(new_class, "version", LEGACY_PLUGINS_VERSION)

if not getattr(new_class, "is_default_version", None):
setattr(new_class, "is_default_version", False)

# category/group name
group_name = getattr(module, "__group_name__", new_class.__module__.split(".")[-1].title())
setattr(new_class, "group_name", group_name)
Expand All @@ -85,7 +88,13 @@ def __new__(cls, name, bases, attrs):
try:
print("update {} component model".format(new_class.code))
ComponentModel.objects.update_or_create(
code=new_class.code, version=new_class.version, defaults={"name": new_name, "status": __debug__}
code=new_class.code,
version=new_class.version,
defaults={
"name": new_name,
"status": __debug__,
"is_default_version": new_class.is_default_version,
},
)
except Exception as e:
if not isinstance(e, ProgrammingError):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.15 on 2023-12-07 13:27

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('component_framework', '0007_auto_20201112_2244'),
]

operations = [
migrations.AddField(
model_name='componentmodel',
name='is_default_version',
field=models.BooleanField(default=False, verbose_name='是否是默认版本'),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ComponentModel(models.Model):
code = models.CharField(_("组件编码"), max_length=255, db_index=True)
version = models.CharField(_("组件版本"), max_length=64, default=LEGACY_PLUGINS_VERSION, db_index=True)
name = models.CharField(_("组件名称"), max_length=255)
is_default_version = models.BooleanField(_("是否是默认版本"), default=False)
status = models.BooleanField(_("组件是否可用"), default=True)

objects = ComponentManager()
Expand Down

0 comments on commit e3a2952

Please sign in to comment.