@firestartr/cli 0.1.25 → 0.1.26
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 +153 -49
- package/build/provisioner/dist-cdktf/client.js +29 -3
- package/build/provisioner/dist-cdktf/index.js +61 -5
- package/build/provisioner/dist-cdktf/index.js.map +1 -1
- package/build/provisioner/dist-cdktf/src/cdktf.d.ts +1 -1
- package/build/provisioner/dist-cdktf/src/cdktf.js +7 -18
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubmembership/FirestartrGithubMembership.js +2 -0
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubmembership/helpers/MembershipAllGroupHelper.d.ts +4 -0
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubmembership/helpers/MembershipAllGroupHelper.js +20 -0
- package/build/provisioner/dist-cdktf/src/features/uninstaller.js +30 -1
- package/build/provisioner/dist-cdktf/src/resources/resource.js +34 -2
- package/build/provisioner/dist-cdktf/src/terraform.js +0 -12
- package/build/provisioner/dist-cdktf/tsconfig.cdktf.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function runCDKTF(
|
|
1
|
+
export declare function runCDKTF(entityPath: any, action: string, depsPath?: any): Promise<unknown>;
|
|
@@ -30,11 +30,10 @@ exports.runCDKTF = void 0;
|
|
|
30
30
|
const catalog_common_1 = __importDefault(require("catalog_common"));
|
|
31
31
|
const child_process_1 = require("child_process");
|
|
32
32
|
const path = __importStar(require("path"));
|
|
33
|
-
async function runCDKTF(
|
|
33
|
+
async function runCDKTF(entityPath, action, depsPath) {
|
|
34
34
|
// ! If we are into a compiled environmet, the folder must be set to current dir plus /provisioner because everything is on the same file at projects root
|
|
35
35
|
// ? Is there a better way to check compiled env than look for packages directory in path ?
|
|
36
36
|
let workDir = __dirname.split(path.sep).includes('packages') ? path.join(__dirname, '..') : path.join(__dirname, 'provisioner');
|
|
37
|
-
const isImport = entity?.metadata?.annotations[catalog_common_1.default.generic.getFirestartrAnnotation("import")];
|
|
38
37
|
workDir = workDir.split("/dist")[0];
|
|
39
38
|
return new Promise((ok, ko) => {
|
|
40
39
|
const cdktfProcess = (0, child_process_1.spawn)("cdktf", [action, "--log-level", "DEBUG", "--auto-approve"], {
|
|
@@ -42,26 +41,13 @@ async function runCDKTF(entity, action, deps) {
|
|
|
42
41
|
env: {
|
|
43
42
|
...process.env,
|
|
44
43
|
PATH: process.env.PATH,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
CATALOG_MAIN_STATE: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.catalogMainSate),
|
|
48
|
-
CATALOG_DESIRED_STATE: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.catalogDesiredState),
|
|
49
|
-
CATALOG_DELETIONS_STATE: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.catalogDeletionsState),
|
|
50
|
-
CDKTF_CONFIG_FILES: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.cdktfConfigFiles),
|
|
51
|
-
FIRESTARTR_CDKTF_IS_IMPORT: isImport ? "true" : "false",
|
|
52
|
-
EXCLUSIONS_YAML_PATH: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.exclusionsYamlPath),
|
|
53
|
-
FIRESTARTR_CDKTF_ENTITY_KIND: entity.kind,
|
|
44
|
+
FIRESTARTR_CDKTF_ENTITY_PATH: entityPath,
|
|
45
|
+
FIRESTARTR_CDKTF_DEPS_PATH: depsPath ? depsPath : "",
|
|
54
46
|
GITHUB_APP_ID: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.githubAppId),
|
|
55
47
|
GITHUB_APP_INSTALLATION_ID: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.githubAppInstallationId),
|
|
56
48
|
GITHUB_APP_INSTALLATION_ID_PREFAPP: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.githubAppInstallationIdPrefapp),
|
|
57
49
|
GITHUB_APP_PEM_FILE: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.githubAppPemFile),
|
|
58
|
-
S3_BUCKET: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.s3Bucket),
|
|
59
|
-
S3_REGION: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.s3Region),
|
|
60
|
-
S3_LOCK: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.s3Lock),
|
|
61
|
-
AWS_ACCESS_KEY_ID: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.awsAccesKey),
|
|
62
|
-
AWS_SECRET_ACCESS_KEY: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.awsAccesSecretKey),
|
|
63
50
|
ORG: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.org),
|
|
64
|
-
TOKEN: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.token),
|
|
65
51
|
KUBERNETES_SERVICE_HOST: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.kubernetesServiceHost),
|
|
66
52
|
KUBERNETES_SERVICE_PORT: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.kubernetesServicePort),
|
|
67
53
|
CDKTF_LOG_LEVEL: "OFF",
|
|
@@ -72,7 +58,10 @@ async function runCDKTF(entity, action, deps) {
|
|
|
72
58
|
});
|
|
73
59
|
let output = '';
|
|
74
60
|
cdktfProcess.stdout.on("data", (log) => {
|
|
75
|
-
|
|
61
|
+
const logparsed = log.toString();
|
|
62
|
+
if (!logparsed.includes("Synthesizing")) {
|
|
63
|
+
output += catalog_common_1.default.io.stripAnsi(logparsed);
|
|
64
|
+
}
|
|
76
65
|
});
|
|
77
66
|
cdktfProcess.stderr.on("data", (log) => {
|
|
78
67
|
output += catalog_common_1.default.io.stripAnsi(log.toString());
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FirestartrGithubMembership = void 0;
|
|
4
4
|
const Entity_1 = require("../base/Entity");
|
|
5
5
|
const MembershipHelper_1 = require("./helpers/MembershipHelper");
|
|
6
|
+
const MembershipAllGroupHelper_1 = require("./helpers/MembershipAllGroupHelper");
|
|
6
7
|
class FirestartrGithubMembership extends Entity_1.Entity {
|
|
7
8
|
constructor(entity) {
|
|
8
9
|
super(entity);
|
|
@@ -10,6 +11,7 @@ class FirestartrGithubMembership extends Entity_1.Entity {
|
|
|
10
11
|
async loadResources(data) {
|
|
11
12
|
const { scope } = data;
|
|
12
13
|
this.mainResource = (0, MembershipHelper_1.provisionMembership)(scope, this);
|
|
14
|
+
(0, MembershipAllGroupHelper_1.provisionAllGroupMembershipRelation)(scope, this);
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
exports.FirestartrGithubMembership = FirestartrGithubMembership;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FirestartrGithubMembership } from "../FirestartrGithubMembership";
|
|
2
|
+
import { Construct } from "constructs";
|
|
3
|
+
import { TeamMembership } from "@cdktf/provider-github/lib/team-membership";
|
|
4
|
+
export declare function provisionAllGroupMembershipRelation(scope: Construct, fsGithubMembership: FirestartrGithubMembership): TeamMembership;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.provisionAllGroupMembershipRelation = void 0;
|
|
7
|
+
const debug_1 = __importDefault(require("debug"));
|
|
8
|
+
const team_membership_1 = require("@cdktf/provider-github/lib/team-membership");
|
|
9
|
+
const messageLog = (0, debug_1.default)('firestartr:provisioner:modules:artifacts:membership:all-group-helper');
|
|
10
|
+
function provisionAllGroupMembershipRelation(scope, fsGithubMembership) {
|
|
11
|
+
const tfStateKey = `_${fsGithubMembership.getTfStateKey()}`;
|
|
12
|
+
const config = {
|
|
13
|
+
username: fsGithubMembership.metadata.name,
|
|
14
|
+
teamId: `${fsGithubMembership.spec.org}-all`,
|
|
15
|
+
role: "member"
|
|
16
|
+
};
|
|
17
|
+
const teamMembership = new team_membership_1.TeamMembership(scope, `${tfStateKey}-all-group-membership`, config);
|
|
18
|
+
return teamMembership;
|
|
19
|
+
}
|
|
20
|
+
exports.provisionAllGroupMembershipRelation = provisionAllGroupMembershipRelation;
|
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.untrackManagedFiles = void 0;
|
|
30
|
+
const catalog_common_1 = __importDefault(require("catalog_common"));
|
|
7
31
|
const debug_1 = __importDefault(require("debug"));
|
|
32
|
+
const path = __importStar(require("path"));
|
|
8
33
|
const cdktf_1 = require("../cdktf");
|
|
9
34
|
const terraform_1 = require("../terraform");
|
|
10
35
|
const messageLog = (0, debug_1.default)('firestartr:provisioner:features:uninstaller');
|
|
@@ -13,7 +38,11 @@ async function untrackManagedFiles(feature, deps) {
|
|
|
13
38
|
return;
|
|
14
39
|
messageLog(`Removing managed files from the Terraform State`);
|
|
15
40
|
messageLog(`Synthing the project...`);
|
|
16
|
-
|
|
41
|
+
const randomFilenameFeature = `${catalog_common_1.default.generic.randomString(20)}.yaml`;
|
|
42
|
+
const randomFilenameDeps = `${catalog_common_1.default.generic.randomString(20)}_deps.yaml`;
|
|
43
|
+
catalog_common_1.default.io.writeYamlFile(randomFilenameFeature, feature, "/tmp");
|
|
44
|
+
catalog_common_1.default.io.writeYamlFile(randomFilenameDeps, deps, "/tmp");
|
|
45
|
+
await (0, cdktf_1.runCDKTF)(path.join("/tmp", randomFilenameFeature), "synth", path.join("/tmp", randomFilenameDeps));
|
|
17
46
|
await (0, terraform_1.runTerraform)(feature, ['init']);
|
|
18
47
|
for (const file of feature.spec.files.filter((file) => file.userManaged === true)) {
|
|
19
48
|
messageLog(`Removing from the state file ${file.path}`);
|
|
@@ -1,8 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
2
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
29
|
exports.Resource = void 0;
|
|
4
30
|
const cdktf_1 = require("../cdktf");
|
|
5
31
|
const terraform_1 = require("../terraform");
|
|
32
|
+
const catalog_common_1 = __importDefault(require("catalog_common"));
|
|
33
|
+
const path = __importStar(require("path"));
|
|
6
34
|
class Resource {
|
|
7
35
|
data = {};
|
|
8
36
|
output = '';
|
|
@@ -22,14 +50,18 @@ class Resource {
|
|
|
22
50
|
await this.runTerraform();
|
|
23
51
|
}
|
|
24
52
|
catch (err) {
|
|
25
|
-
throw
|
|
53
|
+
throw err;
|
|
26
54
|
}
|
|
27
55
|
}
|
|
28
56
|
artifact() {
|
|
29
57
|
return this.get('main_artifact');
|
|
30
58
|
}
|
|
31
59
|
async synth() {
|
|
32
|
-
|
|
60
|
+
const randomFilenameArtifact = `${catalog_common_1.default.generic.randomString(20)}.yaml`;
|
|
61
|
+
const randomFilenameDeps = `${catalog_common_1.default.generic.randomString(20)}_deps.yaml`;
|
|
62
|
+
catalog_common_1.default.io.writeYamlFile(randomFilenameArtifact, this.get('main_artifact'), "/tmp");
|
|
63
|
+
catalog_common_1.default.io.writeYamlFile(randomFilenameDeps, this.get('deps'), "/tmp");
|
|
64
|
+
await (0, cdktf_1.runCDKTF)(path.join("/tmp", randomFilenameArtifact), "synth", path.join("/tmp", randomFilenameDeps));
|
|
33
65
|
}
|
|
34
66
|
log(msg) {
|
|
35
67
|
this.logFn(msg);
|
|
@@ -45,21 +45,9 @@ async function runTerraform(entity, command) {
|
|
|
45
45
|
cwd: workDir,
|
|
46
46
|
env: {
|
|
47
47
|
PATH: process.env.PATH,
|
|
48
|
-
FIRESTARTR_CDKTF_ENTITY_NAME: entity.metadata.name,
|
|
49
|
-
CATALOG_MAIN_STATE: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.catalogMainSate),
|
|
50
|
-
CATALOG_DESIRED_STATE: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.catalogDesiredState),
|
|
51
|
-
CATALOG_DELETIONS_STATE: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.catalogDeletionsState),
|
|
52
|
-
CDKTF_CONFIG_FILES: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.cdktfConfigFiles),
|
|
53
|
-
EXCLUSIONS_YAML_PATH: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.exclusionsYamlPath),
|
|
54
|
-
FIRESTARTR_CDKTF_ENTITY_KIND: entity.kind,
|
|
55
48
|
GITHUB_APP_ID: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.githubAppId),
|
|
56
49
|
GITHUB_APP_INSTALLATION_ID: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.githubAppInstallationId),
|
|
57
50
|
GITHUB_APP_PEM_FILE: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.githubAppPemFile),
|
|
58
|
-
S3_BUCKET: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.s3Bucket),
|
|
59
|
-
S3_REGION: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.s3Region),
|
|
60
|
-
S3_LOCK: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.s3Lock),
|
|
61
|
-
AWS_ACCESS_KEY_ID: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.awsAccesKey),
|
|
62
|
-
AWS_SECRET_ACCESS_KEY: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.awsAccesSecretKey),
|
|
63
51
|
ORG: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.org),
|
|
64
52
|
TOKEN: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.token),
|
|
65
53
|
KUBERNETES_SERVICE_HOST: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.kubernetesServiceHost),
|