Skip to content

Commit

Permalink
Start figuring out where to add configuration
Browse files Browse the repository at this point in the history
Need to add configuration code into the LEAPP framework
  • Loading branch information
abadger committed Jul 2, 2024
1 parent 03c651c commit 0e78dd4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions leapp/actors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ 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, 'configuration', _is_type(string_types), required=False,
default_value=actor.__doc__ or 'There has been no description provided for this actor.')
_get_attribute(actor, 'apis', _is_api_tuple, required=False, default_value=())
])

Expand Down
13 changes: 10 additions & 3 deletions leapp/models/fields/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
import copy
import datetime
import json
try:
# Python 3
from collections.abc import Sequence
except ImportError:
# Python 2.7
from collections import Sequence

import six

Expand Down Expand Up @@ -185,16 +191,17 @@ def _validate_builtin_value(self, value, name):
self._validate(value=value, name=name, expected_type=self._builtin_type)

def _validate(self, value, name, expected_type):
if not isinstance(expected_type, tuple):
if not isinstance(expected_type, Sequence):
expected_type = (expected_type,)

if value is None and self._nullable:
return
if not any(isinstance(value, t) for t in expected_type):

if not isinstance(value, expected_type):
names = ', '.join(['{}'.format(t.__name__) for t in expected_type])
raise ModelViolationError("Fields {} is of type: {} expected: {}".format(name, type(value).__name__,
names))


class Boolean(BuiltinField):
"""
Boolean field
Expand Down
7 changes: 7 additions & 0 deletions leapp/repository/actor_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,13 @@ def description(self):
"""
return self.discover()['description']

@property
def configuration(self):
"""
:return: Actor configurations
"""
return self.discover()['configuration']

@contextlib.contextmanager
def injected_context(self):
"""
Expand Down

0 comments on commit 0e78dd4

Please sign in to comment.