Skip to content

Commit 5bee96d

Browse files
chore: merge develop into main (#1843)
2 parents 61d29e4 + 342ebb4 commit 5bee96d

File tree

53 files changed

+1300
-1388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1300
-1388
lines changed

.github/workflows/ta-tests.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,14 @@ jobs:
150150
- name: Run ucc-gen build in Target Add-on
151151
working-directory: TA
152152
run: |
153-
poetry run ucc-gen build
153+
poetry run ucc-gen build > build_output.log 2>&1
154+
if tail -n 1 build_output.log | grep -q "^INFO: File creation summary: created: "; then
155+
echo "✓ Build completed successfully with expected output"
156+
cat build_output.log
157+
else
158+
echo "✗ Build did not complete with expected output"
159+
echo "Last line of output should start with 'INFO: File creation summary: created: '"
160+
echo "Full output:"
161+
cat build_output.log
162+
exit 1
163+
fi

splunk_add_on_ucc_framework/generators/conf_files/create_account_conf.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
from typing import Tuple, List, Dict
16+
from typing import Tuple, List, Dict, Optional
1717

1818
from splunk_add_on_ucc_framework.generators.file_generator import FileGenerator
1919

@@ -36,24 +36,25 @@ def _set_attributes(self) -> None:
3636
if account["name"] == "oauth":
3737
continue
3838
content = self._gc_schema._get_oauth_enitities(account["entity"])
39-
fields, special_fields = self._gc_schema._parse_fields(content)
39+
fields, _ = self._gc_schema._parse_fields(content)
4040
self.account_fields.append(
4141
("<name>", [f"{f._name} = " for f in fields])
4242
)
4343

44-
def generate(self) -> Dict[str, str]:
44+
def generate(self) -> Optional[List[Dict[str, str]]]:
4545
if not self.account_fields:
46-
return {}
46+
return None
4747

4848
file_path = self.get_file_output_path(["README", self.conf_spec_file])
4949
self.set_template_and_render(
5050
template_file_path=["README"], file_name="account_conf_spec.template"
5151
)
5252

5353
rendered_content = self._template.render(account_stanzas=self.account_fields)
54-
self.writer(
55-
file_name=self.conf_spec_file,
56-
file_path=file_path,
57-
content=rendered_content,
58-
)
59-
return {self.conf_spec_file: file_path}
54+
return [
55+
{
56+
"file_name": self.conf_spec_file,
57+
"file_path": file_path,
58+
"content": rendered_content,
59+
}
60+
]

splunk_add_on_ucc_framework/generators/conf_files/create_alert_actions_conf.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import json
1717
import shutil
1818
from os import path
19-
from typing import Any, Dict
19+
from typing import Any, Dict, List, Optional
2020

2121
from splunk_add_on_ucc_framework.commands.modular_alert_builder import normalize
2222
from splunk_add_on_ucc_framework.generators.file_generator import FileGenerator
@@ -127,41 +127,43 @@ def _set_attributes(self) -> None:
127127
value = f"{str(k).strip()} = {str(v).strip()}"
128128
self.alerts[alert_name].append(value)
129129

130-
def generate(self) -> Dict[str, str]:
131-
conf_files: Dict[str, str] = {}
132-
conf_files.update(self.generate_conf())
133-
conf_files.update(self.generate_conf_spec())
134-
return conf_files
130+
def generate(self) -> Optional[List[Dict[str, str]]]:
131+
conf_files: List[Dict[str, str]] = []
132+
conf = self.generate_conf()
133+
conf_spec = self.generate_conf_spec()
134+
if conf is not None:
135+
conf_files.append(conf)
136+
if conf_spec is not None:
137+
conf_files.append(conf_spec)
138+
return None if conf_files == [] else conf_files
135139

136-
def generate_conf(self) -> Dict[str, str]:
140+
def generate_conf(self) -> Optional[Dict[str, str]]:
137141
if not self.alerts:
138-
return {}
142+
return None
139143

140144
file_path = self.get_file_output_path(["default", self.conf_file])
141145
self.set_template_and_render(
142146
template_file_path=["conf_files"], file_name="alert_actions_conf.template"
143147
)
144148
rendered_content = self._template.render(alerts=self.alerts)
145-
self.writer(
146-
file_name=self.conf_file,
147-
file_path=file_path,
148-
content=rendered_content,
149-
)
150-
return {self.conf_file: file_path}
149+
return {
150+
"file_name": self.conf_file,
151+
"file_path": file_path,
152+
"content": rendered_content,
153+
}
151154

152-
def generate_conf_spec(self) -> Dict[str, str]:
155+
def generate_conf_spec(self) -> Optional[Dict[str, str]]:
153156
if not self.alerts_spec:
154-
return {}
157+
return None
155158

156159
file_path = self.get_file_output_path(["README", self.conf_spec_file])
157160
self.set_template_and_render(
158161
template_file_path=["README"],
159162
file_name="alert_actions_conf_spec.template",
160163
)
161164
rendered_content = self._template.render(alerts=self.alerts_spec)
162-
self.writer(
163-
file_name=self.conf_spec_file,
164-
file_path=file_path,
165-
content=rendered_content,
166-
)
167-
return {self.conf_spec_file: file_path}
165+
return {
166+
"file_name": self.conf_spec_file,
167+
"file_path": file_path,
168+
"content": rendered_content,
169+
}

splunk_add_on_ucc_framework/generators/conf_files/create_app_conf.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
# limitations under the License.
1515
#
1616
from time import time
17-
from typing import Dict
18-
from splunk_add_on_ucc_framework.global_config import GlobalConfig
17+
from typing import Dict, List
18+
1919
from splunk_add_on_ucc_framework.generators.file_generator import FileGenerator
20+
from splunk_add_on_ucc_framework.global_config import GlobalConfig
2021
from splunk_add_on_ucc_framework.utils import get_app_manifest
2122

2223

@@ -57,7 +58,7 @@ def _set_attributes(self) -> None:
5758
).lower()
5859
self.build = str(int(time()))
5960

