Skip to content

Commit

Permalink
Add configs to leappdb
Browse files Browse the repository at this point in the history
  • Loading branch information
dkubek committed Oct 8, 2024
1 parent 40aeb99 commit fc94ee8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
3 changes: 1 addition & 2 deletions leapp/actors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# Python 2.6 through 3.2
from collections import Sequence

from leapp.actors.config import Config, retrieve_config
from leapp.compat import string_types
from leapp.dialogs import Dialog
from leapp.exceptions import (MissingActorAttributeError, RequestStopAfterPhase, StopActorExecution,
Expand Down Expand Up @@ -517,7 +516,7 @@ def get_actor_metadata(actor):
_get_attribute(actor, 'dialogs', _is_dialog_tuple, required=False, default_value=()),
_get_attribute(actor, 'description', _is_type(string_types), required=False,
default_value=actor.__doc__ or 'There has been no description provided for this actor.'),
_get_attribute(actor, 'config_schemas', _is_config_sequence, required=False, default_value=()),
_get_attribute(actor, 'config_schemas', _is_config_sequence, required=False, default_value=()),
_get_attribute(actor, 'apis', _is_api_tuple, required=False, default_value=())
])

Expand Down
14 changes: 14 additions & 0 deletions leapp/actors/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ def to_dict(cls):
# representation[cls.section][cls.name] = cls.type_.get_default()

return representation

@classmethod
def serialize(cls):
"""
:return: Serialized information for the config
"""
return {
'class_name': cls.__name__,
'section': cls.section,
'name': cls.name,
'type': cls.type_.serialize(),
'description': cls.description,
'default': cls.default,
}
# pylint: enable=deprecated-decorator


Expand Down
2 changes: 1 addition & 1 deletion leapp/models/fields/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def to_builtin(self, source, name, target):

def serialize(self):
"""
:return: Serialized form of the workflow
:return: Serialized form of the field
"""
return {
'nullable': self._nullable,
Expand Down
4 changes: 3 additions & 1 deletion leapp/utils/audit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,12 @@ def store_actor_metadata(actor_definition, phase):
'consumes': sorted(model.__name__ for model in _metadata.get('consumes', ())),
'produces': sorted(model.__name__ for model in _metadata.get('produces', ())),
'tags': sorted(tag.__name__ for tag in _metadata.get('tags', ())),
'config_schemas': [field.serialize() for field in _metadata.get('config_schemas', ())],
})
_metadata['phase'] = phase

actor_metadata_fields = ('class_name', 'name', 'description', 'phase', 'tags', 'consumes', 'produces', 'path')
actor_metadata_fields = ('class_name', 'name', 'description', 'phase',
'tags', 'consumes', 'produces', 'config_schemas', 'path')
metadata = json.dumps({field: _metadata[field] for field in actor_metadata_fields}, sort_keys=True)
metadata_hash_id = hashlib.sha256(metadata.encode('utf-8')).hexdigest()

Expand Down

0 comments on commit fc94ee8

Please sign in to comment.