-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from zowe/staging
Staging
- Loading branch information
Showing
2 changed files
with
112 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
This program and the accompanying materials are | ||
made available under the terms of the Eclipse Public License v2.0 which accompanies | ||
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html | ||
SPDX-License-Identifier: EPL-2.0 | ||
Copyright Contributors to the Zowe Project. | ||
*/ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const semver = require('semver'); | ||
|
||
const versions = [ | ||
{ | ||
v: '1.11.0', | ||
upgrade: function(toLocation, serverConfig, instanceItems) { | ||
try { | ||
let hasOutdatedZosmfPluginConfig = serverConfig.dataserviceAuthentication.implementationDefaults.zosmf | ||
&& !serverConfig.dataserviceAuthentication.implementationDefaults.zosmf.plugins; | ||
if (hasOutdatedZosmfPluginConfig) { | ||
if (instanceItems.indexOf('org.zowe.zlux.auth.zosmf.json') != -1) { | ||
console.log('Removing org.zowe.zlux.auth.zosmf.json from defaults'); | ||
fs.unlinkSync(path.join(toLocation, 'plugins', 'org.zowe.zlux.auth.zosmf.json')); | ||
} | ||
if (instanceItems.indexOf('org.zowe.zlux.proxy.zosmf.json') != -1) { | ||
console.log('Removing org.zowe.zlux.proxy.zosmf.json from defaults'); | ||
fs.unlinkSync(path.join(toLocation, 'plugins', 'org.zowe.zlux.proxy.zosmf.json')); | ||
} | ||
} | ||
} catch (e) { | ||
//change not needed | ||
} | ||
} | ||
} | ||
]; | ||
|
||
|
||
module.exports.doUpgrade = function doUpgrade(fromVersion, toLocation, serverConfig, instanceItems) { | ||
let firstIndex = 0; | ||
let upgradingTo; | ||
let upgradedTo; | ||
for (let i = 0; i < versions.length; i++) { | ||
if (semver.gt(versions[i].v, fromVersion)) { | ||
firstIndex = i; | ||
break; | ||
} | ||
} | ||
try { | ||
for (let i = firstIndex; i < versions.length; i++) { | ||
upgradingTo = versions[i].v; | ||
versions[i].upgrade(toLocation, serverConfig, instanceItems); | ||
upgradedTo = versions[i].v; | ||
} | ||
} catch (e) { | ||
console.log('app-server config could not upgrade to version='+upgradingTo); | ||
} finally { | ||
console.log('app-server config upgraded to version='+upgradedTo); | ||
return upgradedTo; | ||
} | ||
}; |