-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: make configuration page as optional #1521
Changes from 27 commits
ad3bb71
1aba2ef
be85138
b0c1d45
1bb56cc
3995495
50c7a48
a4bc679
7264003
5a35c20
2b3a9e8
5c1b6fc
4898e85
9e51759
ffbe04c
4f2d411
b8bdccd
0533e39
fe160a6
1a41cd3
38da3f8
8e28fc9
1e5d55d
9ad2216
a90c117
2d7f0fc
edb5ac0
2066867
a8fa8aa
e610244
d166a13
b3ef144
a8ac385
5367851
6f5830a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,11 +88,14 @@ def expand(self) -> None: | |
self.expand_entities() | ||
|
||
def expand_tabs(self) -> None: | ||
for i, tab in enumerate(self._content["pages"]["configuration"]["tabs"]): | ||
self._content["pages"]["configuration"]["tabs"][i] = resolve_tab(tab) | ||
if self.has_configuration(): | ||
for i, tab in enumerate(self._content["pages"]["configuration"]["tabs"]): | ||
self._content["pages"]["configuration"]["tabs"][i] = resolve_tab(tab) | ||
|
||
def expand_entities(self) -> None: | ||
self._expand_entities(self._content["pages"]["configuration"]["tabs"]) | ||
self._expand_entities( | ||
self._content["pages"].get("configuration", {}).get("tabs") | ||
) | ||
self._expand_entities(self._content["pages"].get("inputs", {}).get("services")) | ||
self._expand_entities(self._content.get("alerts")) | ||
|
||
|
@@ -117,7 +120,9 @@ def inputs(self) -> List[Any]: | |
|
||
@property | ||
def tabs(self) -> List[Any]: | ||
return self._content["pages"]["configuration"]["tabs"] | ||
if "configuration" in self._content["pages"]: | ||
return self._content["pages"]["configuration"]["tabs"] | ||
return [] | ||
|
||
@property | ||
def dashboard(self) -> Dict[str, Any]: | ||
|
@@ -141,9 +146,10 @@ def logging_tab(self) -> Dict[str, Any]: | |
@property | ||
def configs(self) -> List[Any]: | ||
configs = [] | ||
for tab in self.tabs: | ||
if "table" in tab: | ||
configs.append(tab) | ||
if self.has_configuration(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made the changes. |
||
for tab in self.tabs: | ||
if "table" in tab: | ||
configs.append(tab) | ||
return configs | ||
|
||
@property | ||
|
@@ -207,6 +213,9 @@ def add_ucc_version(self, version: str) -> None: | |
def has_inputs(self) -> bool: | ||
return bool(self.inputs) | ||
|
||
def has_configuration(self) -> bool: | ||
return bool(self.tabs) | ||
sgoral-splunk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def has_alerts(self) -> bool: | ||
return bool(self.alerts) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ | |
|
||
from splunk_add_on_ucc_framework import dashboard as dashboard_lib | ||
from splunk_add_on_ucc_framework import global_config as global_config_lib | ||
from splunk_add_on_ucc_framework import data_ui_generator | ||
from splunk_add_on_ucc_framework.tabs import resolve_tab, Tab | ||
from splunk_add_on_ucc_framework.exceptions import GlobalConfigValidatorException | ||
|
||
|
@@ -54,10 +53,13 @@ def __init__(self, source_dir: str, global_config: global_config_lib.GlobalConfi | |
self._config = global_config.content | ||
|
||
@property | ||
def config_tabs(self) -> List[Tab]: | ||
return [ | ||
resolve_tab(tab) for tab in self._config["pages"]["configuration"]["tabs"] | ||
] | ||
def config_tabs(self) -> List[Any]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be a part of a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could resolve tabs if there are tabs in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. globalConfig class already has a similar There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, agree, please create a ticket for it and let's refactor it after this PR is merged. |
||
if self._global_config.has_configuration(): | ||
return [ | ||
resolve_tab(tab) | ||
for tab in self._config["pages"]["configuration"]["tabs"] | ||
] | ||
return [] | ||
|
||
def _validate_config_against_schema(self) -> None: | ||
""" | ||
|
@@ -249,10 +251,11 @@ def _validate_validators(self) -> None: | |
number and regex are supported. | ||
""" | ||
pages = self._config["pages"] | ||
for tab in self.config_tabs: | ||
entities = tab["entity"] | ||
for entity in entities: | ||
self._validate_entity_validators(entity) | ||
if pages.get("configuration"): | ||
for tab in self.config_tabs: | ||
entities = tab["entity"] | ||
for entity in entities: | ||
self._validate_entity_validators(entity) | ||
|
||
inputs = pages.get("inputs") | ||
if inputs is None: | ||
|
@@ -430,8 +433,8 @@ def _validate_duplicates(self) -> None: | |
not required in schema, so this checks if globalConfig has inputs | ||
""" | ||
pages = self._config["pages"] | ||
|
||
self._validate_tabs_duplicates(self.config_tabs) | ||
if pages.get("configuration"): | ||
self._validate_tabs_duplicates(self.config_tabs) | ||
|
||
inputs = pages.get("inputs") | ||
if inputs: | ||
|
@@ -700,9 +703,14 @@ def _validate_field_modifications(self) -> None: | |
) | ||
|
||
def _validate_meta_default_view(self) -> None: | ||
default_view = self._global_config.meta.get( | ||
"defaultView", data_ui_generator.DEFAULT_VIEW | ||
) | ||
default_view = self._global_config.meta.get("defaultView") | ||
if ( | ||
default_view == "configuration" | ||
and not self._global_config.has_configuration() | ||
): | ||
raise GlobalConfigValidatorException( | ||
'meta.defaultView == "configuration" but there is no configuration defined in globalConfig' | ||
) | ||
if default_view == "inputs" and not self._global_config.has_inputs(): | ||
raise GlobalConfigValidatorException( | ||
'meta.defaultView == "inputs" but there is no inputs defined in globalConfig' | ||
|
@@ -714,9 +722,10 @@ def _validate_meta_default_view(self) -> None: | |
|
||
def validate(self) -> None: | ||
self._validate_config_against_schema() | ||
self._validate_configuration_tab_table_has_name_field() | ||
if self._global_config.has_configuration(): | ||
self._validate_configuration_tab_table_has_name_field() | ||
self._validate_file_type_entity() | ||
sgoral-splunk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self._validate_custom_rest_handlers() | ||
self._validate_file_type_entity() | ||
self._validate_validators() | ||
self._validate_multilevel_menu() | ||
self._validate_duplicates() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering about this syntax, I found https://google.github.io/styleguide/pyguide.html#3195-nonetype
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the changes.