Skip to content
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

Clean up the code when checking z/OSMF [v2] #3971

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
All notable changes to the Zowe Installer will be documented in this file.
<!--Add the PR or issue number to the entry if available.-->

## `2.18.1`
- Bugfix: Error message `ZWEL0141E` did not print user ID. [#3971](https://github.com/zowe/zowe-install-packaging/pull/3971)

## `2.17.0`

## New features and enhancements
Expand Down
7 changes: 5 additions & 2 deletions bin/commands/internal/start/prepare/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ global_validate() {
if [[ ${ZWE_ENABLED_COMPONENTS} == *"discovery"* || ${ZWE_ENABLED_COMPONENTS} == *"files-api"* || ${ZWE_ENABLED_COMPONENTS} == *"jobs-api"* ]]; then
validate_this "validate_zosmf_host_and_port \"${ZOSMF_HOST}\" \"${ZOSMF_PORT}\" 2>&1" "zwe-internal-start-prepare,global_validate:${LINENO}"
fi
elif [ "${ZWE_components_gateway_apiml_security_auth_provider}" = "zosmf" ]; then
validate_this "validate_zosmf_as_auth_provider \"${ZOSMF_HOST}\" \"${ZOSMF_PORT}\" \"${ZWE_components_gateway_apiml_security_auth_provider}\" 2>&1" "zwe-internal-start-prepare,global_validate:${LINENO}"
if [ "${ZWE_components_discovery_enabled}" = "false" -a "${ZWE_components_gateway_apiml_security_auth_provider}" = "zosmf" ]; then
let "ZWE_PRIVATE_ERRORS_FOUND=${ZWE_PRIVATE_OLD_ERRORS_FOUND}+1"
print_error "Using z/OSMF as 'components.gateway.apiml.security.auth.provider' is not possible: discovery is disabled."
print_formatted_info "ZWELS" "zwe-internal-start-prepare,global_validate:${LINENO}" "Zosmf validation failed"
fi
fi

check_runtime_validation_result "zwe-internal-start-prepare,global_validate:${LINENO}"
Expand Down
13 changes: 6 additions & 7 deletions bin/commands/internal/start/prepare/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function prepareLogDirectory() {
if (logDir) {
os.mkdir(logDir, 0o750);
if (!fs.isDirectoryWritable(logDir)) {
common.printFormattedError("ZWELS", "zwe-internal-start-prepare,prepare_log_directory", `ZWEL0141E: User $(get_user_id) does not have write permission on ${logDir}.`);
common.printFormattedError("ZWELS", "zwe-internal-start-prepare,prepare_log_directory", `ZWEL0141E: User ${user} does not have write permission on ${logDir}.`);
std.exit(141);
}
}
Expand Down Expand Up @@ -172,12 +172,11 @@ function globalValidate(enabledComponents:string[]): void {
privateErrors++;
common.printFormattedError('ZWELS', "zwe-internal-start-prepare,global_validate", "Zosmf validation failed");
}
} else if (std.getenv('ZWE_components_gateway_apiml_security_auth_provider') == "zosmf") {
let zosmfOk = zosmf.validateZosmfAsAuthProvider(zosmfHost, zosmfPort, 'zosmf');
if (!zosmfOk) {
privateErrors++;
common.printFormattedError('ZWELS', "zwe-internal-start-prepare,global_validate", "Zosmf validation failed");
}
}
if (!enabledComponents.includes('discovery') && std.getenv('ZWE_components_gateway_apiml_security_auth_provider') == "zosmf") {
privateErrors++;
common.printError("Using z/OSMF as 'components.gateway.apiml.security.auth.provider' is not possible: discovery is disabled.");
common.printFormattedError('ZWELS', "zwe-internal-start-prepare,global_validate", "Zosmf validation failed");
}
}

Expand Down
13 changes: 0 additions & 13 deletions bin/libs/zosmf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,3 @@ validate_zosmf_host_and_port() {
print_message "Successfully checked z/OS MF is available on 'https://${zosmf_host}:${zosmf_port}/zosmf/info'"
fi
}

validate_zosmf_as_auth_provider() {
zosmf_host="${1}"
zosmf_port="${2}"
auth_provider="${3}"

if [ -n "${zosmf_host}" -a -n "${zosmf_port}" ]; then
if [ "${auth_provider}" = "zosmf" ]; then
print_error "z/OSMF is not configured. Using z/OSMF as authentication provider is not supported."
return 1
fi
fi
}
11 changes: 0 additions & 11 deletions bin/libs/zosmf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,3 @@ export function validateZosmfHostAndPort(zosmfHost: string, zosmfPort: number):
}
return zosmfCheckPassed;
}

//TODO isnt this completely backwards?
export function validateZosmfAsAuthProvider(zosmfHost: string, zosmfPort: number, authProvider: string): boolean {
if (zosmfHost && zosmfPort) {
if (authProvider == 'zosmf') {
common.printError("z/OSMF is not configured. Using z/OSMF as authentication provider is not supported.");
return true;
}
}
return false;
}
Loading