Skip to content

Commit

Permalink
feat: release v5.29.0 (#840)
Browse files Browse the repository at this point in the history
* feat: deprecated placeholder prop (#835)

* feat: deprecated placeholder prop

* test: validate deprecation message being used

* feat: allows to configure app.conf->package->check_for_updates field (#836)

* feat: allows to configure app.conf->package->check_for_updates field

This change addresses a recent change in the AppInspect API which
checks for explicitly defined check_for_updates field in app.conf.
This change allows to configure it using `meta` in globalConfig file.

* test: adjust smoke tests

* fix: ucc-gen init command accepts optional REST root paremeter (#838)

* feat: update UCC UI to v1.31.0 (#839)

Related PR: splunk/addonfactory-ucc-base-ui#429
  • Loading branch information
artemrys authored Sep 22, 2023
1 parent c08dc01 commit c874f86
Show file tree
Hide file tree
Showing 36 changed files with 455 additions and 100 deletions.
6 changes: 5 additions & 1 deletion docs/advanced/oauth_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ Auth can be used inside the entity tag. Use `type: "oauth"` in the entity list a
- `field`: For now this user must keep it as it is for mandatory fields as mentioned above.
- `help` : This can be changed if user wants to change the help text displayed below field.
- `encrypted` : This should be true if user wants that particular field encrypted else no need to have this parameter.
- `placeholder`: The placeholder for the field.
- `required`: To specify whether the field is required or not. The default value is true.
- `options`:
- `placeholder`: The placeholder for the field.

> [!WARNING]
> [Placeholder](https://splunkui.splunkeng.com/Packages/react-ui/Text?section=develop) attribute is deprecated and will be removed in one of the following versions. Instead, we recommend using "help" attribute.
### Usage

Expand Down
2 changes: 1 addition & 1 deletion docs/custom_ui_extensions/custom_menu.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Custom Menu can be created when there is more than one input present on the inputs page.

> This feature is deprecated (will be removed in the next major version) as [`Multilevel Menu`](https://splunk.github.io/addonfactory-ucc-generator/tabs/#multi-level-menu) is now ready to use if more than one input is available.
> This feature is deprecated (will be removed in the next major version) as [`Multilevel Menu`](../inputs/multilevel_menu) is now ready to use if more than one input is available.
In addition to the multiple inputs, we can use this menu to create a custom component at the top right corner of the Input page.

Expand Down
3 changes: 2 additions & 1 deletion docs/entity/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ Multiselect allows the user to select multiple options at once.
| denyList | string | It filters options that don't match the regex based on the name attribute when received via API call using `endpointUrl` and `referenceName`. | - |
| labelField | string | TBD | - |
| [dependencies](../advanced/dependent_dropdown.md) | array | It is used to update options via an API call when the value of any field in the dependencies list is updated. | - |
| [autoCompleteFields](#autoCompleteFields) | array | It is used to add options in the Single select or Multiple select component. | - |

Example usage below:

Expand Down Expand Up @@ -368,7 +369,7 @@ It supports files that can be opened in text mode or with a text editor. Files w

It only sends file content to the server by reading it using the [readAsArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsArrayBuffer) method of the FileReader class and then decoding it into **UTF-8** format using the [decode](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/decode) method of the TextDecoder class.

File content can be validated using in-built validators like [string](../validators/#string) and [regex](../validators/#regex), and a custom validator can also be implemented using a [custom hook](../../custom_ui_extensions/custom_hook) and [saveValidator](../advances/../advanced/save_validator).
File content can be validated using in-built validators like [string](../validators/#string) and [regex](../validators/#regex), and a custom validator can also be implemented using a [custom hook](../../custom_ui_extensions/custom_hook) and [saveValidator](../advanced/save_validator).

This feature allows you to upload a single file.

Expand Down
8 changes: 6 additions & 2 deletions docs/entity/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@ title: Entity
| field<span class="required-asterisk">*</span> | string | To define a particular entity field. | - |
| label<span class="required-asterisk">*</span> | string | It represents a caption for a field in a user interface. | - |
| [type](./components)<span class="required-asterisk">*</span> | string | To specify the type of entity to be rendered in inputs or configuration form. | - |
| help | string | Help text gives context about a field’s input, such as how the input will be used. It is displayed directly under an input field. | - |
| help | string | Help text gives context about a fields input, such as how the input will be used. It is displayed directly below an input field. | - |
| tooltip | string | Displays a tooltip beside the label. | - |
| defaultValue | string, number or boolean | The initial input value. | - |
| [options](#common-options) | object | To specify an additional attribute for a particular type of entity, such as `items` for a radio bar. | - |
| required | boolean | To specify whether the field is required or not. | false |
| encrypted | boolean | To encrypt that particular field. | false |
| [validators](./validators) | array | It is used to validate the values of fields using various validators. | - |

> [!WARNING]
> [Placeholder](https://splunkui.splunkeng.com/Packages/react-ui/Text?section=develop) attribute is deprecated and will be removed in the next major version. Instead, we recommend to use "help" attribute.
## Common Options

| Property | Type | Description | Default Value |
| ------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
| placeholder | string | The grey text is shown when the input is empty.<br> This option will be removed when Splunk UI deprecates it in their next major release. | - |
| placeholder | string | `Deprecated` The grey text is shown when the input is empty. | - |
| display | boolean | Whether show or hide the field. | true |
| disableonEdit | boolean | When the form is in edit mode, the field becomes uneditable. | false |
| enable | boolean | The enable property sets whether a field is enabled, or not. | true |
4 changes: 2 additions & 2 deletions docs/inputs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ Developers are required to add services in the global config file to create a ne
### Services Properties

| Property | Type | Description |
| ----------------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|-------------------------------------------------------------| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name<span class="required-asterisk">*</span> | string | To define the particular service name. |
| title<span class="required-asterisk">*</span> | string | To show the title of the service. |
| subTitle | string | To show the subtitle (or additional information) of the service. |
| [entity](../entity)<span class="required-asterisk">*</span> | array | A list of fields and their properties. |
| [groups](../advanced/groups) | array | It is used to divide forms into distinct sections, each comprising relevant fields. |
| [groups](../advanced/groups_feature) | array | It is used to divide forms into distinct sections, each comprising relevant fields. |
| style | string | By specifying this property in the global config file, the forms can either be opened as a new page or in a dialog. <br>Supported values are "page" or "dialog". <br> Default value is **dialog**. |
| options | object | This property allows you to enable the [saveValidator](../advanced/save_validator) feature. |
| hook | object | It is used to add custom behaviour to forms. Visit the [Custom Hook](../custom_ui_extensions/custom_hook) page to learn more. |
Expand Down
1 change: 1 addition & 0 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ It takes the following parameters:

* `--addon-name` - [required] add-on name. Consult with
[official naming convention guide](https://dev.splunk.com/enterprise/docs/releaseapps/splunkbase/namingguidelines/).
* `--addon-rest-root` - [optional] add-on REST root, defaults to `--addon-name` if not provided.
* `--addon-display-name` - [required] add-on "official" name.
* `--addon-input-name` - [required] name of the generated input.
* `--addon-version` - [optional] version of the generated add-on, `0.0.1` by default.
Expand Down
2 changes: 1 addition & 1 deletion get-ucc-ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
wget https://github.com/splunk/addonfactory-ucc-base-ui/releases/download/v1.29.2/splunk-ucc-ui.tgz
wget https://github.com/splunk/addonfactory-ucc-base-ui/releases/download/v1.31.0/splunk-ucc-ui.tgz
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

[pytest]
norecursedirs = .git .venv venv build tests/deps node_modules package tests/smoke/output tests/testdata/expected_addons/expected_output_global_config_everything tests/data/output output tests/smoke/Splunk_TA_Dynatrace
addopts = -v --tb=long
addopts = -v --tb=long
4 changes: 4 additions & 0 deletions splunk_add_on_ucc_framework/app_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def update(
app_manifest: app_manifest_lib.AppManifest,
conf_file_names: Sequence[str],
is_visible: bool,
check_for_updates: bool = True,
) -> None:
if "launcher" not in self._app_conf:
self._app_conf.add_section("launcher")
Expand All @@ -60,6 +61,9 @@ def update(
self._app_conf["install"]["is_configured"] = "false"
self._app_conf["install"]["state"] = "enabled"
self._app_conf["package"]["id"] = app_manifest.get_addon_name()
self._app_conf["package"]["check_for_updates"] = (
"true" if check_for_updates else "false"
)
self._app_conf["ui"]["label"] = app_manifest.get_title()
self._app_conf["ui"]["is_visible"] = "true" if is_visible else "false"
for conf_file_name in conf_file_names:
Expand Down
12 changes: 11 additions & 1 deletion splunk_add_on_ucc_framework/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,17 @@ def generate(
)
app_conf.read(output_app_conf_path)
should_be_visible = True if global_config else False
app_conf.update(addon_version, app_manifest, conf_file_names, should_be_visible)
if global_config and global_config.meta.get("checkForUpdates") is False:
check_for_updates = False
else:
check_for_updates = True
app_conf.update(
addon_version,
app_manifest,
conf_file_names,
should_be_visible,
check_for_updates,
)
app_conf.write(output_app_conf_path)
logger.info(f"Updated {app_conf_lib.APP_CONF_FILE_NAME} file in the output folder")

Expand Down
64 changes: 64 additions & 0 deletions splunk_add_on_ucc_framework/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,83 @@
import logging
import os
import sys
import re
from typing import Optional

from cookiecutter import exceptions, main

logger = logging.getLogger("ucc_gen")


ADDON_NAME_RE_STR = r'^[^<>:"/|?*]+$'
ADDON_NAME_RE = re.compile(ADDON_NAME_RE_STR)
ADDON_REST_ROOT_RE_STR = r"^\w+$"
ADDON_REST_ROOT_RE = re.compile(ADDON_REST_ROOT_RE_STR)
ADDON_INPUT_NAME_RE_STR = r"^[0-9a-zA-Z][\w-]*$"
ADDON_INPUT_NAME_RE = re.compile(ADDON_INPUT_NAME_RE_STR)


def _is_valid(pattern: re.Pattern, string: str) -> bool:
result = pattern.search(string)
if result is None:
return False
return True


def _is_valid_addon_name(addon_name: str) -> bool:
return _is_valid(ADDON_NAME_RE, addon_name)


def _is_valid_rest_root_name(rest_root: str) -> bool:
return _is_valid(ADDON_REST_ROOT_RE, rest_root)


def _is_valid_input_name(input_name: str) -> bool:
if len(input_name) > 50:
return False
return _is_valid(ADDON_INPUT_NAME_RE, input_name)


def init(
addon_name: str,
addon_display_name: str,
addon_input_name: str,
addon_version: str,
addon_rest_root: Optional[str] = None,
overwrite: bool = False,
) -> str:
try:
if not _is_valid_addon_name(addon_name):
logger.error(
f"Add-on name provided is not valid, it should follow '{ADDON_NAME_RE_STR}' regex."
)
sys.exit(1)

if addon_rest_root is None:
if _is_valid_rest_root_name(addon_name):
logger.info(
"Parameter `--addon-rest-root` is not provided, using `--addon-name` as a REST root."
)
addon_rest_root = addon_name
else:
logger.error(
f"Can not use add-on name provided as an add-on REST root. "
f"It should follow '{ADDON_REST_ROOT_RE_STR}' regex. "
f"Please provide `--addon-rest-root` to specify add-on REST root."
)
sys.exit(1)
else:
if not _is_valid_rest_root_name(addon_rest_root):
logger.error(
f"Add-on REST root provided is not valid, it should follow '{ADDON_REST_ROOT_RE_STR}' regex."
)
sys.exit(1)
if not _is_valid_input_name(addon_input_name):
logger.error(
f"Add-on input name provided is not valid, "
f"it should follow '{ADDON_INPUT_NAME_RE_STR}' regex and be less than 50 characters."
)
sys.exit(1)
generated_addon_path = main.cookiecutter(
template=os.path.join(
os.path.dirname(__file__),
Expand All @@ -39,6 +102,7 @@ def init(
no_input=True,
extra_context={
"addon_name": addon_name,
"addon_rest_root": addon_rest_root,
"addon_display_name": addon_display_name,
"addon_input_name": addon_input_name,
"addon_version": addon_version,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"addon_name": "",
"addon_rest_root": "",
"addon_display_name": "",
"addon_input_name": "",
"addon_version": ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
},
"meta": {
"name": "{{cookiecutter.addon_name}}",
"restRoot": "{{cookiecutter.addon_name}}",
"restRoot": "{{cookiecutter.addon_rest_root}}",
"version": "{{cookiecutter.addon_version}}",
"displayName": "{{cookiecutter.addon_display_name}}",
"schemaVersion": "0.0.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get_account_api_key(session_key: str, account_name: str):
cfm = conf_manager.ConfManager(
session_key,
ADDON_NAME,
realm=f"__REST_CREDENTIAL__#{ADDON_NAME}#configs/conf-{{cookiecutter.addon_name}}_account",
realm=f"__REST_CREDENTIAL__#{ADDON_NAME}#configs/conf-{{cookiecutter.addon_rest_root}}_account",
)
account_conf_file = cfm.get_conf("{{cookiecutter.addon_name}}_account")
return account_conf_file.get(account_name).get("api_key")
Expand Down
Loading

0 comments on commit c874f86

Please sign in to comment.