@firestartr/cli 1.50.1-snapshot-26 → 1.50.1-snapshot-28
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,58 @@ 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
|
+
console.dir("--- 🚀 GraphQL response:");
|
|
298381
|
+
console.dir(response, { depth: null });
|
|
298382
|
+
return transformGraphQLResponse(response);
|
|
298383
|
+
}
|
|
298384
|
+
;
|
|
298385
|
+
function transformGraphQLResponse(response) {
|
|
298386
|
+
const teams = response?.organization?.teams?.nodes;
|
|
298387
|
+
if (!teams)
|
|
298388
|
+
return {};
|
|
298389
|
+
let result = {
|
|
298390
|
+
repositories: {},
|
|
298391
|
+
teams: {},
|
|
298392
|
+
};
|
|
298393
|
+
teams.forEach((team) => {
|
|
298394
|
+
const teamName = team.name;
|
|
298395
|
+
const teamId = team.id;
|
|
298396
|
+
result.teams[teamName] = { id: teamId };
|
|
298397
|
+
const repositories = team.repositories.edges;
|
|
298398
|
+
repositories.forEach((repoEdge) => {
|
|
298399
|
+
const repoName = repoEdge.node.name;
|
|
298400
|
+
const permission = repoEdge.permission;
|
|
298401
|
+
if (!result.repositories[repoName]) {
|
|
298402
|
+
result.repositories[repoName] = {};
|
|
298403
|
+
}
|
|
298404
|
+
result.repositories[repoName][teamName] = permission;
|
|
298405
|
+
});
|
|
298406
|
+
});
|
|
298407
|
+
console.log("--- 🚀 Transformed GraphQL response:");
|
|
298408
|
+
console.dir(result, { depth: null });
|
|
298409
|
+
return result;
|
|
298410
|
+
}
|
|
298172
298411
|
async function getOrgPlanName(org) {
|
|
298173
298412
|
github_src_logger.info(`Getting plan for org ${org}`);
|
|
298174
298413
|
const orgInfo = await getOrgInfo(org);
|
|
@@ -298187,6 +298426,7 @@ async function doPaginatedRequest(options) {
|
|
|
298187
298426
|
validateMember,
|
|
298188
298427
|
getUserRoleInOrg,
|
|
298189
298428
|
getOrgInfo,
|
|
298429
|
+
getOrgTeamsDirectAccess,
|
|
298190
298430
|
getOrgPlanName,
|
|
298191
298431
|
});
|
|
298192
298432
|
|
|
@@ -309585,10 +309825,19 @@ class GithubDecanter extends decanter_base {
|
|
|
309585
309825
|
}
|
|
309586
309826
|
}
|
|
309587
309827
|
|
|
309828
|
+
;// CONCATENATED MODULE: ../importer/src/logger.ts
|
|
309829
|
+
|
|
309830
|
+
/* harmony default export */ const importer_src_logger = (catalog_common.logger);
|
|
309831
|
+
|
|
309588
309832
|
;// CONCATENATED MODULE: ../importer/src/decanter/gh/github_group.ts
|
|
309589
309833
|
|
|
309590
309834
|
|
|
309591
309835
|
|
|
309836
|
+
|
|
309837
|
+
|
|
309838
|
+
|
|
309839
|
+
|
|
309840
|
+
|
|
309592
309841
|
class GroupGithubDecanter extends GithubDecanter {
|
|
309593
309842
|
constructor() {
|
|
309594
309843
|
super(...arguments);
|
|
@@ -309598,7 +309847,7 @@ class GroupGithubDecanter extends GithubDecanter {
|
|
|
309598
309847
|
this.claim = {
|
|
309599
309848
|
kind: this.claimKind,
|
|
309600
309849
|
version: this.VERSION(),
|
|
309601
|
-
name: this.data.groupDetails.
|
|
309850
|
+
name: this.data.groupDetails.slug,
|
|
309602
309851
|
description: this.data.groupDetails.description,
|
|
309603
309852
|
type: 'business-unit',
|
|
309604
309853
|
};
|
|
@@ -309622,7 +309871,9 @@ class GroupGithubDecanter extends GithubDecanter {
|
|
|
309622
309871
|
__decantProviders() {
|
|
309623
309872
|
this.__patchClaim({
|
|
309624
309873
|
op: 'add',
|
|
309625
|
-
value: {
|
|
309874
|
+
value: {
|
|
309875
|
+
github: { name: `${this.data.groupDetails.name}`, org: this.org },
|
|
309876
|
+
},
|
|
309626
309877
|
path: '/providers',
|
|
309627
309878
|
});
|
|
309628
309879
|
}
|
|
@@ -309630,13 +309881,13 @@ class GroupGithubDecanter extends GithubDecanter {
|
|
|
309630
309881
|
if (this.data.groupDetails.parent) {
|
|
309631
309882
|
this.__patchClaim({
|
|
309632
309883
|
op: 'add',
|
|
309633
|
-
value: `group:${this.data.groupDetails.parent.
|
|
309884
|
+
value: `group:${this.data.groupDetails.parent.slug}`,
|
|
309634
309885
|
path: '/parent',
|
|
309635
309886
|
});
|
|
309636
309887
|
}
|
|
309637
309888
|
}
|
|
309638
309889
|
async __gatherMembers() {
|
|
309639
|
-
this.data['members'] = (await github_0.team.getTeamMembers(this.data.groupDetails.
|
|
309890
|
+
this.data['members'] = (await github_0.team.getTeamMembers(this.data.groupDetails.slug, this.org)).map((member) => {
|
|
309640
309891
|
return { name: member.login, role: member.role };
|
|
309641
309892
|
});
|
|
309642
309893
|
}
|
|
@@ -309645,28 +309896,43 @@ class GroupGithubDecanter extends GithubDecanter {
|
|
|
309645
309896
|
return this.__validateEqual(members, this.data.members);
|
|
309646
309897
|
}
|
|
309647
309898
|
async __adaptInitializerBase(_claim) {
|
|
309648
|
-
|
|
309649
|
-
|
|
309650
|
-
|
|
309651
|
-
|
|
309652
|
-
|
|
309653
|
-
|
|
309654
|
-
|
|
309655
|
-
|
|
309656
|
-
|
|
309657
|
-
|
|
309899
|
+
let githubGroupDefaultsFilePath;
|
|
309900
|
+
try {
|
|
309901
|
+
githubGroupDefaultsFilePath = external_path_.join(getConfigPath(), 'resources', 'defaults_github_group.yaml');
|
|
309902
|
+
}
|
|
309903
|
+
catch (e) {
|
|
309904
|
+
importer_src_logger.warn('No config path set, using built-in defaults');
|
|
309905
|
+
githubGroupDefaultsFilePath = '';
|
|
309906
|
+
}
|
|
309907
|
+
let adapter;
|
|
309908
|
+
if (githubGroupDefaultsFilePath &&
|
|
309909
|
+
external_fs_.existsSync(githubGroupDefaultsFilePath)) {
|
|
309910
|
+
adapter = catalog_common.io.fromYaml(external_fs_.readFileSync(githubGroupDefaultsFilePath, 'utf-8'));
|
|
309911
|
+
}
|
|
309912
|
+
else {
|
|
309913
|
+
adapter = {
|
|
309914
|
+
name: 'base',
|
|
309915
|
+
apiVersion: 'firestartr.dev/v1',
|
|
309916
|
+
kind: 'FirestartrGithubGroup',
|
|
309917
|
+
defaultValues: {
|
|
309918
|
+
context: {
|
|
309919
|
+
backend: {
|
|
309920
|
+
ref: {
|
|
309921
|
+
kind: 'FirestartrProviderConfig',
|
|
309922
|
+
name: 'firestartr-terraform-state',
|
|
309923
|
+
},
|
|
309658
309924
|
},
|
|
309659
|
-
|
|
309660
|
-
|
|
309661
|
-
|
|
309662
|
-
|
|
309663
|
-
|
|
309925
|
+
provider: {
|
|
309926
|
+
ref: {
|
|
309927
|
+
kind: 'FirestartrProviderConfig',
|
|
309928
|
+
name: 'github-app',
|
|
309929
|
+
},
|
|
309664
309930
|
},
|
|
309665
309931
|
},
|
|
309666
309932
|
},
|
|
309667
|
-
}
|
|
309668
|
-
}
|
|
309669
|
-
return new InitializerDefault(
|
|
309933
|
+
};
|
|
309934
|
+
}
|
|
309935
|
+
return new InitializerDefault(adapter);
|
|
309670
309936
|
}
|
|
309671
309937
|
__validateKind(cr) {
|
|
309672
309938
|
return true;
|
|
@@ -309746,9 +310012,9 @@ class GroupCollectionGithubDecanter extends GithubDecanter {
|
|
|
309746
310012
|
const groups = [];
|
|
309747
310013
|
const teamMaps = {};
|
|
309748
310014
|
teamList.forEach((team) => {
|
|
309749
|
-
teamMaps[team.
|
|
310015
|
+
teamMaps[team.slug] = team;
|
|
309750
310016
|
});
|
|
309751
|
-
const filteredGroups = await this.filter(GroupCollectionGithubDecanter.collectionKind, filters, teamList.map((team) => team.
|
|
310017
|
+
const filteredGroups = await this.filter(GroupCollectionGithubDecanter.collectionKind, filters, teamList.map((team) => team.slug));
|
|
309752
310018
|
for (const team of filteredGroups) {
|
|
309753
310019
|
groups.push(new GroupGithubDecanter({ groupDetails: teamMaps[team] }, this.org));
|
|
309754
310020
|
}
|
|
@@ -309763,6 +310029,11 @@ applyCollectionMixins(GroupCollectionGithubDecanter);
|
|
|
309763
310029
|
|
|
309764
310030
|
|
|
309765
310031
|
|
|
310032
|
+
|
|
310033
|
+
|
|
310034
|
+
|
|
310035
|
+
|
|
310036
|
+
|
|
309766
310037
|
class MemberGithubDecanter extends GithubDecanter {
|
|
309767
310038
|
constructor() {
|
|
309768
310039
|
super(...arguments);
|
|
@@ -309800,28 +310071,43 @@ class MemberGithubDecanter extends GithubDecanter {
|
|
|
309800
310071
|
});
|
|
309801
310072
|
}
|
|
309802
310073
|
async __adaptInitializerBase(_claim) {
|
|
309803
|
-
|
|
309804
|
-
|
|
309805
|
-
|
|
309806
|
-
|
|
309807
|
-
|
|
309808
|
-
|
|
309809
|
-
|
|
309810
|
-
|
|
309811
|
-
|
|
309812
|
-
|
|
310074
|
+
let githubMemberDefaultsFilePath;
|
|
310075
|
+
try {
|
|
310076
|
+
githubMemberDefaultsFilePath = external_path_.join(getConfigPath(), 'resources', 'defaults_github_membership.yaml');
|
|
310077
|
+
}
|
|
310078
|
+
catch (e) {
|
|
310079
|
+
importer_src_logger.warn('No config path set, using built-in defaults');
|
|
310080
|
+
githubMemberDefaultsFilePath = '';
|
|
310081
|
+
}
|
|
310082
|
+
let adapter;
|
|
310083
|
+
if (githubMemberDefaultsFilePath &&
|
|
310084
|
+
external_fs_.existsSync(githubMemberDefaultsFilePath)) {
|
|
310085
|
+
adapter = catalog_common.io.fromYaml(external_fs_.readFileSync(githubMemberDefaultsFilePath, 'utf-8'));
|
|
310086
|
+
}
|
|
310087
|
+
else {
|
|
310088
|
+
adapter = {
|
|
310089
|
+
name: 'base',
|
|
310090
|
+
apiVersion: 'firestartr.dev/v1',
|
|
310091
|
+
kind: 'FirestartrGithubMembership',
|
|
310092
|
+
defaultValues: {
|
|
310093
|
+
context: {
|
|
310094
|
+
backend: {
|
|
310095
|
+
ref: {
|
|
310096
|
+
kind: 'FirestartrProviderConfig',
|
|
310097
|
+
name: 'firestartr-terraform-state',
|
|
310098
|
+
},
|
|
309813
310099
|
},
|
|
309814
|
-
|
|
309815
|
-
|
|
309816
|
-
|
|
309817
|
-
|
|
309818
|
-
|
|
310100
|
+
provider: {
|
|
310101
|
+
ref: {
|
|
310102
|
+
kind: 'FirestartrProviderConfig',
|
|
310103
|
+
name: 'github-app',
|
|
310104
|
+
},
|
|
309819
310105
|
},
|
|
309820
310106
|
},
|
|
309821
310107
|
},
|
|
309822
|
-
}
|
|
309823
|
-
}
|
|
309824
|
-
return new InitializerDefault(
|
|
310108
|
+
};
|
|
310109
|
+
}
|
|
310110
|
+
return new InitializerDefault(adapter);
|
|
309825
310111
|
}
|
|
309826
310112
|
}
|
|
309827
310113
|
|
|
@@ -309854,15 +310140,21 @@ applyCollectionMixins(MemberCollectionGithubDecanter);
|
|
|
309854
310140
|
|
|
309855
310141
|
|
|
309856
310142
|
|
|
310143
|
+
|
|
310144
|
+
|
|
310145
|
+
|
|
310146
|
+
|
|
310147
|
+
|
|
309857
310148
|
const TYPE_MAP = {
|
|
309858
310149
|
User: 'user',
|
|
309859
310150
|
Team: 'group',
|
|
309860
310151
|
Organization: 'org',
|
|
309861
310152
|
};
|
|
309862
310153
|
class RepoGithubDecanter extends GithubDecanter {
|
|
309863
|
-
constructor() {
|
|
309864
|
-
super(
|
|
310154
|
+
constructor(data, org, githubTeams = {}) {
|
|
310155
|
+
super(data, org);
|
|
309865
310156
|
this.claimKind = 'ComponentClaim';
|
|
310157
|
+
this.githubTeams = githubTeams;
|
|
309866
310158
|
}
|
|
309867
310159
|
__decantStart() {
|
|
309868
310160
|
this.claim = {
|
|
@@ -309870,7 +310162,6 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
309870
310162
|
version: this.VERSION(),
|
|
309871
310163
|
type: 'service',
|
|
309872
310164
|
lifecycle: 'production',
|
|
309873
|
-
system: `system:${this.org}-system`,
|
|
309874
310165
|
name: this.data.repoDetails.name,
|
|
309875
310166
|
};
|
|
309876
310167
|
}
|
|
@@ -309924,6 +310215,9 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
309924
310215
|
}
|
|
309925
310216
|
}
|
|
309926
310217
|
__decantRelations() {
|
|
310218
|
+
importer_src_logger.debug("Decanting repo's relations...");
|
|
310219
|
+
console.dir(this.data.teamsAndMembers, { depth: null });
|
|
310220
|
+
importer_src_logger.debug("Decanting maintainers...");
|
|
309927
310221
|
const directMaintainers = this.data.teamsAndMembers.directMembers
|
|
309928
310222
|
.filter((member) => member.role === 'maintain')
|
|
309929
310223
|
.map((member) => {
|
|
@@ -309949,6 +310243,7 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
309949
310243
|
path: '/maintainedBy',
|
|
309950
310244
|
});
|
|
309951
310245
|
}
|
|
310246
|
+
importer_src_logger.debug("Decanting admins...");
|
|
309952
310247
|
const directAdmins = this.data.teamsAndMembers.directMembers
|
|
309953
310248
|
.filter((member) => member.role === 'admin')
|
|
309954
310249
|
.map((member) => {
|
|
@@ -309984,6 +310279,7 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
309984
310279
|
path: '/providers/github/overrides',
|
|
309985
310280
|
});
|
|
309986
310281
|
}
|
|
310282
|
+
importer_src_logger.debug("Decanting writers...");
|
|
309987
310283
|
const directWriters = this.data.teamsAndMembers.directMembers
|
|
309988
310284
|
.filter((member) => member.role === 'push')
|
|
309989
310285
|
.map((member) => {
|
|
@@ -310008,6 +310304,7 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
310008
310304
|
path: '/providers/github/overrides',
|
|
310009
310305
|
});
|
|
310010
310306
|
}
|
|
310307
|
+
importer_src_logger.debug("Decanting readers...");
|
|
310011
310308
|
const directReaders = this.data.teamsAndMembers.directMembers
|
|
310012
310309
|
.filter((member) => member.role === 'pull')
|
|
310013
310310
|
.map((member) => {
|
|
@@ -310036,13 +310333,18 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
310036
310333
|
async __gatherRepoTeamsAndMembers() {
|
|
310037
310334
|
this.data['teamsAndMembers'] = {};
|
|
310038
310335
|
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 };
|
|
310336
|
+
return { name: member.login, slug: member.slug, role: member.role_name };
|
|
310040
310337
|
});
|
|
310041
310338
|
const outsideMembers = (await github_0.repo.getCollaborators(this.data.repoDetails.owner.login, this.data.repoDetails.name, 'outside')).map((member) => {
|
|
310042
310339
|
return { name: member.login, role: member.role_name };
|
|
310043
310340
|
});
|
|
310044
|
-
|
|
310045
|
-
|
|
310341
|
+
console.debug("--- 🚀 Gathered repo's teams and members:");
|
|
310342
|
+
console.dir(this.githubTeams, { depth: null });
|
|
310343
|
+
const teams = Object.keys(this.githubTeams).map((teamName) => {
|
|
310344
|
+
return {
|
|
310345
|
+
name: teamName,
|
|
310346
|
+
role: this.githubTeams[teamName].toLowerCase(),
|
|
310347
|
+
};
|
|
310046
310348
|
});
|
|
310047
310349
|
this.data['teamsAndMembers']['teams'] = teams;
|
|
310048
310350
|
this.data['teamsAndMembers']['directMembers'] = directMembers;
|
|
@@ -310108,59 +310410,74 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
310108
310410
|
return null;
|
|
310109
310411
|
}
|
|
310110
310412
|
async __adaptInitializerBase(_claim) {
|
|
310111
|
-
|
|
310112
|
-
|
|
310113
|
-
|
|
310114
|
-
|
|
310115
|
-
|
|
310116
|
-
|
|
310117
|
-
|
|
310118
|
-
|
|
310119
|
-
|
|
310120
|
-
|
|
310413
|
+
let githubRepoDefaultsFilePath;
|
|
310414
|
+
try {
|
|
310415
|
+
githubRepoDefaultsFilePath = external_path_.join(getConfigPath(), 'resources', 'defaults_github_repository.yaml');
|
|
310416
|
+
}
|
|
310417
|
+
catch (e) {
|
|
310418
|
+
importer_src_logger.warn('No config path set, using built-in defaults');
|
|
310419
|
+
githubRepoDefaultsFilePath = '';
|
|
310420
|
+
}
|
|
310421
|
+
let adapter;
|
|
310422
|
+
if (githubRepoDefaultsFilePath &&
|
|
310423
|
+
external_fs_.existsSync(githubRepoDefaultsFilePath)) {
|
|
310424
|
+
adapter = catalog_common.io.fromYaml(external_fs_.readFileSync(githubRepoDefaultsFilePath, 'utf-8'));
|
|
310425
|
+
}
|
|
310426
|
+
else {
|
|
310427
|
+
adapter = {
|
|
310428
|
+
name: 'base',
|
|
310429
|
+
apiVersion: 'firestartr.dev/v1',
|
|
310430
|
+
kind: 'FirestartrGithubRepository',
|
|
310431
|
+
defaultValues: {
|
|
310432
|
+
context: {
|
|
310433
|
+
backend: {
|
|
310434
|
+
ref: {
|
|
310435
|
+
kind: 'FirestartrProviderConfig',
|
|
310436
|
+
name: 'firestartr-terraform-state',
|
|
310437
|
+
},
|
|
310121
310438
|
},
|
|
310122
|
-
|
|
310123
|
-
|
|
310124
|
-
|
|
310125
|
-
|
|
310126
|
-
|
|
310439
|
+
provider: {
|
|
310440
|
+
ref: {
|
|
310441
|
+
kind: 'FirestartrProviderConfig',
|
|
310442
|
+
name: 'github-app',
|
|
310443
|
+
},
|
|
310127
310444
|
},
|
|
310128
310445
|
},
|
|
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: {
|
|
310446
|
+
name: this.data.repoDetails.name,
|
|
310137
310447
|
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
|
-
|
|
310448
|
+
org: this.org,
|
|
310449
|
+
firestartr: {
|
|
310450
|
+
technology: { stack: 'none', version: 'none' },
|
|
310451
|
+
},
|
|
310452
|
+
repo: {
|
|
310453
|
+
description: this.data.repoDetails.description,
|
|
310454
|
+
allowMergeCommit: this.data.repoDetails.allow_merge_commit,
|
|
310455
|
+
allowSquashMerge: this.data.repoDetails.allow_squash_merge,
|
|
310456
|
+
allowRebaseMerge: this.data.repoDetails.allow_rebase_merge,
|
|
310457
|
+
allowAutoMerge: this.data.repoDetails.allow_auto_merge,
|
|
310458
|
+
deleteBranchOnMerge: this.data.repoDetails.delete_branch_on_merge,
|
|
310459
|
+
autoInit: true,
|
|
310460
|
+
archiveOnDestroy: true,
|
|
310461
|
+
allowUpdateBranch: this.data.repoDetails.allow_update_branch,
|
|
310462
|
+
hasIssues: this.data.repoDetails.has_issues,
|
|
310463
|
+
visibility: this.data.repoDetails.visibility,
|
|
310464
|
+
defaultBranch: this.data.repoDetails.default_branch,
|
|
310465
|
+
},
|
|
310466
|
+
permissions: [],
|
|
310467
|
+
actions: {
|
|
310468
|
+
oidc: this.data.oidc.use_default
|
|
310469
|
+
? undefined
|
|
310470
|
+
: {
|
|
310471
|
+
useDefault: this.data.oidc.use_default,
|
|
310472
|
+
includeClaimKeys: this.data.oidc.include_claim_keys
|
|
310473
|
+
? this.data.oidc.include_claim_keys
|
|
310474
|
+
: [],
|
|
310475
|
+
},
|
|
310476
|
+
},
|
|
310160
310477
|
},
|
|
310161
|
-
}
|
|
310162
|
-
}
|
|
310163
|
-
return new InitializerDefault(
|
|
310478
|
+
};
|
|
310479
|
+
}
|
|
310480
|
+
return new InitializerDefault(adapter);
|
|
310164
310481
|
}
|
|
310165
310482
|
async __adaptOverriderRepo(_claim) {
|
|
310166
310483
|
return new GithubRepositoryOverrider();
|
|
@@ -310176,6 +310493,7 @@ class RepoCollectionGithubDecanter extends GithubDecanter {
|
|
|
310176
310493
|
if (this.IS_SKIP_SET(filters, RepoCollectionGithubDecanter.collectionKind)) {
|
|
310177
310494
|
return [];
|
|
310178
310495
|
}
|
|
310496
|
+
const { teams, repositories: directAccessRepos } = await this.github.org.getOrgTeamsDirectAccess(this.org);
|
|
310179
310497
|
let repoList = await this.github.org.getRepositoryList(this.org);
|
|
310180
310498
|
repoList = repoList.filter((el) => !el.archived);
|
|
310181
310499
|
const repoMap = {};
|
|
@@ -310186,7 +310504,9 @@ class RepoCollectionGithubDecanter extends GithubDecanter {
|
|
|
310186
310504
|
const filteredRepos = await this.filter(RepoCollectionGithubDecanter.collectionKind, filters, repoList.map((repo) => repo.name));
|
|
310187
310505
|
for (const repoName of filteredRepos) {
|
|
310188
310506
|
const repoInfo = await this.github.repo.getRepoInfo(this.org, repoName);
|
|
310189
|
-
|
|
310507
|
+
console.log(`--- 🚀 Processing repo: ${repoName}`);
|
|
310508
|
+
console.dir(directAccessRepos, { depth: null });
|
|
310509
|
+
repos.push(new RepoGithubDecanter({ repoDetails: repoInfo }, this.org, directAccessRepos?.[repoName]));
|
|
310190
310510
|
}
|
|
310191
310511
|
this.data['collection'] = repos;
|
|
310192
310512
|
return repos;
|
|
@@ -310196,10 +310516,6 @@ RepoCollectionGithubDecanter.collectionKind = 'gh-repo';
|
|
|
310196
310516
|
applyCollectionMixins(RepoCollectionGithubDecanter);
|
|
310197
310517
|
/* harmony default export */ const github_repo_collection = (RepoCollectionGithubDecanter);
|
|
310198
310518
|
|
|
310199
|
-
;// CONCATENATED MODULE: ../importer/src/logger.ts
|
|
310200
|
-
|
|
310201
|
-
/* harmony default export */ const importer_src_logger = (catalog_common.logger);
|
|
310202
|
-
|
|
310203
310519
|
;// CONCATENATED MODULE: ../importer/src/decanter/index.ts
|
|
310204
310520
|
|
|
310205
310521
|
|
|
@@ -310292,7 +310608,7 @@ function getClaimPathFromCR(claimsBasePath, cr) {
|
|
|
310292
310608
|
FirestartrGithubRepository: 'components',
|
|
310293
310609
|
FirestartrGithubMembership: 'users',
|
|
310294
310610
|
};
|
|
310295
|
-
return external_path_.join(claimsBasePath, mapCrsToClaims[cr.kind], `${cr.metadata.
|
|
310611
|
+
return external_path_.join(claimsBasePath, mapCrsToClaims[cr.kind], `${cr.metadata.labels['claim-ref']}.yaml`.toLowerCase());
|
|
310296
310612
|
}
|
|
310297
310613
|
function getCrPath(crsBasePath, cr) {
|
|
310298
310614
|
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;
|