@firestartr/cli 1.50.1-snapshot-21 → 1.50.1-snapshot-22
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/build/index.js
CHANGED
|
@@ -289786,12 +289786,18 @@ function fromYaml(data) {
|
|
|
289786
289786
|
}
|
|
289787
289787
|
function toYaml(data, opts = {}) {
|
|
289788
289788
|
src_logger.debug('opts', opts);
|
|
289789
|
-
const result = yaml_dist.stringify(data
|
|
289789
|
+
const result = yaml_dist.stringify(data, {
|
|
289790
|
+
defaultKeyType: 'PLAIN',
|
|
289791
|
+
defaultStringType: 'QUOTE_DOUBLE',
|
|
289792
|
+
});
|
|
289790
289793
|
return result;
|
|
289791
289794
|
}
|
|
289792
289795
|
function dumpYaml(data) {
|
|
289793
289796
|
src_logger.debug('Dumping object data to YAML %O', data);
|
|
289794
|
-
return yaml_dist.stringify(data
|
|
289797
|
+
return yaml_dist.stringify(data, {
|
|
289798
|
+
defaultKeyType: 'PLAIN',
|
|
289799
|
+
defaultStringType: 'QUOTE_DOUBLE',
|
|
289800
|
+
});
|
|
289795
289801
|
}
|
|
289796
289802
|
|
|
289797
289803
|
// EXTERNAL MODULE: external "child_process"
|
|
@@ -295731,6 +295737,186 @@ function dist_bundle_paginateRest(octokit) {
|
|
|
295731
295737
|
dist_bundle_paginateRest.VERSION = _octokit_plugin_paginate_rest_dist_bundle_VERSION;
|
|
295732
295738
|
|
|
295733
295739
|
|
|
295740
|
+
;// CONCATENATED MODULE: ../github/node_modules/@octokit/plugin-paginate-graphql/dist-bundle/index.js
|
|
295741
|
+
// pkg/dist-src/errors.js
|
|
295742
|
+
var generateMessage = (path, cursorValue) => `The cursor at "${path.join(
|
|
295743
|
+
","
|
|
295744
|
+
)}" did not change its value "${cursorValue}" after a page transition. Please make sure your that your query is set up correctly.`;
|
|
295745
|
+
var MissingCursorChange = class extends Error {
|
|
295746
|
+
constructor(pageInfo, cursorValue) {
|
|
295747
|
+
super(generateMessage(pageInfo.pathInQuery, cursorValue));
|
|
295748
|
+
this.pageInfo = pageInfo;
|
|
295749
|
+
this.cursorValue = cursorValue;
|
|
295750
|
+
if (Error.captureStackTrace) {
|
|
295751
|
+
Error.captureStackTrace(this, this.constructor);
|
|
295752
|
+
}
|
|
295753
|
+
}
|
|
295754
|
+
name = "MissingCursorChangeError";
|
|
295755
|
+
};
|
|
295756
|
+
var MissingPageInfo = class extends Error {
|
|
295757
|
+
constructor(response) {
|
|
295758
|
+
super(
|
|
295759
|
+
`No pageInfo property found in response. Please make sure to specify the pageInfo in your query. Response-Data: ${JSON.stringify(
|
|
295760
|
+
response,
|
|
295761
|
+
null,
|
|
295762
|
+
2
|
|
295763
|
+
)}`
|
|
295764
|
+
);
|
|
295765
|
+
this.response = response;
|
|
295766
|
+
if (Error.captureStackTrace) {
|
|
295767
|
+
Error.captureStackTrace(this, this.constructor);
|
|
295768
|
+
}
|
|
295769
|
+
}
|
|
295770
|
+
name = "MissingPageInfo";
|
|
295771
|
+
};
|
|
295772
|
+
|
|
295773
|
+
// pkg/dist-src/object-helpers.js
|
|
295774
|
+
var isObject = (value) => Object.prototype.toString.call(value) === "[object Object]";
|
|
295775
|
+
function findPaginatedResourcePath(responseData) {
|
|
295776
|
+
const paginatedResourcePath = deepFindPathToProperty(
|
|
295777
|
+
responseData,
|
|
295778
|
+
"pageInfo"
|
|
295779
|
+
);
|
|
295780
|
+
if (paginatedResourcePath.length === 0) {
|
|
295781
|
+
throw new MissingPageInfo(responseData);
|
|
295782
|
+
}
|
|
295783
|
+
return paginatedResourcePath;
|
|
295784
|
+
}
|
|
295785
|
+
var deepFindPathToProperty = (object, searchProp, path = []) => {
|
|
295786
|
+
for (const key of Object.keys(object)) {
|
|
295787
|
+
const currentPath = [...path, key];
|
|
295788
|
+
const currentValue = object[key];
|
|
295789
|
+
if (isObject(currentValue)) {
|
|
295790
|
+
if (currentValue.hasOwnProperty(searchProp)) {
|
|
295791
|
+
return currentPath;
|
|
295792
|
+
}
|
|
295793
|
+
const result = deepFindPathToProperty(
|
|
295794
|
+
currentValue,
|
|
295795
|
+
searchProp,
|
|
295796
|
+
currentPath
|
|
295797
|
+
);
|
|
295798
|
+
if (result.length > 0) {
|
|
295799
|
+
return result;
|
|
295800
|
+
}
|
|
295801
|
+
}
|
|
295802
|
+
}
|
|
295803
|
+
return [];
|
|
295804
|
+
};
|
|
295805
|
+
var dist_bundle_get = (object, path) => {
|
|
295806
|
+
return path.reduce((current, nextProperty) => current[nextProperty], object);
|
|
295807
|
+
};
|
|
295808
|
+
var set = (object, path, mutator) => {
|
|
295809
|
+
const lastProperty = path[path.length - 1];
|
|
295810
|
+
const parentPath = [...path].slice(0, -1);
|
|
295811
|
+
const parent = dist_bundle_get(object, parentPath);
|
|
295812
|
+
if (typeof mutator === "function") {
|
|
295813
|
+
parent[lastProperty] = mutator(parent[lastProperty]);
|
|
295814
|
+
} else {
|
|
295815
|
+
parent[lastProperty] = mutator;
|
|
295816
|
+
}
|
|
295817
|
+
};
|
|
295818
|
+
|
|
295819
|
+
// pkg/dist-src/extract-page-info.js
|
|
295820
|
+
var extractPageInfos = (responseData) => {
|
|
295821
|
+
const pageInfoPath = findPaginatedResourcePath(responseData);
|
|
295822
|
+
return {
|
|
295823
|
+
pathInQuery: pageInfoPath,
|
|
295824
|
+
pageInfo: dist_bundle_get(responseData, [...pageInfoPath, "pageInfo"])
|
|
295825
|
+
};
|
|
295826
|
+
};
|
|
295827
|
+
|
|
295828
|
+
// pkg/dist-src/page-info.js
|
|
295829
|
+
var isForwardSearch = (givenPageInfo) => {
|
|
295830
|
+
return givenPageInfo.hasOwnProperty("hasNextPage");
|
|
295831
|
+
};
|
|
295832
|
+
var getCursorFrom = (pageInfo) => isForwardSearch(pageInfo) ? pageInfo.endCursor : pageInfo.startCursor;
|
|
295833
|
+
var hasAnotherPage = (pageInfo) => isForwardSearch(pageInfo) ? pageInfo.hasNextPage : pageInfo.hasPreviousPage;
|
|
295834
|
+
|
|
295835
|
+
// pkg/dist-src/iterator.js
|
|
295836
|
+
var createIterator = (octokit) => {
|
|
295837
|
+
return (query, initialParameters = {}) => {
|
|
295838
|
+
let nextPageExists = true;
|
|
295839
|
+
let parameters = { ...initialParameters };
|
|
295840
|
+
return {
|
|
295841
|
+
[Symbol.asyncIterator]: () => ({
|
|
295842
|
+
async next() {
|
|
295843
|
+
if (!nextPageExists) return { done: true, value: {} };
|
|
295844
|
+
const response = await octokit.graphql(
|
|
295845
|
+
query,
|
|
295846
|
+
parameters
|
|
295847
|
+
);
|
|
295848
|
+
const pageInfoContext = extractPageInfos(response);
|
|
295849
|
+
const nextCursorValue = getCursorFrom(pageInfoContext.pageInfo);
|
|
295850
|
+
nextPageExists = hasAnotherPage(pageInfoContext.pageInfo);
|
|
295851
|
+
if (nextPageExists && nextCursorValue === parameters.cursor) {
|
|
295852
|
+
throw new MissingCursorChange(pageInfoContext, nextCursorValue);
|
|
295853
|
+
}
|
|
295854
|
+
parameters = {
|
|
295855
|
+
...parameters,
|
|
295856
|
+
cursor: nextCursorValue
|
|
295857
|
+
};
|
|
295858
|
+
return { done: false, value: response };
|
|
295859
|
+
}
|
|
295860
|
+
})
|
|
295861
|
+
};
|
|
295862
|
+
};
|
|
295863
|
+
};
|
|
295864
|
+
|
|
295865
|
+
// pkg/dist-src/merge-responses.js
|
|
295866
|
+
var mergeResponses = (response1, response2) => {
|
|
295867
|
+
if (Object.keys(response1).length === 0) {
|
|
295868
|
+
return Object.assign(response1, response2);
|
|
295869
|
+
}
|
|
295870
|
+
const path = findPaginatedResourcePath(response1);
|
|
295871
|
+
const nodesPath = [...path, "nodes"];
|
|
295872
|
+
const newNodes = dist_bundle_get(response2, nodesPath);
|
|
295873
|
+
if (newNodes) {
|
|
295874
|
+
set(response1, nodesPath, (values) => {
|
|
295875
|
+
return [...values, ...newNodes];
|
|
295876
|
+
});
|
|
295877
|
+
}
|
|
295878
|
+
const edgesPath = [...path, "edges"];
|
|
295879
|
+
const newEdges = dist_bundle_get(response2, edgesPath);
|
|
295880
|
+
if (newEdges) {
|
|
295881
|
+
set(response1, edgesPath, (values) => {
|
|
295882
|
+
return [...values, ...newEdges];
|
|
295883
|
+
});
|
|
295884
|
+
}
|
|
295885
|
+
const pageInfoPath = [...path, "pageInfo"];
|
|
295886
|
+
set(response1, pageInfoPath, dist_bundle_get(response2, pageInfoPath));
|
|
295887
|
+
return response1;
|
|
295888
|
+
};
|
|
295889
|
+
|
|
295890
|
+
// pkg/dist-src/paginate.js
|
|
295891
|
+
var createPaginate = (octokit) => {
|
|
295892
|
+
const iterator = createIterator(octokit);
|
|
295893
|
+
return async (query, initialParameters = {}) => {
|
|
295894
|
+
let mergedResponse = {};
|
|
295895
|
+
for await (const response of iterator(
|
|
295896
|
+
query,
|
|
295897
|
+
initialParameters
|
|
295898
|
+
)) {
|
|
295899
|
+
mergedResponse = mergeResponses(mergedResponse, response);
|
|
295900
|
+
}
|
|
295901
|
+
return mergedResponse;
|
|
295902
|
+
};
|
|
295903
|
+
};
|
|
295904
|
+
|
|
295905
|
+
// pkg/dist-src/version.js
|
|
295906
|
+
var plugin_paginate_graphql_dist_bundle_VERSION = "0.0.0-development";
|
|
295907
|
+
|
|
295908
|
+
// pkg/dist-src/index.js
|
|
295909
|
+
function paginateGraphQL(octokit) {
|
|
295910
|
+
return {
|
|
295911
|
+
graphql: Object.assign(octokit.graphql, {
|
|
295912
|
+
paginate: Object.assign(createPaginate(octokit), {
|
|
295913
|
+
iterator: createIterator(octokit)
|
|
295914
|
+
})
|
|
295915
|
+
})
|
|
295916
|
+
};
|
|
295917
|
+
}
|
|
295918
|
+
|
|
295919
|
+
|
|
295734
295920
|
;// CONCATENATED MODULE: ../../node_modules/@octokit/oauth-methods/dist-bundle/index.js
|
|
295735
295921
|
// pkg/dist-src/version.js
|
|
295736
295922
|
var oauth_methods_dist_bundle_VERSION = "0.0.0-development";
|
|
@@ -297618,7 +297804,7 @@ async function dist_node_get(cache, options) {
|
|
|
297618
297804
|
repositorySelection
|
|
297619
297805
|
};
|
|
297620
297806
|
}
|
|
297621
|
-
async function
|
|
297807
|
+
async function dist_node_set(cache, options, data) {
|
|
297622
297808
|
const key = optionsToCacheKey(options);
|
|
297623
297809
|
const permissionsString = options.permissions ? "" : Object.keys(data.permissions).map(
|
|
297624
297810
|
(name) => `${name}${data.permissions[name] === "write" ? "!" : ""}`
|
|
@@ -297793,7 +297979,7 @@ async function getInstallationAuthenticationImpl(state, options, request) {
|
|
|
297793
297979
|
if (singleFileName) {
|
|
297794
297980
|
Object.assign(payload, { singleFileName });
|
|
297795
297981
|
}
|
|
297796
|
-
await
|
|
297982
|
+
await dist_node_set(state.cache, options, cacheOptions);
|
|
297797
297983
|
const cacheData = {
|
|
297798
297984
|
installationId: options.installationId,
|
|
297799
297985
|
token,
|
|
@@ -298057,6 +298243,7 @@ async function checkIfInstalledForOrg(org = 'default') {
|
|
|
298057
298243
|
|
|
298058
298244
|
|
|
298059
298245
|
|
|
298246
|
+
|
|
298060
298247
|
const generateGithubAppToken = async (config) => {
|
|
298061
298248
|
try {
|
|
298062
298249
|
const { appId, privateKey, installationOrgId } = config;
|
|
@@ -298102,7 +298289,7 @@ async function getOctokitForOrg(org, paginated = false, genGithubAppToken = gene
|
|
|
298102
298289
|
});
|
|
298103
298290
|
const options = { auth: auth };
|
|
298104
298291
|
if (paginated) {
|
|
298105
|
-
options.plugins = [dist_bundle_paginateRest];
|
|
298292
|
+
options.plugins = [dist_bundle_paginateRest, paginateGraphQL];
|
|
298106
298293
|
}
|
|
298107
298294
|
return new dist_src_Octokit(options);
|
|
298108
298295
|
}
|
|
@@ -298169,6 +298356,54 @@ async function getOrgInfo(org) {
|
|
|
298169
298356
|
const orgInfo = await octokit.orgs.get({ org });
|
|
298170
298357
|
return orgInfo.data;
|
|
298171
298358
|
}
|
|
298359
|
+
async function getOrgTeamsDirectAccess(org) {
|
|
298360
|
+
github_src_logger.info(`Getting teams for org ${org}`);
|
|
298361
|
+
const octokit = await getOctokitForOrg(org);
|
|
298362
|
+
const response = await octokit.graphql(`{
|
|
298363
|
+
organization(login: "${org}") {
|
|
298364
|
+
teams(first: 30) {
|
|
298365
|
+
nodes {
|
|
298366
|
+
id
|
|
298367
|
+
name
|
|
298368
|
+
repositories {
|
|
298369
|
+
edges {
|
|
298370
|
+
permission
|
|
298371
|
+
node {
|
|
298372
|
+
name
|
|
298373
|
+
}
|
|
298374
|
+
}
|
|
298375
|
+
}
|
|
298376
|
+
}
|
|
298377
|
+
}
|
|
298378
|
+
}
|
|
298379
|
+
}`);
|
|
298380
|
+
return transformGraphQLResponse(response);
|
|
298381
|
+
}
|
|
298382
|
+
;
|
|
298383
|
+
function transformGraphQLResponse(response) {
|
|
298384
|
+
const teams = response?.data?.organization?.teams?.nodes;
|
|
298385
|
+
if (!teams)
|
|
298386
|
+
return {};
|
|
298387
|
+
let result = {
|
|
298388
|
+
repositories: {},
|
|
298389
|
+
teams: {},
|
|
298390
|
+
};
|
|
298391
|
+
teams.forEach((team) => {
|
|
298392
|
+
const teamName = team.name;
|
|
298393
|
+
const teamId = team.id;
|
|
298394
|
+
result.teams[teamName] = { id: teamId };
|
|
298395
|
+
const repositories = team.repositories.edges;
|
|
298396
|
+
repositories.forEach((repoEdge) => {
|
|
298397
|
+
const repoName = repoEdge.node.name;
|
|
298398
|
+
const permission = repoEdge.permission;
|
|
298399
|
+
if (!result.repositories[repoName]) {
|
|
298400
|
+
result.repositories[repoName] = {};
|
|
298401
|
+
}
|
|
298402
|
+
result.repositories[repoName][teamName] = permission;
|
|
298403
|
+
});
|
|
298404
|
+
});
|
|
298405
|
+
return result;
|
|
298406
|
+
}
|
|
298172
298407
|
async function getOrgPlanName(org) {
|
|
298173
298408
|
github_src_logger.info(`Getting plan for org ${org}`);
|
|
298174
298409
|
const orgInfo = await getOrgInfo(org);
|
|
@@ -298187,6 +298422,7 @@ async function doPaginatedRequest(options) {
|
|
|
298187
298422
|
validateMember,
|
|
298188
298423
|
getUserRoleInOrg,
|
|
298189
298424
|
getOrgInfo,
|
|
298425
|
+
getOrgTeamsDirectAccess,
|
|
298190
298426
|
getOrgPlanName,
|
|
298191
298427
|
});
|
|
298192
298428
|
|
|
@@ -309585,10 +309821,19 @@ class GithubDecanter extends decanter_base {
|
|
|
309585
309821
|
}
|
|
309586
309822
|
}
|
|
309587
309823
|
|
|
309824
|
+
;// CONCATENATED MODULE: ../importer/src/logger.ts
|
|
309825
|
+
|
|
309826
|
+
/* harmony default export */ const importer_src_logger = (catalog_common.logger);
|
|
309827
|
+
|
|
309588
309828
|
;// CONCATENATED MODULE: ../importer/src/decanter/gh/github_group.ts
|
|
309589
309829
|
|
|
309590
309830
|
|
|
309591
309831
|
|
|
309832
|
+
|
|
309833
|
+
|
|
309834
|
+
|
|
309835
|
+
|
|
309836
|
+
|
|
309592
309837
|
class GroupGithubDecanter extends GithubDecanter {
|
|
309593
309838
|
constructor() {
|
|
309594
309839
|
super(...arguments);
|
|
@@ -309598,7 +309843,7 @@ class GroupGithubDecanter extends GithubDecanter {
|
|
|
309598
309843
|
this.claim = {
|
|
309599
309844
|
kind: this.claimKind,
|
|
309600
309845
|
version: this.VERSION(),
|
|
309601
|
-
name: this.data.groupDetails.
|
|
309846
|
+
name: this.data.groupDetails.slug,
|
|
309602
309847
|
description: this.data.groupDetails.description,
|
|
309603
309848
|
type: 'business-unit',
|
|
309604
309849
|
};
|
|
@@ -309622,7 +309867,9 @@ class GroupGithubDecanter extends GithubDecanter {
|
|
|
309622
309867
|
__decantProviders() {
|
|
309623
309868
|
this.__patchClaim({
|
|
309624
309869
|
op: 'add',
|
|
309625
|
-
value: {
|
|
309870
|
+
value: {
|
|
309871
|
+
github: { name: `${this.data.groupDetails.name}`, org: this.org },
|
|
309872
|
+
},
|
|
309626
309873
|
path: '/providers',
|
|
309627
309874
|
});
|
|
309628
309875
|
}
|
|
@@ -309630,13 +309877,13 @@ class GroupGithubDecanter extends GithubDecanter {
|
|
|
309630
309877
|
if (this.data.groupDetails.parent) {
|
|
309631
309878
|
this.__patchClaim({
|
|
309632
309879
|
op: 'add',
|
|
309633
|
-
value: `group:${this.data.groupDetails.parent.
|
|
309880
|
+
value: `group:${this.data.groupDetails.parent.slug}`,
|
|
309634
309881
|
path: '/parent',
|
|
309635
309882
|
});
|
|
309636
309883
|
}
|
|
309637
309884
|
}
|
|
309638
309885
|
async __gatherMembers() {
|
|
309639
|
-
this.data['members'] = (await github_0.team.getTeamMembers(this.data.groupDetails.
|
|
309886
|
+
this.data['members'] = (await github_0.team.getTeamMembers(this.data.groupDetails.slug, this.org)).map((member) => {
|
|
309640
309887
|
return { name: member.login, role: member.role };
|
|
309641
309888
|
});
|
|
309642
309889
|
}
|
|
@@ -309645,28 +309892,43 @@ class GroupGithubDecanter extends GithubDecanter {
|
|
|
309645
309892
|
return this.__validateEqual(members, this.data.members);
|
|
309646
309893
|
}
|
|
309647
309894
|
async __adaptInitializerBase(_claim) {
|
|
309648
|
-
|
|
309649
|
-
|
|
309650
|
-
|
|
309651
|
-
|
|
309652
|
-
|
|
309653
|
-
|
|
309654
|
-
|
|
309655
|
-
|
|
309656
|
-
|
|
309657
|
-
|
|
309895
|
+
let githubGroupDefaultsFilePath;
|
|
309896
|
+
try {
|
|
309897
|
+
githubGroupDefaultsFilePath = external_path_.join(getConfigPath(), 'resources', 'defaults_github_group.yaml');
|
|
309898
|
+
}
|
|
309899
|
+
catch (e) {
|
|
309900
|
+
importer_src_logger.warn('No config path set, using built-in defaults');
|
|
309901
|
+
githubGroupDefaultsFilePath = '';
|
|
309902
|
+
}
|
|
309903
|
+
let adapter;
|
|
309904
|
+
if (githubGroupDefaultsFilePath &&
|
|
309905
|
+
external_fs_.existsSync(githubGroupDefaultsFilePath)) {
|
|
309906
|
+
adapter = catalog_common.io.fromYaml(external_fs_.readFileSync(githubGroupDefaultsFilePath, 'utf-8'));
|
|
309907
|
+
}
|
|
309908
|
+
else {
|
|
309909
|
+
adapter = {
|
|
309910
|
+
name: 'base',
|
|
309911
|
+
apiVersion: 'firestartr.dev/v1',
|
|
309912
|
+
kind: 'FirestartrGithubGroup',
|
|
309913
|
+
defaultValues: {
|
|
309914
|
+
context: {
|
|
309915
|
+
backend: {
|
|
309916
|
+
ref: {
|
|
309917
|
+
kind: 'FirestartrProviderConfig',
|
|
309918
|
+
name: 'firestartr-terraform-state',
|
|
309919
|
+
},
|
|
309658
309920
|
},
|
|
309659
|
-
|
|
309660
|
-
|
|
309661
|
-
|
|
309662
|
-
|
|
309663
|
-
|
|
309921
|
+
provider: {
|
|
309922
|
+
ref: {
|
|
309923
|
+
kind: 'FirestartrProviderConfig',
|
|
309924
|
+
name: 'github-app',
|
|
309925
|
+
},
|
|
309664
309926
|
},
|
|
309665
309927
|
},
|
|
309666
309928
|
},
|
|
309667
|
-
}
|
|
309668
|
-
}
|
|
309669
|
-
return new InitializerDefault(
|
|
309929
|
+
};
|
|
309930
|
+
}
|
|
309931
|
+
return new InitializerDefault(adapter);
|
|
309670
309932
|
}
|
|
309671
309933
|
__validateKind(cr) {
|
|
309672
309934
|
return true;
|
|
@@ -309746,9 +310008,9 @@ class GroupCollectionGithubDecanter extends GithubDecanter {
|
|
|
309746
310008
|
const groups = [];
|
|
309747
310009
|
const teamMaps = {};
|
|
309748
310010
|
teamList.forEach((team) => {
|
|
309749
|
-
teamMaps[team.
|
|
310011
|
+
teamMaps[team.slug] = team;
|
|
309750
310012
|
});
|
|
309751
|
-
const filteredGroups = await this.filter(GroupCollectionGithubDecanter.collectionKind, filters, teamList.map((team) => team.
|
|
310013
|
+
const filteredGroups = await this.filter(GroupCollectionGithubDecanter.collectionKind, filters, teamList.map((team) => team.slug));
|
|
309752
310014
|
for (const team of filteredGroups) {
|
|
309753
310015
|
groups.push(new GroupGithubDecanter({ groupDetails: teamMaps[team] }, this.org));
|
|
309754
310016
|
}
|
|
@@ -309763,6 +310025,11 @@ applyCollectionMixins(GroupCollectionGithubDecanter);
|
|
|
309763
310025
|
|
|
309764
310026
|
|
|
309765
310027
|
|
|
310028
|
+
|
|
310029
|
+
|
|
310030
|
+
|
|
310031
|
+
|
|
310032
|
+
|
|
309766
310033
|
class MemberGithubDecanter extends GithubDecanter {
|
|
309767
310034
|
constructor() {
|
|
309768
310035
|
super(...arguments);
|
|
@@ -309800,28 +310067,43 @@ class MemberGithubDecanter extends GithubDecanter {
|
|
|
309800
310067
|
});
|
|
309801
310068
|
}
|
|
309802
310069
|
async __adaptInitializerBase(_claim) {
|
|
309803
|
-
|
|
309804
|
-
|
|
309805
|
-
|
|
309806
|
-
|
|
309807
|
-
|
|
309808
|
-
|
|
309809
|
-
|
|
309810
|
-
|
|
309811
|
-
|
|
309812
|
-
|
|
310070
|
+
let githubMemberDefaultsFilePath;
|
|
310071
|
+
try {
|
|
310072
|
+
githubMemberDefaultsFilePath = external_path_.join(getConfigPath(), 'resources', 'defaults_github_membership.yaml');
|
|
310073
|
+
}
|
|
310074
|
+
catch (e) {
|
|
310075
|
+
importer_src_logger.warn('No config path set, using built-in defaults');
|
|
310076
|
+
githubMemberDefaultsFilePath = '';
|
|
310077
|
+
}
|
|
310078
|
+
let adapter;
|
|
310079
|
+
if (githubMemberDefaultsFilePath &&
|
|
310080
|
+
external_fs_.existsSync(githubMemberDefaultsFilePath)) {
|
|
310081
|
+
adapter = catalog_common.io.fromYaml(external_fs_.readFileSync(githubMemberDefaultsFilePath, 'utf-8'));
|
|
310082
|
+
}
|
|
310083
|
+
else {
|
|
310084
|
+
adapter = {
|
|
310085
|
+
name: 'base',
|
|
310086
|
+
apiVersion: 'firestartr.dev/v1',
|
|
310087
|
+
kind: 'FirestartrGithubMembership',
|
|
310088
|
+
defaultValues: {
|
|
310089
|
+
context: {
|
|
310090
|
+
backend: {
|
|
310091
|
+
ref: {
|
|
310092
|
+
kind: 'FirestartrProviderConfig',
|
|
310093
|
+
name: 'firestartr-terraform-state',
|
|
310094
|
+
},
|
|
309813
310095
|
},
|
|
309814
|
-
|
|
309815
|
-
|
|
309816
|
-
|
|
309817
|
-
|
|
309818
|
-
|
|
310096
|
+
provider: {
|
|
310097
|
+
ref: {
|
|
310098
|
+
kind: 'FirestartrProviderConfig',
|
|
310099
|
+
name: 'github-app',
|
|
310100
|
+
},
|
|
309819
310101
|
},
|
|
309820
310102
|
},
|
|
309821
310103
|
},
|
|
309822
|
-
}
|
|
309823
|
-
}
|
|
309824
|
-
return new InitializerDefault(
|
|
310104
|
+
};
|
|
310105
|
+
}
|
|
310106
|
+
return new InitializerDefault(adapter);
|
|
309825
310107
|
}
|
|
309826
310108
|
}
|
|
309827
310109
|
|
|
@@ -309854,15 +310136,21 @@ applyCollectionMixins(MemberCollectionGithubDecanter);
|
|
|
309854
310136
|
|
|
309855
310137
|
|
|
309856
310138
|
|
|
310139
|
+
|
|
310140
|
+
|
|
310141
|
+
|
|
310142
|
+
|
|
310143
|
+
|
|
309857
310144
|
const TYPE_MAP = {
|
|
309858
310145
|
User: 'user',
|
|
309859
310146
|
Team: 'group',
|
|
309860
310147
|
Organization: 'org',
|
|
309861
310148
|
};
|
|
309862
310149
|
class RepoGithubDecanter extends GithubDecanter {
|
|
309863
|
-
constructor() {
|
|
309864
|
-
super(
|
|
310150
|
+
constructor(data, org, githubTeams = {}) {
|
|
310151
|
+
super(data, org);
|
|
309865
310152
|
this.claimKind = 'ComponentClaim';
|
|
310153
|
+
this.githubTeams = githubTeams;
|
|
309866
310154
|
}
|
|
309867
310155
|
__decantStart() {
|
|
309868
310156
|
this.claim = {
|
|
@@ -309870,7 +310158,6 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
309870
310158
|
version: this.VERSION(),
|
|
309871
310159
|
type: 'service',
|
|
309872
310160
|
lifecycle: 'production',
|
|
309873
|
-
system: `system:${this.org}-system`,
|
|
309874
310161
|
name: this.data.repoDetails.name,
|
|
309875
310162
|
};
|
|
309876
310163
|
}
|
|
@@ -309924,6 +310211,9 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
309924
310211
|
}
|
|
309925
310212
|
}
|
|
309926
310213
|
__decantRelations() {
|
|
310214
|
+
importer_src_logger.debug("Decanting repo's relations...");
|
|
310215
|
+
console.dir(this.data.teamsAndMembers, { depth: null });
|
|
310216
|
+
importer_src_logger.debug("Decanting maintainers...");
|
|
309927
310217
|
const directMaintainers = this.data.teamsAndMembers.directMembers
|
|
309928
310218
|
.filter((member) => member.role === 'maintain')
|
|
309929
310219
|
.map((member) => {
|
|
@@ -309949,6 +310239,7 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
309949
310239
|
path: '/maintainedBy',
|
|
309950
310240
|
});
|
|
309951
310241
|
}
|
|
310242
|
+
importer_src_logger.debug("Decanting admins...");
|
|
309952
310243
|
const directAdmins = this.data.teamsAndMembers.directMembers
|
|
309953
310244
|
.filter((member) => member.role === 'admin')
|
|
309954
310245
|
.map((member) => {
|
|
@@ -309984,6 +310275,7 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
309984
310275
|
path: '/providers/github/overrides',
|
|
309985
310276
|
});
|
|
309986
310277
|
}
|
|
310278
|
+
importer_src_logger.debug("Decanting writers...");
|
|
309987
310279
|
const directWriters = this.data.teamsAndMembers.directMembers
|
|
309988
310280
|
.filter((member) => member.role === 'push')
|
|
309989
310281
|
.map((member) => {
|
|
@@ -310008,6 +310300,7 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
310008
310300
|
path: '/providers/github/overrides',
|
|
310009
310301
|
});
|
|
310010
310302
|
}
|
|
310303
|
+
importer_src_logger.debug("Decanting readers...");
|
|
310011
310304
|
const directReaders = this.data.teamsAndMembers.directMembers
|
|
310012
310305
|
.filter((member) => member.role === 'pull')
|
|
310013
310306
|
.map((member) => {
|
|
@@ -310036,13 +310329,16 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
310036
310329
|
async __gatherRepoTeamsAndMembers() {
|
|
310037
310330
|
this.data['teamsAndMembers'] = {};
|
|
310038
310331
|
const directMembers = (await github_0.repo.getCollaborators(this.data.repoDetails.owner.login, this.data.repoDetails.name, 'direct')).map((member) => {
|
|
310039
|
-
return { name: member.login, role: member.role_name };
|
|
310332
|
+
return { name: member.login, slug: member.slug, role: member.role_name };
|
|
310040
310333
|
});
|
|
310041
310334
|
const outsideMembers = (await github_0.repo.getCollaborators(this.data.repoDetails.owner.login, this.data.repoDetails.name, 'outside')).map((member) => {
|
|
310042
310335
|
return { name: member.login, role: member.role_name };
|
|
310043
310336
|
});
|
|
310044
|
-
const teams =
|
|
310045
|
-
return {
|
|
310337
|
+
const teams = Object.keys(this.githubTeams).map((teamName) => {
|
|
310338
|
+
return {
|
|
310339
|
+
name: teamName,
|
|
310340
|
+
role: this.githubTeams[teamName].toLowerCase(),
|
|
310341
|
+
};
|
|
310046
310342
|
});
|
|
310047
310343
|
this.data['teamsAndMembers']['teams'] = teams;
|
|
310048
310344
|
this.data['teamsAndMembers']['directMembers'] = directMembers;
|
|
@@ -310108,59 +310404,74 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
310108
310404
|
return null;
|
|
310109
310405
|
}
|
|
310110
310406
|
async __adaptInitializerBase(_claim) {
|
|
310111
|
-
|
|
310112
|
-
|
|
310113
|
-
|
|
310114
|
-
|
|
310115
|
-
|
|
310116
|
-
|
|
310117
|
-
|
|
310118
|
-
|
|
310119
|
-
|
|
310120
|
-
|
|
310407
|
+
let githubRepoDefaultsFilePath;
|
|
310408
|
+
try {
|
|
310409
|
+
githubRepoDefaultsFilePath = external_path_.join(getConfigPath(), 'resources', 'defaults_github_repository.yaml');
|
|
310410
|
+
}
|
|
310411
|
+
catch (e) {
|
|
310412
|
+
importer_src_logger.warn('No config path set, using built-in defaults');
|
|
310413
|
+
githubRepoDefaultsFilePath = '';
|
|
310414
|
+
}
|
|
310415
|
+
let adapter;
|
|
310416
|
+
if (githubRepoDefaultsFilePath &&
|
|
310417
|
+
external_fs_.existsSync(githubRepoDefaultsFilePath)) {
|
|
310418
|
+
adapter = catalog_common.io.fromYaml(external_fs_.readFileSync(githubRepoDefaultsFilePath, 'utf-8'));
|
|
310419
|
+
}
|
|
310420
|
+
else {
|
|
310421
|
+
adapter = {
|
|
310422
|
+
name: 'base',
|
|
310423
|
+
apiVersion: 'firestartr.dev/v1',
|
|
310424
|
+
kind: 'FirestartrGithubRepository',
|
|
310425
|
+
defaultValues: {
|
|
310426
|
+
context: {
|
|
310427
|
+
backend: {
|
|
310428
|
+
ref: {
|
|
310429
|
+
kind: 'FirestartrProviderConfig',
|
|
310430
|
+
name: 'firestartr-terraform-state',
|
|
310431
|
+
},
|
|
310121
310432
|
},
|
|
310122
|
-
|
|
310123
|
-
|
|
310124
|
-
|
|
310125
|
-
|
|
310126
|
-
|
|
310433
|
+
provider: {
|
|
310434
|
+
ref: {
|
|
310435
|
+
kind: 'FirestartrProviderConfig',
|
|
310436
|
+
name: 'github-app',
|
|
310437
|
+
},
|
|
310127
310438
|
},
|
|
310128
310439
|
},
|
|
310129
|
-
|
|
310130
|
-
name: this.data.repoDetails.name,
|
|
310131
|
-
description: this.data.repoDetails.description,
|
|
310132
|
-
org: this.org,
|
|
310133
|
-
firestartr: {
|
|
310134
|
-
technology: { stack: 'none', version: 'none' },
|
|
310135
|
-
},
|
|
310136
|
-
repo: {
|
|
310440
|
+
name: this.data.repoDetails.name,
|
|
310137
310441
|
description: this.data.repoDetails.description,
|
|
310138
|
-
|
|
310139
|
-
|
|
310140
|
-
|
|
310141
|
-
|
|
310142
|
-
|
|
310143
|
-
|
|
310144
|
-
|
|
310145
|
-
|
|
310146
|
-
|
|
310147
|
-
|
|
310148
|
-
|
|
310149
|
-
|
|
310150
|
-
|
|
310151
|
-
|
|
310152
|
-
|
|
310153
|
-
|
|
310154
|
-
:
|
|
310155
|
-
|
|
310156
|
-
|
|
310157
|
-
|
|
310158
|
-
|
|
310159
|
-
|
|
310442
|
+
org: this.org,
|
|
310443
|
+
firestartr: {
|
|
310444
|
+
technology: { stack: 'none', version: 'none' },
|
|
310445
|
+
},
|
|
310446
|
+
repo: {
|
|
310447
|
+
description: this.data.repoDetails.description,
|
|
310448
|
+
allowMergeCommit: this.data.repoDetails.allow_merge_commit,
|
|
310449
|
+
allowSquashMerge: this.data.repoDetails.allow_squash_merge,
|
|
310450
|
+
allowRebaseMerge: this.data.repoDetails.allow_rebase_merge,
|
|
310451
|
+
allowAutoMerge: this.data.repoDetails.allow_auto_merge,
|
|
310452
|
+
deleteBranchOnMerge: this.data.repoDetails.delete_branch_on_merge,
|
|
310453
|
+
autoInit: true,
|
|
310454
|
+
archiveOnDestroy: true,
|
|
310455
|
+
allowUpdateBranch: this.data.repoDetails.allow_update_branch,
|
|
310456
|
+
hasIssues: this.data.repoDetails.has_issues,
|
|
310457
|
+
visibility: this.data.repoDetails.visibility,
|
|
310458
|
+
defaultBranch: this.data.repoDetails.default_branch,
|
|
310459
|
+
},
|
|
310460
|
+
permissions: [],
|
|
310461
|
+
actions: {
|
|
310462
|
+
oidc: this.data.oidc.use_default
|
|
310463
|
+
? undefined
|
|
310464
|
+
: {
|
|
310465
|
+
useDefault: this.data.oidc.use_default,
|
|
310466
|
+
includeClaimKeys: this.data.oidc.include_claim_keys
|
|
310467
|
+
? this.data.oidc.include_claim_keys
|
|
310468
|
+
: [],
|
|
310469
|
+
},
|
|
310470
|
+
},
|
|
310160
310471
|
},
|
|
310161
|
-
}
|
|
310162
|
-
}
|
|
310163
|
-
return new InitializerDefault(
|
|
310472
|
+
};
|
|
310473
|
+
}
|
|
310474
|
+
return new InitializerDefault(adapter);
|
|
310164
310475
|
}
|
|
310165
310476
|
async __adaptOverriderRepo(_claim) {
|
|
310166
310477
|
return new GithubRepositoryOverrider();
|
|
@@ -310176,6 +310487,7 @@ class RepoCollectionGithubDecanter extends GithubDecanter {
|
|
|
310176
310487
|
if (this.IS_SKIP_SET(filters, RepoCollectionGithubDecanter.collectionKind)) {
|
|
310177
310488
|
return [];
|
|
310178
310489
|
}
|
|
310490
|
+
const { teams, repositories: directAccessRepos } = await this.github.org.getOrgTeamsDirectAccess(this.org);
|
|
310179
310491
|
let repoList = await this.github.org.getRepositoryList(this.org);
|
|
310180
310492
|
repoList = repoList.filter((el) => !el.archived);
|
|
310181
310493
|
const repoMap = {};
|
|
@@ -310186,7 +310498,7 @@ class RepoCollectionGithubDecanter extends GithubDecanter {
|
|
|
310186
310498
|
const filteredRepos = await this.filter(RepoCollectionGithubDecanter.collectionKind, filters, repoList.map((repo) => repo.name));
|
|
310187
310499
|
for (const repoName of filteredRepos) {
|
|
310188
310500
|
const repoInfo = await this.github.repo.getRepoInfo(this.org, repoName);
|
|
310189
|
-
repos.push(new RepoGithubDecanter({ repoDetails: repoInfo }, this.org));
|
|
310501
|
+
repos.push(new RepoGithubDecanter({ repoDetails: repoInfo }, this.org, directAccessRepos?.[repoName]));
|
|
310190
310502
|
}
|
|
310191
310503
|
this.data['collection'] = repos;
|
|
310192
310504
|
return repos;
|
|
@@ -310196,10 +310508,6 @@ RepoCollectionGithubDecanter.collectionKind = 'gh-repo';
|
|
|
310196
310508
|
applyCollectionMixins(RepoCollectionGithubDecanter);
|
|
310197
310509
|
/* harmony default export */ const github_repo_collection = (RepoCollectionGithubDecanter);
|
|
310198
310510
|
|
|
310199
|
-
;// CONCATENATED MODULE: ../importer/src/logger.ts
|
|
310200
|
-
|
|
310201
|
-
/* harmony default export */ const importer_src_logger = (catalog_common.logger);
|
|
310202
|
-
|
|
310203
310511
|
;// CONCATENATED MODULE: ../importer/src/decanter/index.ts
|
|
310204
310512
|
|
|
310205
310513
|
|
|
@@ -310292,7 +310600,7 @@ function getClaimPathFromCR(claimsBasePath, cr) {
|
|
|
310292
310600
|
FirestartrGithubRepository: 'components',
|
|
310293
310601
|
FirestartrGithubMembership: 'users',
|
|
310294
310602
|
};
|
|
310295
|
-
return external_path_.join(claimsBasePath, mapCrsToClaims[cr.kind], `${cr.metadata.
|
|
310603
|
+
return external_path_.join(claimsBasePath, mapCrsToClaims[cr.kind], `${cr.metadata.labels['claim-ref']}.yaml`.toLowerCase());
|
|
310296
310604
|
}
|
|
310297
310605
|
function getCrPath(crsBasePath, cr) {
|
|
310298
310606
|
return external_path_.join(crsBasePath, `${cr.kind}.${cr.metadata.name}.yaml`);
|
|
@@ -9,6 +9,7 @@ declare const _default: {
|
|
|
9
9
|
validateMember: typeof import("./src/organization").validateMember;
|
|
10
10
|
getUserRoleInOrg: typeof import("./src/organization").getUserRoleInOrg;
|
|
11
11
|
getOrgInfo: typeof import("./src/organization").getOrgInfo;
|
|
12
|
+
getOrgTeamsDirectAccess: typeof import("./src/organization").getOrgTeamsDirectAccess;
|
|
12
13
|
getOrgPlanName: typeof import("./src/organization").getOrgPlanName;
|
|
13
14
|
};
|
|
14
15
|
repo: {
|
|
@@ -4,6 +4,8 @@ export declare function getUserList(org: string, perPageEntries?: number): Promi
|
|
|
4
4
|
export declare function validateMember(username: string, org: string): Promise<any>;
|
|
5
5
|
export declare function getUserRoleInOrg(username: string, org: string): Promise<"admin" | "member" | "billing_manager">;
|
|
6
6
|
export declare function getOrgInfo(org: string): Promise<any>;
|
|
7
|
+
export declare function getOrgTeamsDirectAccess(org: string): Promise<any>;
|
|
8
|
+
export declare function transformGraphQLResponse(response: any): any;
|
|
7
9
|
export declare function getOrgPlanName(org: string): Promise<any>;
|
|
8
10
|
declare const _default: {
|
|
9
11
|
getRepositoryList: typeof getRepositoryList;
|
|
@@ -12,6 +14,7 @@ declare const _default: {
|
|
|
12
14
|
validateMember: typeof validateMember;
|
|
13
15
|
getUserRoleInOrg: typeof getUserRoleInOrg;
|
|
14
16
|
getOrgInfo: typeof getOrgInfo;
|
|
17
|
+
getOrgTeamsDirectAccess: typeof getOrgTeamsDirectAccess;
|
|
15
18
|
getOrgPlanName: typeof getOrgPlanName;
|
|
16
19
|
};
|
|
17
20
|
export default _default;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BranchStrategiesInitializer, GithubRepositoryOverrider, InitializerDefault } from 'cdk8s_renderer';
|
|
2
2
|
import { GithubDecanter } from './base';
|
|
3
3
|
export default class RepoGithubDecanter extends GithubDecanter {
|
|
4
|
+
githubTeams: any;
|
|
5
|
+
constructor(data: any, org: string, githubTeams?: any);
|
|
4
6
|
claimKind: string;
|
|
5
7
|
__decantStart(): void;
|
|
6
8
|
__decantProviders(): void;
|