This repository has been archived by the owner on Oct 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathec_setup_custom.pl
49 lines (43 loc) · 2.29 KB
/
ec_setup_custom.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use strict;
use warnings;
use ElectricCommander::Util;
# Have to rename "cofngi_new" into "config_new_basic_credential"
# If promoted from < 2.2.0
# die $otherPluginName, $otherVersion, $thisVersion;
# Determine which version is newer. $versionCmp is < 0 if this
# version is newer than the other version.
# my $versionCmp = compareExact($otherVersion, $thisVersion);
if (compareExact($otherVersion, "2.2.0.0") <= 0) {
my $xpath = $commander->getProperties({ path => "/plugins/$pluginName/project/ec_plugin_cfgs/" });
for my $configProp ($xpath->findnodes('//property')) {
my $configName = $configProp->findvalue('propertyName')->string_value;
my $oldCredName = $commander->getPropertyValue("/plugins/$pluginName/project/ec_plugin_cfgs/$configName/credential");
if ($oldCredName) {
my $newCredName = "${configName}_basic_credential";
$commander->setProperty("/plugins/$pluginName/project/ec_plugin_cfgs/$configName/basic_credential", $newCredName);
$commander->setProperty("/plugins/$pluginName/project/ec_plugin_cfgs/$configName/bearer_credential", "${configName}_bearer_credential");
$commander->deleteProperty("/plugins/$pluginName/project/ec_plugin_cfgs/$configName/credential");
$commander->setProperty("/plugins/$pluginName/project/ec_plugin_cfgs/$configName/authScheme", "basic");
$commander->setProperty("/plugins/$pluginName/project/ec_plugin_cfgs/$configName/endpoint", "https://api.github.com");
eval {
$commander->modifyCredential({
credentialName => $oldCredName,
projectName => "/plugins/$pluginName/project",
newName => $newCredName,
});
warn "Renamed credential $oldCredName to $newCredName";
$commander->createCredential({
credentialName => "${configName}_bearer_credential",
projectName => "/plugins/$pluginName/project",
userName => "",
password => ""
});
1;
}
or do {
warn "Failed to rename credential $oldCredName: $@";
};
}
}
}
# /plugins/$otherPluginName/project/$configName