@contrail/cli 3.5.2 → 3.5.3-alpha.0dcc977
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -25
- package/dist/api/org-config.d.ts +3 -0
- package/dist/api/org-config.js +26 -0
- package/dist/api/types.d.ts +0 -5
- package/dist/api/types.js +1 -36
- package/dist/commands/groups/export.js +1 -13
- package/dist/commands/instance/export.js +2 -0
- package/dist/commands/instance/import.js +2 -0
- package/dist/commands/org-config/export.d.ts +13 -0
- package/dist/commands/org-config/export.js +71 -0
- package/dist/commands/org-config/import.d.ts +12 -0
- package/dist/commands/org-config/import.js +70 -0
- package/dist/commands/types/getAll.js +0 -18
- package/dist/commands/types/loadAll.js +0 -2
- package/dist/commands/types/mergeTypeProperties.js +0 -5
- package/dist/commands/types/uploadOptionSetHierarchies.js +0 -117
- package/dist/commands/types/uploadOptionSets.js +1 -1
- package/dist/commands/types/uploadRuleSets.js +2 -85
- package/dist/commands/types/uploadTypeOverrides.js +10 -2
- package/dist/commands/types/uploadTypePolicies.js +2 -86
- package/dist/commands/types/uploadTypePropertyPolicies.d.ts +0 -1
- package/dist/commands/types/uploadTypePropertyPolicies.js +3 -139
- package/dist/commands/users/export.js +1 -13
- package/dist/helpers/file-helpers.d.ts +1 -0
- package/dist/helpers/file-helpers.js +15 -1
- package/dist/helpers/types/type-uploader.js +1 -1
- package/dist/interfaces.d.ts +0 -25
- package/dist/templates/typescript/tsup.config.ts +0 -0
- package/node_modules/@contrail/org-config-migration/.github/workflows/publish-to-npm.yml +117 -0
- package/node_modules/@contrail/org-config-migration/.husky/pre-commit +0 -0
- package/node_modules/@contrail/org-config-migration/lib/index.d.ts +3 -3
- package/node_modules/@contrail/org-config-migration/lib/index.js +19 -19
- package/node_modules/@contrail/org-config-migration/lib/interfaces.d.ts +87 -97
- package/node_modules/@contrail/org-config-migration/lib/interfaces.js +2 -2
- package/node_modules/@contrail/org-config-migration/lib/services/index.d.ts +1 -1
- package/node_modules/@contrail/org-config-migration/lib/services/index.js +17 -17
- package/node_modules/@contrail/org-config-migration/lib/services/types.d.ts +12 -17
- package/node_modules/@contrail/org-config-migration/lib/services/types.js +115 -155
- package/node_modules/@contrail/org-config-migration/lib/types/exportAll.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportAll.js +34 -40
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSet.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSet.js +20 -20
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSetHierarchies.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSetHierarchies.js +16 -47
- package/node_modules/@contrail/org-config-migration/lib/types/exportOverrides.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportOverrides.js +8 -8
- package/node_modules/@contrail/org-config-migration/lib/types/exportRuleSets.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportRuleSets.js +14 -39
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePolicies.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePolicies.js +44 -56
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePropertyPolicies.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePropertyPolicies.js +44 -71
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypes.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypes.js +85 -85
- package/node_modules/@contrail/org-config-migration/lib/types/importAll.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/importAll.js +386 -451
- package/node_modules/@contrail/org-config-migration/lib/types/index.d.ts +8 -9
- package/node_modules/@contrail/org-config-migration/lib/types/index.js +24 -25
- package/node_modules/@contrail/org-config-migration/lib/types/parseOptionSetHierarchy.d.ts +3 -3
- package/node_modules/@contrail/org-config-migration/lib/types/parseOptionSetHierarchy.js +210 -210
- package/node_modules/@contrail/org-config-migration/lib/users/export.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/users/export.js +40 -40
- package/node_modules/@contrail/org-config-migration/lib/users/import.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/users/import.js +41 -41
- package/node_modules/@contrail/org-config-migration/lib/users/index.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/users/index.js +18 -18
- package/node_modules/@contrail/org-config-migration/package.json +1 -1
- package/oclif.manifest.json +111 -52
- package/package.json +2 -2
- package/dist/commands/types/uploadUsageInfo.d.ts +0 -15
- package/dist/commands/types/uploadUsageInfo.js +0 -180
- package/dist/commands/types/uploadUsageInfo.spec.d.ts +0 -1
- package/dist/commands/types/uploadUsageInfo.spec.js +0 -249
- package/node_modules/@contrail/org-config-migration/lib/types/exportUsageInfo.d.ts +0 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportUsageInfo.js +0 -39
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ $ npm install -g @contrail/cli
|
|
|
17
17
|
$ contrail COMMAND
|
|
18
18
|
running command...
|
|
19
19
|
$ contrail (--version)
|
|
20
|
-
@contrail/cli/3.5.
|
|
20
|
+
@contrail/cli/3.5.3-alpha.0dcc977 linux-x64 node-v24.19.0
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
|
@@ -61,6 +61,8 @@ To get instructions on how to set up autocomplete for your shell, run `contrail
|
|
|
61
61
|
* [`contrail load custom-entity DATAFILE CONFIGFILE`](#contrail-load-custom-entity-datafile-configfile)
|
|
62
62
|
* [`contrail load line-sheet DATAFILE CONFIGFILE`](#contrail-load-line-sheet-datafile-configfile)
|
|
63
63
|
* [`contrail load upload-and-load INCOMINGFILE CONFIGFILENAME`](#contrail-load-upload-and-load-incomingfile-configfilename)
|
|
64
|
+
* [`contrail org-config export`](#contrail-org-config-export)
|
|
65
|
+
* [`contrail org-config import`](#contrail-org-config-import)
|
|
64
66
|
* [`contrail projects export PROJECTNAME`](#contrail-projects-export-projectname)
|
|
65
67
|
* [`contrail projects list`](#contrail-projects-list)
|
|
66
68
|
* [`contrail projects load TEMPLATEFILELOCATION`](#contrail-projects-load-templatefilelocation)
|
|
@@ -86,7 +88,6 @@ To get instructions on how to set up autocomplete for your shell, run `contrail
|
|
|
86
88
|
* [`contrail types uploadTypePolicies`](#contrail-types-uploadtypepolicies)
|
|
87
89
|
* [`contrail types uploadTypePropertyPolicies`](#contrail-types-uploadtypepropertypolicies)
|
|
88
90
|
* [`contrail types uploadTypes`](#contrail-types-uploadtypes)
|
|
89
|
-
* [`contrail types uploadUsageInfo`](#contrail-types-uploadusageinfo)
|
|
90
91
|
* [`contrail users export`](#contrail-users-export)
|
|
91
92
|
* [`contrail users import USERSFILE`](#contrail-users-import-usersfile)
|
|
92
93
|
* [`contrail webhooks create`](#contrail-webhooks-create)
|
|
@@ -778,6 +779,53 @@ EXAMPLES
|
|
|
778
779
|
$ contrail load-processor upload-and-load <File Path> <Config Path>
|
|
779
780
|
```
|
|
780
781
|
|
|
782
|
+
## `contrail org-config export`
|
|
783
|
+
|
|
784
|
+
Export the org config for your Org
|
|
785
|
+
|
|
786
|
+
```
|
|
787
|
+
USAGE
|
|
788
|
+
$ contrail org-config export [-l error|warn|info|debug] [-e true|false] [-d <value>] [-f]
|
|
789
|
+
|
|
790
|
+
FLAGS
|
|
791
|
+
-d, --outDir=<value> [default: .] The directory to which to export the org config data. Defaults to the
|
|
792
|
+
current directory
|
|
793
|
+
-e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
|
|
794
|
+
<options: true|false>
|
|
795
|
+
-f, --overwrite Replaces any existing export files in outDir
|
|
796
|
+
-l, --logLevel=<option> The Log Level
|
|
797
|
+
<options: error|warn|info|debug>
|
|
798
|
+
|
|
799
|
+
DESCRIPTION
|
|
800
|
+
Export the org config for your Org
|
|
801
|
+
|
|
802
|
+
EXAMPLES
|
|
803
|
+
$ contrail org-config export
|
|
804
|
+
```
|
|
805
|
+
|
|
806
|
+
## `contrail org-config import`
|
|
807
|
+
|
|
808
|
+
Upload an extracted org config
|
|
809
|
+
|
|
810
|
+
```
|
|
811
|
+
USAGE
|
|
812
|
+
$ contrail org-config import [-l error|warn|info|debug] [-e true|false] [-d <value>]
|
|
813
|
+
|
|
814
|
+
FLAGS
|
|
815
|
+
-d, --dir=<value> [default: .] The directory from which to import the org config data. Defaults to the
|
|
816
|
+
current directory. The org config data will be loaded from $dir/org-config.yml
|
|
817
|
+
-e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
|
|
818
|
+
<options: true|false>
|
|
819
|
+
-l, --logLevel=<option> The Log Level
|
|
820
|
+
<options: error|warn|info|debug>
|
|
821
|
+
|
|
822
|
+
DESCRIPTION
|
|
823
|
+
Upload an extracted org config
|
|
824
|
+
|
|
825
|
+
EXAMPLES
|
|
826
|
+
$ contrail org-config import
|
|
827
|
+
```
|
|
828
|
+
|
|
781
829
|
## `contrail projects export PROJECTNAME`
|
|
782
830
|
|
|
783
831
|
Export a project.
|
|
@@ -1403,29 +1451,6 @@ EXAMPLES
|
|
|
1403
1451
|
$ contrail types uploadTypes
|
|
1404
1452
|
```
|
|
1405
1453
|
|
|
1406
|
-
## `contrail types uploadUsageInfo`
|
|
1407
|
-
|
|
1408
|
-
Upload extracted usage info
|
|
1409
|
-
|
|
1410
|
-
```
|
|
1411
|
-
USAGE
|
|
1412
|
-
$ contrail types uploadUsageInfo [-l error|warn|info|debug] [-e true|false] [-d <value>]
|
|
1413
|
-
|
|
1414
|
-
FLAGS
|
|
1415
|
-
-d, --dir=<value> [default: .] The directory from which to export the usage info data. Defaults to the
|
|
1416
|
-
current directory. The usage info data will be loaded from $dir/usage-info.yml
|
|
1417
|
-
-e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
|
|
1418
|
-
<options: true|false>
|
|
1419
|
-
-l, --logLevel=<option> The Log Level
|
|
1420
|
-
<options: error|warn|info|debug>
|
|
1421
|
-
|
|
1422
|
-
DESCRIPTION
|
|
1423
|
-
Upload extracted usage info
|
|
1424
|
-
|
|
1425
|
-
EXAMPLES
|
|
1426
|
-
$ contrail types uploadUsageInfo
|
|
1427
|
-
```
|
|
1428
|
-
|
|
1429
1454
|
## `contrail users export`
|
|
1430
1455
|
|
|
1431
1456
|
Export all users in the org.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createOrgConfig = exports.updateOrgConfig = exports.getOrgConfigs = void 0;
|
|
4
|
+
const sdk_1 = require("@contrail/sdk");
|
|
5
|
+
async function getOrgConfigs(options) {
|
|
6
|
+
return new sdk_1.Entities().get({
|
|
7
|
+
entityName: 'org-config',
|
|
8
|
+
...options,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.getOrgConfigs = getOrgConfigs;
|
|
12
|
+
async function updateOrgConfig(id, changes) {
|
|
13
|
+
return new sdk_1.Entities().update({
|
|
14
|
+
entityName: 'org-config',
|
|
15
|
+
id,
|
|
16
|
+
object: changes,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.updateOrgConfig = updateOrgConfig;
|
|
20
|
+
async function createOrgConfig(orgConfig) {
|
|
21
|
+
return new sdk_1.Entities().create({
|
|
22
|
+
entityName: 'org-config',
|
|
23
|
+
object: orgConfig,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.createOrgConfig = createOrgConfig;
|
package/dist/api/types.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
export declare function getOptionSets(): Promise<any[]>;
|
|
2
2
|
export declare function getUserLists(): Promise<any[]>;
|
|
3
3
|
export declare function getOptionSetHierarchies(): Promise<any[]>;
|
|
4
|
-
export declare function getOptionSetHierarchyLinks(): Promise<any[]>;
|
|
5
4
|
export declare function getRuleSets(): Promise<any[]>;
|
|
6
|
-
export declare function getRuleSetLinks(): Promise<any[]>;
|
|
7
|
-
export declare function getUsageInfo(): Promise<any[]>;
|
|
8
5
|
export declare function getTypePropertyPolicies(): Promise<any[]>;
|
|
9
|
-
export declare function getTypePropertyPolicyLinks(): Promise<any[]>;
|
|
10
6
|
export declare function getTypePolicies(): Promise<any[]>;
|
|
11
7
|
export declare function getTypeOverrideCopies(): Promise<any[]>;
|
|
12
8
|
export declare function uploadTypeOverrideObjects(reducedOverrides: any): Promise<void>;
|
|
13
|
-
export declare function getTypePolicyLinks(): Promise<any[]>;
|
package/dist/api/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.uploadTypeOverrideObjects = exports.getTypeOverrideCopies = exports.getTypePolicies = exports.getTypePropertyPolicies = exports.getRuleSets = exports.getOptionSetHierarchies = exports.getUserLists = exports.getOptionSets = void 0;
|
|
4
4
|
const sdk_1 = require("@contrail/sdk");
|
|
5
5
|
async function getOptionSets() {
|
|
6
6
|
return await new sdk_1.Entities().get({
|
|
@@ -21,13 +21,6 @@ async function getOptionSetHierarchies() {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
exports.getOptionSetHierarchies = getOptionSetHierarchies;
|
|
24
|
-
async function getOptionSetHierarchyLinks() {
|
|
25
|
-
const entitiesClient = new sdk_1.Entities();
|
|
26
|
-
return await entitiesClient.get({
|
|
27
|
-
entityName: 'type-option-set-hierarchy-link',
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
exports.getOptionSetHierarchyLinks = getOptionSetHierarchyLinks;
|
|
31
24
|
async function getRuleSets() {
|
|
32
25
|
const entitiesClient = new sdk_1.Entities();
|
|
33
26
|
return await entitiesClient.get({
|
|
@@ -35,20 +28,6 @@ async function getRuleSets() {
|
|
|
35
28
|
});
|
|
36
29
|
}
|
|
37
30
|
exports.getRuleSets = getRuleSets;
|
|
38
|
-
async function getRuleSetLinks() {
|
|
39
|
-
const entitiesClient = new sdk_1.Entities();
|
|
40
|
-
return await entitiesClient.get({
|
|
41
|
-
entityName: 'type-rule-set-link',
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
exports.getRuleSetLinks = getRuleSetLinks;
|
|
45
|
-
async function getUsageInfo() {
|
|
46
|
-
const entitiesClient = new sdk_1.Entities();
|
|
47
|
-
return await entitiesClient.get({
|
|
48
|
-
entityName: 'type-property-usage-info',
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
exports.getUsageInfo = getUsageInfo;
|
|
52
31
|
async function getTypePropertyPolicies() {
|
|
53
32
|
const entitiesClient = new sdk_1.Entities();
|
|
54
33
|
return await entitiesClient.get({
|
|
@@ -56,13 +35,6 @@ async function getTypePropertyPolicies() {
|
|
|
56
35
|
});
|
|
57
36
|
}
|
|
58
37
|
exports.getTypePropertyPolicies = getTypePropertyPolicies;
|
|
59
|
-
async function getTypePropertyPolicyLinks() {
|
|
60
|
-
const entitiesClient = new sdk_1.Entities();
|
|
61
|
-
return await entitiesClient.get({
|
|
62
|
-
entityName: 'type-property-policy-link',
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
exports.getTypePropertyPolicyLinks = getTypePropertyPolicyLinks;
|
|
66
38
|
async function getTypePolicies() {
|
|
67
39
|
const entitiesClient = new sdk_1.Entities();
|
|
68
40
|
return await entitiesClient.get({
|
|
@@ -86,10 +58,3 @@ async function uploadTypeOverrideObjects(reducedOverrides) {
|
|
|
86
58
|
});
|
|
87
59
|
}
|
|
88
60
|
exports.uploadTypeOverrideObjects = uploadTypeOverrideObjects;
|
|
89
|
-
async function getTypePolicyLinks() {
|
|
90
|
-
const entitiesClient = new sdk_1.Entities();
|
|
91
|
-
return await entitiesClient.get({
|
|
92
|
-
entityName: 'type-policy-link',
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
exports.getTypePolicyLinks = getTypePolicyLinks;
|
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.exportGroups = exports.DEFAULT_FILE_LOCATION = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const path = tslib_1.__importStar(require("path"));
|
|
6
5
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
8
6
|
const login_1 = require("../../auth/login");
|
|
9
|
-
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
10
7
|
const core_1 = require("@oclif/core");
|
|
11
8
|
const file_helpers_1 = require("../../helpers/file-helpers");
|
|
12
9
|
const users_1 = require("../../api/users");
|
|
@@ -61,18 +58,9 @@ async function exportGroups(fileLocation, overwrite) {
|
|
|
61
58
|
});
|
|
62
59
|
}
|
|
63
60
|
groups = groups.sort((one, two) => (one.name < two.name ? -1 : 1));
|
|
64
|
-
await saveData(groups, fileLocation, overwrite);
|
|
61
|
+
await (0, file_helpers_1.saveData)(groups, fileLocation, overwrite);
|
|
65
62
|
}
|
|
66
63
|
exports.exportGroups = exportGroups;
|
|
67
|
-
async function saveData(data, fileLocation, overwrite) {
|
|
68
|
-
const yamlStr = js_yaml_1.default.dump(data);
|
|
69
|
-
const CURRENT_DIR = process.cwd();
|
|
70
|
-
const pathToWrite = path.join(CURRENT_DIR, fileLocation);
|
|
71
|
-
if (fs_1.default.existsSync(pathToWrite)) {
|
|
72
|
-
await (0, file_helpers_1.safeFileOverwrite)(pathToWrite, overwrite);
|
|
73
|
-
}
|
|
74
|
-
fs_1.default.writeFileSync(pathToWrite, yamlStr, 'utf8');
|
|
75
|
-
}
|
|
76
64
|
function getGroupPrincipals(group, allGroups, orgUsers) {
|
|
77
65
|
if (!group?.groupPrincipals) {
|
|
78
66
|
return [];
|
|
@@ -6,6 +6,7 @@ const core_1 = require("@oclif/core");
|
|
|
6
6
|
const getAll_1 = require("../types/getAll");
|
|
7
7
|
const export_1 = require("../users/export");
|
|
8
8
|
const export_2 = require("../groups/export");
|
|
9
|
+
const export_3 = require("../org-config/export");
|
|
9
10
|
const basecommand_1 = require("../../basecommand");
|
|
10
11
|
class ExportInstance extends basecommand_1.BaseCommand {
|
|
11
12
|
static description = 'Exports an data of an instance including types and users';
|
|
@@ -32,6 +33,7 @@ class ExportInstance extends basecommand_1.BaseCommand {
|
|
|
32
33
|
await (0, getAll_1.getAll)(this.flags.outDir, this.flags.overwrite);
|
|
33
34
|
await (0, export_1.exportUsers)(path.join(this.flags.outDir, 'users.yml'), this.flags.overwrite);
|
|
34
35
|
await (0, export_2.exportGroups)(path.join(this.flags.outDir, 'groups.yml'), this.flags.overwrite);
|
|
36
|
+
await (0, export_3.exportOrgConfig)(this.flags.outDir, this.flags.overwrite);
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
exports.default = ExportInstance;
|
|
@@ -8,6 +8,7 @@ const import_1 = require("../users/import");
|
|
|
8
8
|
const import_2 = require("../groups/import");
|
|
9
9
|
const uploadTypePropertyPolicies_1 = require("../types/uploadTypePropertyPolicies");
|
|
10
10
|
const uploadTypePolicies_1 = require("../types/uploadTypePolicies");
|
|
11
|
+
const import_3 = require("../org-config/import");
|
|
11
12
|
const basecommand_1 = require("../../basecommand");
|
|
12
13
|
class ImportInstance extends basecommand_1.BaseCommand {
|
|
13
14
|
static description = 'Import the data to an instance, including types and users';
|
|
@@ -30,6 +31,7 @@ class ImportInstance extends basecommand_1.BaseCommand {
|
|
|
30
31
|
await (0, import_2.uploadGroups)(path.join(this.flags.dir, 'groups.yml'));
|
|
31
32
|
await (0, uploadTypePropertyPolicies_1.uploadTypePropertyPolicies)(this.flags.dir);
|
|
32
33
|
await (0, uploadTypePolicies_1.uploadTypePolicies)(this.flags.dir);
|
|
34
|
+
await (0, import_3.uploadOrgConfig)(this.flags.dir);
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
exports.default = ImportInstance;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../../basecommand';
|
|
2
|
+
export default class ExportOrgConfig extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
outDir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
overwrite: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare function exportOrgConfig(outDir: string, overwrite: boolean): Promise<void>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exportOrgConfig = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
+
const login_1 = require("../../auth/login");
|
|
8
|
+
const core_1 = require("@oclif/core");
|
|
9
|
+
const file_helpers_1 = require("../../helpers/file-helpers");
|
|
10
|
+
const org_config_1 = require("../../api/org-config");
|
|
11
|
+
const basecommand_1 = require("../../basecommand");
|
|
12
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
13
|
+
const ORG_SPECIFIC_FIELDS = [
|
|
14
|
+
'id',
|
|
15
|
+
'orgId',
|
|
16
|
+
'createdOn',
|
|
17
|
+
'updatedOn',
|
|
18
|
+
'createdById',
|
|
19
|
+
'updatedById',
|
|
20
|
+
'createdBy',
|
|
21
|
+
'updatedBy',
|
|
22
|
+
];
|
|
23
|
+
class ExportOrgConfig extends basecommand_1.BaseCommand {
|
|
24
|
+
static description = 'Export the org config for your Org';
|
|
25
|
+
static examples = [
|
|
26
|
+
`$ contrail org-config export
|
|
27
|
+
`,
|
|
28
|
+
];
|
|
29
|
+
static flags = {
|
|
30
|
+
...basecommand_1.BaseCommand.baseFlags,
|
|
31
|
+
outDir: core_1.Flags.string({
|
|
32
|
+
char: 'd',
|
|
33
|
+
description: 'The directory to which to export the org config data. Defaults to the current directory',
|
|
34
|
+
required: false,
|
|
35
|
+
default: '.',
|
|
36
|
+
}),
|
|
37
|
+
overwrite: core_1.Flags.boolean({
|
|
38
|
+
char: 'f',
|
|
39
|
+
description: 'Replaces any existing export files in outDir',
|
|
40
|
+
required: false,
|
|
41
|
+
default: false,
|
|
42
|
+
}),
|
|
43
|
+
};
|
|
44
|
+
async run() {
|
|
45
|
+
await exportOrgConfig(this.flags.outDir, this.flags.overwrite);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.default = ExportOrgConfig;
|
|
49
|
+
async function exportOrgConfig(outDir, overwrite) {
|
|
50
|
+
try {
|
|
51
|
+
await (0, login_1.authUser)();
|
|
52
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('ORG CONFIG')} Exporting`);
|
|
53
|
+
const orgConfigs = await (0, org_config_1.getOrgConfigs)();
|
|
54
|
+
if (!Array.isArray(orgConfigs) || orgConfigs.length === 0) {
|
|
55
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('ORG CONFIG')} No org config found. Skipping.`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const orgConfig = { ...orgConfigs[0] };
|
|
59
|
+
for (const field of ORG_SPECIFIC_FIELDS) {
|
|
60
|
+
delete orgConfig[field];
|
|
61
|
+
}
|
|
62
|
+
await (0, file_helpers_1.saveData)(orgConfig, path.join(outDir, 'org-config.yml'), overwrite);
|
|
63
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('ORG CONFIG')} Exported`);
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
logger_1.default.info(`${chalk_1.default.red.bold('FAIL')} Org Config Export Failed. ${e}`);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
logger_1.default.info(`${chalk_1.default.green.bold('COMPLETE')} Org Config Export Complete.`);
|
|
70
|
+
}
|
|
71
|
+
exports.exportOrgConfig = exportOrgConfig;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommand } from '../../basecommand';
|
|
2
|
+
export default class ImportOrgConfig extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
dir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare function uploadOrgConfig(dir: string): Promise<void>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uploadOrgConfig = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
8
|
+
const login_1 = require("../../auth/login");
|
|
9
|
+
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
10
|
+
const core_1 = require("@oclif/core");
|
|
11
|
+
const org_config_1 = require("../../api/org-config");
|
|
12
|
+
const basecommand_1 = require("../../basecommand");
|
|
13
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
14
|
+
class ImportOrgConfig extends basecommand_1.BaseCommand {
|
|
15
|
+
static description = 'Upload an extracted org config';
|
|
16
|
+
static examples = [
|
|
17
|
+
`$ contrail org-config import
|
|
18
|
+
`,
|
|
19
|
+
];
|
|
20
|
+
static flags = {
|
|
21
|
+
...basecommand_1.BaseCommand.baseFlags,
|
|
22
|
+
dir: core_1.Flags.string({
|
|
23
|
+
char: 'd',
|
|
24
|
+
description: 'The directory from which to import the org config data. Defaults to the current directory. The org config data will be loaded from $dir/org-config.yml',
|
|
25
|
+
required: false,
|
|
26
|
+
default: '.',
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
async run() {
|
|
30
|
+
await uploadOrgConfig(this.flags.dir);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.default = ImportOrgConfig;
|
|
34
|
+
async function uploadOrgConfig(dir) {
|
|
35
|
+
try {
|
|
36
|
+
await (0, login_1.authUser)();
|
|
37
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('ORG CONFIG')} Uploading`);
|
|
38
|
+
const orgConfig = loadOrgConfig(dir);
|
|
39
|
+
if (!orgConfig || typeof orgConfig !== 'object') {
|
|
40
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('ORG CONFIG')} No org config found in ${dir}. Skipping.`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const existingOrgConfigs = await (0, org_config_1.getOrgConfigs)();
|
|
44
|
+
if (Array.isArray(existingOrgConfigs) && existingOrgConfigs.length > 0) {
|
|
45
|
+
await (0, org_config_1.updateOrgConfig)(existingOrgConfigs[0].id, orgConfig);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
await (0, org_config_1.createOrgConfig)(orgConfig);
|
|
49
|
+
}
|
|
50
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('ORG CONFIG')} Uploaded`);
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
logger_1.default.info(`${chalk_1.default.red.bold('FAIL')} Org Config Upload Failed. ${e}`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
logger_1.default.info(`${chalk_1.default.green.bold('COMPLETE')} Org Config Upload Complete.`);
|
|
57
|
+
}
|
|
58
|
+
exports.uploadOrgConfig = uploadOrgConfig;
|
|
59
|
+
function loadOrgConfig(fromDir) {
|
|
60
|
+
const filePath = path.join(fromDir, 'org-config.yml');
|
|
61
|
+
if (!fs_1.default.existsSync(filePath)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
return js_yaml_1.default.load(fs_1.default.readFileSync(filePath, 'utf8'));
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -54,14 +54,9 @@ async function getAll(outDir, overwrite) {
|
|
|
54
54
|
types: await (0, type_extractor_1.getTypes)(),
|
|
55
55
|
optionSets: await (0, types_1.getOptionSets)(),
|
|
56
56
|
optionSetHierarchies: await (0, types_1.getOptionSetHierarchies)(),
|
|
57
|
-
optionSetHierarchyLinks: await (0, types_1.getOptionSetHierarchyLinks)(),
|
|
58
57
|
ruleSets: await (0, types_1.getRuleSets)(),
|
|
59
|
-
ruleSetLinks: await (0, types_1.getRuleSetLinks)(),
|
|
60
|
-
usageInfo: await (0, types_1.getUsageInfo)(),
|
|
61
58
|
typePropertyPolicies: await (0, types_1.getTypePropertyPolicies)(),
|
|
62
|
-
typePropertyPolicyLinks: await (0, types_1.getTypePropertyPolicyLinks)(),
|
|
63
59
|
typePolicies: await (0, types_1.getTypePolicies)(),
|
|
64
|
-
typePolicyLinks: await (0, types_1.getTypePolicyLinks)(),
|
|
65
60
|
typeOverrides: await (0, types_1.getTypeOverrideCopies)(),
|
|
66
61
|
orgUsers: await (0, users_1.getUserOrgs)(),
|
|
67
62
|
groups: await (0, users_1.getGroups)(),
|
|
@@ -125,31 +120,18 @@ async function saveData(reducedData, dir, overwrite) {
|
|
|
125
120
|
split: true,
|
|
126
121
|
fileLabel: 'identifier',
|
|
127
122
|
},
|
|
128
|
-
reducedOptionSetHierarchyLinks: {
|
|
129
|
-
filename: 'type-option-set-hierarchy-links',
|
|
130
|
-
split: false,
|
|
131
|
-
fileLabel: '',
|
|
132
|
-
},
|
|
133
123
|
reducedRuleSets: { filename: 'rule-sets', split: true, fileLabel: 'name' },
|
|
134
|
-
reducedRuleSetLinks: { filename: 'rule-set-links', split: false, fileLabel: '' },
|
|
135
|
-
reducedUsageInfo: { filename: 'usage-info', split: false, fileLabel: '' },
|
|
136
124
|
reducedTypePropertyPolicies: {
|
|
137
125
|
filename: 'type-property-policies',
|
|
138
126
|
split: true,
|
|
139
127
|
fileLabel: 'label',
|
|
140
128
|
},
|
|
141
|
-
reducedTypePropertyPolicyLinks: {
|
|
142
|
-
filename: 'type-property-policy-links',
|
|
143
|
-
split: false,
|
|
144
|
-
fileLabel: '',
|
|
145
|
-
},
|
|
146
129
|
reducedOverrides: {
|
|
147
130
|
filename: 'type-overrides',
|
|
148
131
|
split: false,
|
|
149
132
|
fileLabel: '',
|
|
150
133
|
},
|
|
151
134
|
reducedTypePolicies: { filename: 'type-policies', split: true, fileLabel: 'label' },
|
|
152
|
-
reducedTypePolicyLinks: { filename: 'type-policy-links', split: false, fileLabel: '' },
|
|
153
135
|
};
|
|
154
136
|
for (const [key, folder] of Object.entries(propertyToFolderMap)) {
|
|
155
137
|
const CURRENT_DIR = process.cwd();
|
|
@@ -7,7 +7,6 @@ const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
|
7
7
|
const login_1 = require("../../auth/login");
|
|
8
8
|
const uploadOptionSets_1 = require("./uploadOptionSets");
|
|
9
9
|
const uploadOptionSetHierarchies_1 = require("./uploadOptionSetHierarchies");
|
|
10
|
-
const uploadUsageInfo_1 = require("./uploadUsageInfo");
|
|
11
10
|
const uploadRuleSets_1 = require("./uploadRuleSets");
|
|
12
11
|
const uploadTypePropertyPolicies_1 = require("./uploadTypePropertyPolicies");
|
|
13
12
|
const type_uploader_1 = require("../../helpers/types/type-uploader");
|
|
@@ -41,7 +40,6 @@ async function loadAll(dir, skipPolicies = false) {
|
|
|
41
40
|
await (0, uploadOptionSets_1.uploadOptionSets)(dir);
|
|
42
41
|
await (0, type_uploader_1.uploadTypes)(dir);
|
|
43
42
|
await (0, uploadOptionSetHierarchies_1.uploadOptionSetHierarchies)(dir);
|
|
44
|
-
await (0, uploadUsageInfo_1.uploadUsageInfo)(dir);
|
|
45
43
|
await (0, uploadRuleSets_1.uploadRuleSets)(dir);
|
|
46
44
|
if (!skipPolicies) {
|
|
47
45
|
await (0, uploadTypePropertyPolicies_1.uploadTypePropertyPolicies)(dir);
|
|
@@ -62,14 +62,9 @@ async function mergeTypeProperties(fileLocation, typePaths) {
|
|
|
62
62
|
types: await (0, type_extractor_1.getTypes)(),
|
|
63
63
|
optionSets: await (0, types_2.getOptionSets)(),
|
|
64
64
|
optionSetHierarchies: [],
|
|
65
|
-
optionSetHierarchyLinks: [],
|
|
66
65
|
ruleSets: [],
|
|
67
|
-
ruleSetLinks: [],
|
|
68
|
-
usageInfo: [],
|
|
69
66
|
typePropertyPolicies: [],
|
|
70
|
-
typePropertyPolicyLinks: [],
|
|
71
67
|
typePolicies: [],
|
|
72
|
-
typePolicyLinks: [],
|
|
73
68
|
};
|
|
74
69
|
const reducedData = await (0, types_1.getAllReducedTypes)(data);
|
|
75
70
|
for (const typePath of typePaths) {
|