60-
def generate(self) -> Dict[str, str]:
61+
def generate(self) -> List[Dict[str, str]]:
6162
file_path = self.get_file_output_path(["default", self.conf_file])
6263
self.set_template_and_render(
6364
template_file_path=["conf_files"], file_name="app_conf.template"
@@ -75,10 +76,11 @@ def generate(self) -> Dict[str, str]:
7576
label=self.title,
7677
is_visible=self.is_visible,
7778
)
78-
self.writer(
79-
file_name=self.conf_file,
80-
file_path=file_path,
81-
content=rendered_content,
82-
merge_mode="item_overwrite",
83-
)
84-
return {self.conf_file: file_path}
79+
return [
80+
{
81+
"file_name": self.conf_file,
82+
"file_path": file_path,
83+
"content": rendered_content,
84+
"merge_mode": "item_overwrite",
85+
}
86+
]

splunk_add_on_ucc_framework/generators/conf_files/create_commands_conf.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
from typing import Dict
16+
from typing import Dict, List, Optional
1717

1818
from splunk_add_on_ucc_framework.generators.file_generator import FileGenerator
1919

@@ -30,9 +30,9 @@ def _set_attributes(self) -> None:
3030
for command in self._global_config.custom_search_commands:
3131
self.command_names.append(command["commandName"])
3232

33-
def generate(self) -> Dict[str, str]:
33+
def generate(self) -> Optional[List[Dict[str, str]]]:
3434
if not self._global_config.has_custom_search_commands():
35-
return {}
35+
return None
3636

3737
file_path = self.get_file_output_path(["default", self.conf_file])
3838
self.set_template_and_render(
@@ -41,9 +41,10 @@ def generate(self) -> Dict[str, str]:
4141
rendered_content = self._template.render(
4242
command_names=self.command_names,
4343
)
44-
self.writer(
45-
file_name=self.conf_file,
46-
file_path=file_path,
47-
content=rendered_content,
48-
)
49-
return {self.conf_file: file_path}
44+
return [
45+
{
46+
"file_name": self.conf_file,
47+
"file_path": file_path,
48+
"content": rendered_content,
49+
}
50+
]

splunk_add_on_ucc_framework/generators/conf_files/create_eventtypes_conf.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
from typing import Any, Dict, List
16+
from typing import Any, Dict, List, Optional
1717

1818
from splunk_add_on_ucc_framework.commands.modular_alert_builder import normalize
1919
from splunk_add_on_ucc_framework.generators.file_generator import FileGenerator
@@ -35,18 +35,19 @@ def _set_attributes(self) -> None:
3535
schema_content = envs["schema.content"]
3636
self.alert_settings = schema_content["modular_alerts"]
3737

38-
def generate(self) -> Dict[str, str]:
38+
def generate(self) -> Optional[List[Dict[str, str]]]:
3939
if not self.alert_settings:
40-
return {}
40+
return None
4141

4242
file_path = self.get_file_output_path(["default", self.conf_file])
4343
self.set_template_and_render(
4444
template_file_path=["conf_files"], file_name="eventtypes_conf.template"
4545
)
4646
rendered_content = self._template.render(mod_alerts=self.alert_settings)
47-
self.writer(
48-
file_name=self.conf_file,
49-
file_path=file_path,
50-
content=rendered_content,
51-
)
52-
return {self.conf_file: file_path}
47+
return [
48+
{
49+
"file_name": self.conf_file,
50+
"file_path": file_path,
51+
"content": rendered_content,
52+
}
53+
]

splunk_add_on_ucc_framework/generators/conf_files/create_inputs_conf.py

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515
#
1616
from collections import defaultdict
17-
from typing import Any, Dict, List
17+
from typing import Any, Dict, List, Optional
1818

1919
from splunk_add_on_ucc_framework.generators.file_generator import FileGenerator
2020

@@ -99,15 +99,19 @@ def _set_attributes(self) -> None:
9999
prop = f"{field_name} = {field_value}".rstrip()
100100
spec_properties.append(prop)
101101

102-
def generate(self) -> Dict[str, str]:
103-
conf_files: Dict[str, str] = {}
104-
conf_files.update(self.generate_conf())
105-
conf_files.update(self.generate_conf_spec())
106-
return conf_files
107-
108-
def generate_conf(self) -> Dict[str, str]:
102+
def generate(self) -> Optional[List[Dict[str, str]]]:
103+
conf_files: List[Dict[str, str]] = []
104+
conf = self.generate_conf()
105+
conf_spec = self.generate_conf_spec()
106+
if conf is not None:
107+
conf_files.append(conf)
108+
if conf_spec is not None:
109+
conf_files.extend(conf_spec)
110+
return None if conf_files == [] else conf_files
111+
112+
def generate_conf(self) -> Optional[Dict[str, str]]:
109113
if not self.inputs_conf_names:
110-
return {}
114+
return None
111115

112116
file_path = self.get_file_output_path(["default", self.conf_file])
113117
self.set_template_and_render(
@@ -118,16 +122,15 @@ def generate_conf(self) -> Dict[str, str]:
118122
input_names=self.inputs_conf_names,
119123
default_values=self.inputs_conf_params,
120124
)
121-
self.writer(
122-
file_name=self.conf_file,
123-
file_path=file_path,
124-
content=rendered_content,
125-
)
126-
return {self.conf_file: file_path}
125+
return {
126+
"file_name": self.conf_file,
127+
"file_path": file_path,
128+
"content": rendered_content,
129+
}
127130

128-
def _generate_spec_inputs(self) -> Dict[str, str]:
131+
def _generate_spec_inputs(self) -> Optional[Dict[str, str]]:
129132
if not self.inputs_conf_spec:
130-
return {}
133+
return None
131134

132135
spec_file = self._spec_file_name("inputs")
133136
file_path = self.get_file_output_path(["README", spec_file])
@@ -140,12 +143,11 @@ def _generate_spec_inputs(self) -> Dict[str, str]:
140143
input_names=self.inputs_conf_names,
141144
input_stanzas=self.inputs_conf_spec,
142145
)
143-
self.writer(
144-
file_name=spec_file,
145-
file_path=file_path,
146-
content=rendered_content,
147-
)
148-
return {spec_file: file_path}
146+
return {
147+
"file_name": spec_file,
148+
"file_path": file_path,
149+
"content": rendered_content,
150+
}
149151

