-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: usr: Added new Config source that allows to add arbitrary data d…
…irectly from the pipeline definition.
- Loading branch information
1 parent
ff0fd1d
commit 377ce73
Showing
5 changed files
with
136 additions
and
2 deletions.
There are no files selected for viewing
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,27 @@ | ||
[[sources]] | ||
type = "config" | ||
id = "config1" | ||
|
||
[sources.config.data] | ||
name = "this is a name" | ||
|
||
[sources.config.data.embedded] | ||
somefield = 123 | ||
|
||
[sources.config.data.embedded.morefields] | ||
comment = "This could go forever" | ||
|
||
|
||
[[sinks]] | ||
type = "print" | ||
id = "print" | ||
|
||
[[sinks]] | ||
type = "archive" | ||
id = "archive" | ||
|
||
[sinks.config] | ||
output = "data.json" | ||
override = true | ||
create_parents = true | ||
pretty = true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2017-2018 KuraLabs S.R.L | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
""" | ||
Config | ||
====== | ||
This sources let the user indicate static data to describe current pipeline. | ||
**Data collected:** | ||
*Anything the user entered on the configuration* | ||
**Dependencies:** | ||
.. code-block:: sh | ||
pip3 install flowbber[config] | ||
**Usage:** | ||
.. code-block:: toml | ||
[[sources]] | ||
type = "config" | ||
id = "..." | ||
[sources.config.data] | ||
anydata = "...." | ||
.. code-block:: json | ||
{ | ||
"sources": [ | ||
{ | ||
"type": "config", | ||
"id": "...", | ||
"config": { | ||
"data": { | ||
"anydata": "...." | ||
} | ||
} | ||
} | ||
] | ||
} | ||
data | ||
---- | ||
Free off schema data. | ||
- **Default**: ``False`` | ||
- **Optional**: ``False`` | ||
- **Schema**: | ||
.. code-block:: python3 | ||
{ | ||
'type': 'dict' | ||
} | ||
- **Secret**: ``False`` | ||
""" # noqa | ||
|
||
from copy import deepcopy | ||
|
||
from flowbber.components import Source | ||
|
||
|
||
class ConfigSource(Source): | ||
|
||
def declare_config(self, config): | ||
config.add_option( | ||
'data', | ||
schema={ | ||
'type': 'dict', | ||
'empty': False, | ||
}, | ||
) | ||
|
||
def collect(self): | ||
return deepcopy(self.config.data.value) | ||
|
||
|
||
__all__ = ['ConfigSource'] |
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