@contrail/cli 1.0.58 → 1.0.60

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.
@@ -23,6 +23,7 @@ export declare class AssortmentConfiguration {
23
23
  export declare class Folder {
24
24
  identifier: string;
25
25
  name: string;
26
+ principals: string[];
26
27
  assortments: AssortmentConfiguration[];
27
28
  subFolders: Folder[];
28
29
  }
@@ -30,6 +31,7 @@ export declare class ProjectConfiguration {
30
31
  projectName: string;
31
32
  identifier: string;
32
33
  commonConfig: CommonConfiguration;
34
+ principals: string[];
33
35
  assortments: AssortmentConfiguration[];
34
36
  subFolders: Folder[];
35
37
  }
@@ -37,6 +39,7 @@ export declare class ProjectConfigurationTemplate {
37
39
  projectName: string;
38
40
  identifier: string;
39
41
  commonConfig: CommonConfiguration;
42
+ principals: string[];
40
43
  allFolders: FolderSlim[];
41
44
  allAssortments: AssortmentConfigurationSlim[];
42
45
  allAssortmentRelationships: AssortmentConfigurationRelationships[];
@@ -44,6 +47,7 @@ export declare class ProjectConfigurationTemplate {
44
47
  export declare class FolderSlim {
45
48
  identifier: string;
46
49
  name: string;
50
+ principals: string[];
47
51
  folderIdentifier: string;
48
52
  }
49
53
  export declare class AssortmentConfigurationSlim {
@@ -54,10 +54,12 @@ async function exportProject(name) {
54
54
  const projectConfiguration = {
55
55
  projectName: workspace.name,
56
56
  identifier: workspace.identifier,
57
+ principals: [],
57
58
  commonConfig: {},
58
59
  assortments: [],
59
60
  subFolders: []
60
61
  };
62
+ projectConfiguration.principals = await getFolderPrincipals(workspace);
61
63
  const allAssortments = [];
62
64
  await getAssortmentsAndSubFolders(workspace.id, projectConfiguration.assortments, projectConfiguration.subFolders, allAssortments);
63
65
  await convertRelationshipsInFolders(projectConfiguration, allAssortments);
@@ -104,9 +106,11 @@ async function getAssortmentsAndSubFolders(parentId, assortments, subFolders, al
104
106
  const converted = {
105
107
  identifier: folder.identifier,
106
108
  name: folder.name,
109
+ principals: [],
107
110
  assortments: [],
108
111
  subFolders: [],
109
112
  };
113
+ converted.principals = await getFolderPrincipals(folder);
110
114
  await getAssortmentsAndSubFolders(folder.id, converted.assortments, converted.subFolders, allAssortments);
111
115
  subFolders.push(converted);
112
116
  }
@@ -136,6 +140,20 @@ function convertRelationshipsToIdentifiers(assortments, allAssortments) {
136
140
  delete assortment.composedFromAssortmentIds;
137
141
  }
138
142
  }
143
+ async function getFolderPrincipals(folder) {
144
+ const principals = [];
145
+ if (!folder.policyOwner) {
146
+ return ['INHERIT'];
147
+ }
148
+ const workspacePrincipals = await new Entities().get({
149
+ entityName: 'workspace-principal',
150
+ criteria: { workspaceId: folder.id }
151
+ });
152
+ for (const workspacePrincipal of workspacePrincipals) {
153
+ principals.push(workspacePrincipal.principalReference);
154
+ }
155
+ return principals;
156
+ }
139
157
  function deleteNonUserKeys(assortment) {
140
158
  delete assortment.name;
141
159
  delete assortment.identifier;
@@ -58,6 +58,7 @@ function parseToProjectConfiguration(projectConfigurationFromFile) {
58
58
  projectName: projectConfigurationFromFile.projectName,
59
59
  identifier: projectConfigurationFromFile.identifier,
60
60
  commonConfig: projectConfigurationFromFile.commonConfig,
61
+ principals: projectConfigurationFromFile.principals,
61
62
  assortments: [],
62
63
  subFolders: [],
63
64
  };
@@ -271,7 +271,7 @@ function saveData(reducedData, dir) {
271
271
  if (!fileLabel) {
272
272
  console.warn('skipping bad data:', item);
273
273
  }
274
- fs.writeFileSync(path.join(subDir, `${fileLabel}.yml`), yamlStr, 'utf8');
274
+ fs.writeFileSync(path.join(subDir, `${removeSlash(fileLabel)}.yml`), yamlStr, 'utf8');
275
275
  }
276
276
  }
277
277
  else {
@@ -280,3 +280,7 @@ function saveData(reducedData, dir) {
280
280
  }
281
281
  }
282
282
  }
283
+ function removeSlash(string) {
284
+ const re = /\//gi;
285
+ return string.replace(re, '-');
286
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "1.0.58",
3
+ "version": "1.0.60",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -22,6 +22,7 @@ export class AssortmentConfiguration {
22
22
  export class Folder {
23
23
  identifier: string;
24
24
  name: string;
25
+ principals: string[];
25
26
  assortments: AssortmentConfiguration[];
26
27
  subFolders: Folder[];
27
28
  }
@@ -30,6 +31,7 @@ export class ProjectConfiguration {
30
31
  projectName: string;
31
32
  identifier: string;
32
33
  commonConfig: CommonConfiguration;
34
+ principals: string[];
33
35
  assortments: AssortmentConfiguration[];
34
36
  subFolders: Folder[];
35
37
  }
@@ -38,6 +40,7 @@ export class ProjectConfigurationTemplate {
38
40
  projectName: string;
39
41
  identifier: string;
40
42
  commonConfig: CommonConfiguration;
43
+ principals: string[];
41
44
  allFolders: FolderSlim[];
42
45
  allAssortments: AssortmentConfigurationSlim[];
43
46
  allAssortmentRelationships: AssortmentConfigurationRelationships[];
@@ -46,6 +49,7 @@ export class ProjectConfigurationTemplate {
46
49
  export class FolderSlim {
47
50
  identifier: string;
48
51
  name: string;
52
+ principals: string[];
49
53
  folderIdentifier: string;
50
54
  }
51
55
 
@@ -67,11 +67,14 @@ async function exportProject(name) {
67
67
  const projectConfiguration = {
68
68
  projectName: workspace.name,
69
69
  identifier: workspace.identifier,
70
+ principals: [],
70
71
  commonConfig: {},
71
72
  assortments: [],
72
73
  subFolders: []
73
74
  };
74
75
 
76
+ projectConfiguration.principals = await getFolderPrincipals(workspace);
77
+
75
78
  const allAssortments = [];
76
79
  await getAssortmentsAndSubFolders(workspace.id, projectConfiguration.assortments, projectConfiguration.subFolders, allAssortments);
77
80
  await convertRelationshipsInFolders(projectConfiguration, allAssortments);
@@ -125,9 +128,12 @@ async function getAssortmentsAndSubFolders(parentId, assortments, subFolders, al
125
128
  const converted = {
126
129
  identifier: folder.identifier,
127
130
  name: folder.name,
131
+ principals: [],
128
132
  assortments: [],
129
133
  subFolders: [],
130
134
  };
135
+
136
+ converted.principals = await getFolderPrincipals(folder);
131
137
  await getAssortmentsAndSubFolders(folder.id, converted.assortments, converted.subFolders, allAssortments);
132
138
  subFolders.push(converted);
133
139
  }
@@ -166,6 +172,24 @@ function convertRelationshipsToIdentifiers(assortments, allAssortments) {
166
172
  }
167
173
  }
168
174
 
175
+ async function getFolderPrincipals(folder) {
176
+ const principals = [];
177
+ if (!folder.policyOwner) {
178
+ return ['INHERIT'];
179
+ }
180
+
181
+ const workspacePrincipals = await new Entities().get({
182
+ entityName: 'workspace-principal',
183
+ criteria: {workspaceId: folder.id}
184
+ });
185
+
186
+ for (const workspacePrincipal of workspacePrincipals) {
187
+ principals.push(workspacePrincipal.principalReference);
188
+ }
189
+
190
+ return principals;
191
+ }
192
+
169
193
  function deleteNonUserKeys(assortment) {
170
194
  delete assortment.name;
171
195
  delete assortment.identifier;
@@ -74,6 +74,7 @@ function parseToProjectConfiguration(projectConfigurationFromFile: ProjectConfig
74
74
  projectName: projectConfigurationFromFile.projectName,
75
75
  identifier: projectConfigurationFromFile.identifier,
76
76
  commonConfig: projectConfigurationFromFile.commonConfig,
77
+ principals: projectConfigurationFromFile.principals,
77
78
  assortments: [],
78
79
  subFolders: [],
79
80
  };
@@ -306,7 +306,7 @@ function saveData(reducedData, dir: string) {
306
306
  if(!fileLabel) {
307
307
  console.warn('skipping bad data:', item);
308
308
  }
309
- fs.writeFileSync(path.join(subDir, `${fileLabel}.yml`), yamlStr, 'utf8');
309
+ fs.writeFileSync(path.join(subDir, `${removeSlash(fileLabel)}.yml`), yamlStr, 'utf8');
310
310
  }
311
311
  } else {
312
312
  const yamlStr = yaml.dump(reducedData[key]);
@@ -314,4 +314,9 @@ function saveData(reducedData, dir: string) {
314
314
  }
315
315
 
316
316
  }
317
+ }
318
+
319
+ function removeSlash(string) {
320
+ const re = /\//gi;
321
+ return string.replace(re, '-');
317
322
  }