Skip to content

Commit 9389ba2

Browse files
authored
Merge pull request #371 from lowell80/modinput-preserve-app
Modinput preserve 'app' context
2 parents c8fe42c + 0f65cd7 commit 9389ba2

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

examples/github_forks/bin/github_forks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ def stream_events(self, inputs, ew):
130130
owner = input_item["owner"]
131131
repo_name = input_item["repo_name"]
132132

133+
# Hint: API auth required?, get a secret from passwords.conf
134+
# self.service.namespace["app"] = input_item["__app"]
135+
# api_token = self.service.storage_passwords["github_api_token"].clear_password
136+
133137
# Get the fork count from the Github API
134138
jsondata = _get_github_repos(owner, repo_name)
135139
fork_count = jsondata["forks_count"]

splunklib/modularinput/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,14 @@ def parse_parameters(param_node):
6464
def parse_xml_data(parent_node, child_node_tag):
6565
data = {}
6666
for child in parent_node:
67+
child_name = child.get("name")
6768
if child.tag == child_node_tag:
6869
if child_node_tag == "stanza":
69-
data[child.get("name")] = {}
70+
data[child_name] = {
71+
"__app": child.get("app", None)
72+
}
7073
for param in child:
71-
data[child.get("name")][param.get("name")] = parse_parameters(param)
74+
data[child_name][param.get("name")] = parse_parameters(param)
7275
elif "item" == parent_node.tag:
73-
data[child.get("name")] = parse_parameters(child)
76+
data[child_name] = parse_parameters(child)
7477
return data
52 Bytes
Binary file not shown.
Binary file not shown.

tests/modularinput/test_input_definition.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ def test_parse_inputdef_with_two_inputs(self):
4848
"session_key": "123102983109283019283"
4949
}
5050
expectedDefinition.inputs["foobar://aaa"] = {
51+
"__app": "search",
5152
"param1": "value1",
5253
"param2": "value2",
5354
"disabled": "0",
5455
"index": "default"
5556
}
5657
expectedDefinition.inputs["foobar://bbb"] = {
58+
"__app": "my_app",
5759
"param1": "value11",
5860
"param2": "value22",
5961
"disabled": "0",

0 commit comments

Comments
 (0)