Skip to content

Commit

Permalink
Read yaml by configmgr (#4069)
Browse files Browse the repository at this point in the history
* Read yaml by configmgr

Signed-off-by: Martin Zeithaml <[email protected]>

* Changelog update

Signed-off-by: Martin Zeithaml <[email protected]>

* When not found, return empty string

Signed-off-by: Martin Zeithaml <[email protected]>

* Changelog update

Signed-off-by: Martin Zeithaml <[email protected]>

---------

Signed-off-by: Martin Zeithaml <[email protected]>
Co-authored-by: 1000TurquoisePogs <[email protected]>
  • Loading branch information
Martin-Zeithaml and 1000TurquoisePogs authored Nov 18, 2024
1 parent d275394 commit 30d2e0d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
All notable changes to the Zowe Installer will be documented in this file.

## `3.0.1`
- Bugfix: When `--log-dir` parameter for `zwe` command is a file, there might be an error "InternalError: stack overflow". [#40nn](https://github.com/zowe/zowe-install-packaging/pull/40nn)
- Enhancement: command `zwe install` does not require NodeJS [#4069](https://github.com/zowe/zowe-install-packaging/pull/4069)
- Enhancement: new javascript funtion `getStatvfs()` to obtain information about the file sysytem [#3994](https://github.com/zowe/zowe-install-packaging/pull/3994)
- Enhancement: command `zwe diagnose` in javascript only [#4061](https://github.com/zowe/zowe-install-packaging/pull/4061)
- Enhancement: schema validation update for `zowe.job.name` and `zowe.job.prefix` [#4060](https://github.com/zowe/zowe-install-packaging/pull/4060)
Expand Down
4 changes: 2 additions & 2 deletions bin/commands/install/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ ${ZWE_PRIVATE_DS_SZWEEXEC}|Zowe executable utilities library|dsntype(library) ds
if [ -n "${ZWE_CLI_PARAMETER_DATASET_PREFIX}" ]; then
prefix="${ZWE_CLI_PARAMETER_DATASET_PREFIX}"
else
require_zowe_yaml
require_zowe_yaml "skipnode"

# read prefix and validate
prefix=$(read_yaml "${ZWE_CLI_PARAMETER_CONFIG}" ".zowe.setup.dataset.prefix")
prefix=$(read_yaml_configmgr "${ZWE_CLI_PARAMETER_CONFIG}" ".zowe.setup.dataset.prefix")
if [ -z "${prefix}" ]; then
print_error_and_exit "Error ZWEL0157E: Zowe dataset prefix (zowe.setup.dataset.prefix) is not defined in Zowe YAML configuration file." "" 157
fi
Expand Down
6 changes: 3 additions & 3 deletions bin/libs/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ check_configmgr_enabled() {
}

require_zowe_yaml() {
# node is required to read yaml file
require_node

if [ -z "${1}" ]; then
require_node
fi
if [ -z "${ZWE_CLI_PARAMETER_CONFIG}" ]; then
print_error_and_exit "Error ZWEL0108E: Zowe YAML config file is required." "" 108
elif [ ! -f "${ZWE_CLI_PARAMETER_CONFIG}" ]; then
Expand Down
34 changes: 34 additions & 0 deletions bin/libs/json.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,40 @@ read_yaml() {
return ${code}
}

read_yaml_configmgr() {
file="${1}"
key=$(echo "${2}" | tr '.' '/')
ignore_null="${3:-true}"

print_trace "- read_yaml_configmgr process ${file} and extract '${2} -> ${key}'"

configmgr="${ZWE_zowe_runtimeDirectory}/bin/utils/configmgr"
schema="${ZWE_zowe_runtimeDirectory}/schemas/server-common.json:${ZWE_zowe_runtimeDirectory}/schemas/zowe-yaml-schema.json"

result=$(_CEE_RUNOPTS="XPLINK(ON)" "${configmgr}" -s "$schema" -p "FILE(${file})" extract "${key}" 2>&1);
code=$?

# When the item is not defined in config, configmgr returns
# code 0 and
# stdout = "error not found, reason=nnn"
if [[ "${result}" == "error not found, reason="* ]]; then
result=""
fi

print_trace " * Exit code: ${code}"
print_trace " * Output:"
print_trace "$(padding_left "${result}" " ")"

if [ ${code} -eq 0 ]; then
if [ "${ignore_null}" = "true" ]; then
if [ "${result}" = "null" -o "${result}" = "undefined" ]; then
result=
fi
fi
printf "${result}"
fi
}

read_json() {
file="${1}"
key="${2}"
Expand Down

0 comments on commit 30d2e0d

Please sign in to comment.