Skip to content

Commit

Permalink
Add a way to override the identity (#12)
Browse files Browse the repository at this point in the history
* Add a way to override the identity

Co-authored-by: msm <msm@cert.pl>
Co-authored-by: Paweł Srokosz <pawel.srokosz@cert.pl>
  • Loading branch information
3 people authored Apr 28, 2021
1 parent 13984a3 commit 826374f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion karton/config_extractor/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.0"
__version__ = "1.1.0"
11 changes: 10 additions & 1 deletion karton/config_extractor/config_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tempfile
import zipfile
from collections import defaultdict, namedtuple
from typing import DefaultDict, Dict, List
from typing import DefaultDict, Dict, List, Optional

from karton.core import Config, Karton, Resource, Task
from karton.core.resource import ResourceBase
Expand Down Expand Up @@ -83,6 +83,10 @@ def args_parser(cls):
default=[],
nargs="+",
)
parser.add_argument(
"--identity",
help="Override the default Karton identity",
)
return parser

@classmethod
Expand All @@ -98,6 +102,7 @@ def main(cls):
config = Config(args.config_file)
service = ConfigExtractor(
config,
identity=args.identity,
modules=args.modules,
result_tags=args.tag,
result_attributes=dict(attributes),
Expand All @@ -107,6 +112,7 @@ def main(cls):
def __init__(
self,
config: Config,
identity: Optional[str],
modules: str,
result_tags: List[str],
result_attributes: Dict[str, List[str]],
Expand All @@ -115,11 +121,14 @@ def __init__(
Create instance of the ConfigExtractor.
:param config: Karton configuration object
:param identity: Override the default Karton identity.
:param modules: Path to a directory with malduck modules.
:param result_tags: Tags to be applied to all produced configs.
:param result_attributes: Attributes to be applied to all produced configs.
"""
super().__init__(config)
if identity is not None:
self.identity = identity
self.modules = ExtractorModules(modules)
self.result_tags = result_tags
self.result_attributes = result_attributes
Expand Down

0 comments on commit 826374f

Please # to comment.