diff --git a/CHANGELOG.md b/CHANGELOG.md index a6a68c1b21..be6da56e68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to the Zowe Installer will be documented in this file. +## `2.14.0` + +### New features and enhancements +- Enhancement: configmgr.ts now can return a Zowe config with the given HA instance's configuration substituted for convenience. This now used in zwe to fix an issue where zwe would not respect the preference of if a component was enabled or disabled in a particular instance when zowe.useConfigmgr was set to true. + +#### Minor enhancements/defect fixes +- Bugfix: environment variables were not using the values specified for each HA instance when zowe.useConfigmgr was set to true. + ## `2.13.0` ### New features and enhancements diff --git a/bin/libs/component.ts b/bin/libs/component.ts index 1680ca3f61..ddf6eb3037 100644 --- a/bin/libs/component.ts +++ b/bin/libs/component.ts @@ -24,6 +24,7 @@ import * as shell from './shell'; import * as configmgr from './configmgr'; import * as varlib from './var'; import * as fakejq from './fakejq'; +import * as configUtils from './config'; const CONFIG_MGR=configmgr.CONFIG_MGR; const ZOWE_CONFIG=configmgr.ZOWE_CONFIG; @@ -44,11 +45,13 @@ const PLUGIN_DEF_SCHEMA_ID = "https://zowe.org/schemas/v2/appfw-plugin-definitio const PLUGIN_DEF_SCHEMAS = `${runtimeDirectory}/components/app-server/schemas/plugindefinition-schema.json`; -export function getEnabledComponents(): string[] { - let components = Object.keys(ZOWE_CONFIG.components); - let enabled:string[] = []; - components.forEach((key:string) => { - if (ZOWE_CONFIG.components[key].enabled == true) { +export function getEnabledComponents() { + let haInstance = configUtils.sanitizeHaInstanceId(); + let haConfig = configmgr.getZoweConfig(haInstance); + let components = Object.keys(haConfig.components); + let enabled: string[] = []; + components.forEach((key) => { + if (haConfig.components[key].enabled == true) { enabled.push(key); } }); @@ -353,15 +356,7 @@ export function findAllEnabledComponents(): string { } export function findAllEnabledComponents2(): string[] { - let installedComponentsEnv=std.getenv('ZWE_INSTALLED_COMPONENTS'); - let installedComponents = installedComponentsEnv ? installedComponentsEnv.split(',') : null; - if (!installedComponents) { - installedComponents = findAllInstalledComponents2(); - } - return installedComponents.filter(function(component: string) { - let componentNameAsEnv=stringlib.sanitizeAlphanum(component); - return std.getenv(`ZWE_components_${componentNameAsEnv}_enabled`) == 'true'; - }); + return getEnabledComponents(); } export function findAllLaunchComponents(): string { diff --git a/bin/libs/configmgr.ts b/bin/libs/configmgr.ts index 03863f3d7a..ba16685f1e 100644 --- a/bin/libs/configmgr.ts +++ b/bin/libs/configmgr.ts @@ -48,6 +48,7 @@ const ZOWE_SCHEMA_ID = 'https://zowe.org/schemas/v2/server-base'; const ZOWE_SCHEMA_SET=`${ZOWE_SCHEMA}:${COMMON_SCHEMA}`; export let ZOWE_CONFIG=getZoweConfig(); +let HA_CONFIGS = {}; export function getZoweBaseSchemas(): string { return ZOWE_SCHEMA_SET; @@ -373,6 +374,7 @@ export function updateZoweConfig(updateObj: any, writeUpdate: boolean, arrayMerg let rc = updateConfig(getZoweConfigName(), updateObj, arrayMergeStrategy); if (rc == 0) { ZOWE_CONFIG=getZoweConfig(); + HA_CONFIGS = {}; //reset if (writeUpdate) { writeZoweConfigUpdate(updateObj, arrayMergeStrategy); writeMergedConfig(ZOWE_CONFIG); @@ -490,14 +492,29 @@ function getConfig(configName: string, configPath: string, schemas: string): any } } -export function getZoweConfig(): any { - if (configLoaded) { +function makeHaConfig(haInstance: string): any { + let config = getConfig(ZOWE_CONFIG_NAME, ZOWE_CONFIG_PATH, ZOWE_SCHEMA_SET); + if (config.haInstances && config.haInstances[haInstance]) { + let merger = new objUtils.Merger(); + merger.mergeArrays = false; + let mergedConfig = merger.merge(config.haInstances[haInstance], config); + INSTANCE_KEYS_NOT_IN_BASE.forEach((key) => delete mergedConfig[key]); + HA_CONFIGS[haInstance] = mergedConfig; + return mergedConfig; + } + return config; +} + +export function getZoweConfig(haInstance?: string): any { + if (configLoaded && !haInstance) { return getConfig(ZOWE_CONFIG_NAME, ZOWE_CONFIG_PATH, ZOWE_SCHEMA_SET); + } else if (configLoaded) { + return HA_CONFIGS[haInstance] || makeHaConfig(haInstance); } else { let config = getConfig(ZOWE_CONFIG_NAME, ZOWE_CONFIG_PATH, ZOWE_SCHEMA_SET); configLoaded = true; const writeResult = writeMergedConfig(config); - return config; + return haInstance ? makeHaConfig(haInstance) : config; } } @@ -528,7 +545,7 @@ export function getZoweConfigEnv(haInstance: string): any { haFlattener.setSeparator('_'); haFlattener.setPrefix('ZWE_'); haFlattener.setKeepArrays(true); - let overrides = haFlattener.flatten(config.haInstances[haInstance]); + overrides = haFlattener.flatten(config.haInstances[haInstance]); } else { envs['ZWE_haInstance_hostname'] = config.zowe.externalDomains[0]; }