150152
def _generate_spec_other(self, name: str, parameters: List[str]) -> Dict[str, str]:
151153
spec_file = self._spec_file_name(name)
@@ -154,20 +156,21 @@ def _generate_spec_other(self, name: str, parameters: List[str]) -> Dict[str, st
154156
content = ["[<name>]"]
155157
content.extend(parameters)
156158

157-
self.writer(
158-
file_name=spec_file,
159-
file_path=file_path,
160-
content="\n".join(content),
161-
)
162-
return {spec_file: file_path}
159+
return {
160+
"file_name": spec_file,
161+
"file_path": file_path,
162+
"content": "\n".join(content),
163+
}
163164

164-
def generate_conf_spec(self) -> Dict[str, str]:
165-
files = self._generate_spec_inputs()
165+
def generate_conf_spec(self) -> Optional[List[Dict[str, str]]]:
166+
files: List[Dict[str, str]] = []
167+
spec_input = self._generate_spec_inputs()
168+
if spec_input is not None:
169+
files.append(spec_input)
166170

167171
for name, params in self.other_spec_files.items():
168-
files.update(self._generate_spec_other(name, params))
172+
files.append(self._generate_spec_other(name, params))
169173

170174
if not files:
171-
return {}
172-
175+
return None
173176
return files

splunk_add_on_ucc_framework/generators/conf_files/create_restmap_conf.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
from typing import Dict, Union, List
16+
from typing import Dict, Union, List, Optional
1717

1818
from splunk_add_on_ucc_framework.commands.rest_builder.endpoint.base import (
1919
RestEndpointBuilder,
@@ -43,9 +43,9 @@ def _set_attributes(self) -> None:
4343

4444
self.endpoint_names = ", ".join(sorted([ep.name for ep in self.endpoints]))
4545

46-
def generate(self) -> Dict[str, str]:
46+
def generate(self) -> Optional[List[Dict[str, str]]]:
4747
if not self.endpoints:
48-
return {}
48+
return None
4949

5050
file_path = self.get_file_output_path(["default", self.conf_file])
5151
self.set_template_and_render(
@@ -56,9 +56,10 @@ def generate(self) -> Dict[str, str]:
5656
endpoint_names=self.endpoint_names,
5757
namespace=self.namespace,
5858
)
59-
self.writer(
60-
file_name=self.conf_file,
61-
file_path=file_path,
62-
content=rendered_content,
63-
)
64-
return {self.conf_file: file_path}
59+
return [
60+
{
61+
"file_name": self.conf_file,
62+
"file_path": file_path,
63+
"content": rendered_content,
64+
}
65+
]

0 commit comments

Comments
 (0)