@firestartr/cli 0.1.28 → 0.1.30
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 +95898 -97519
- package/build/provisioner/dist-cdktf/client.js +6 -4
- package/build/provisioner/dist-cdktf/index.js +55232 -57691
- package/build/provisioner/dist-cdktf/index.js.map +1 -1
- package/build/provisioner/dist-cdktf/src/cdktf.js +14 -12
- package/build/provisioner/dist-cdktf/src/config/config.js +3 -3
- package/build/provisioner/dist-cdktf/src/entities/base/Entity.d.ts +2 -2
- package/build/provisioner/dist-cdktf/src/entities/base/Entity.js +4 -5
- package/build/provisioner/dist-cdktf/src/entities/base/auxiliars/ConfigAux.js +4 -4
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubgroup/auxiliars/TeamConfigAux.js +2 -2
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubgroup/helpers/TeamMembersHelper.js +2 -2
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubgroup/helpers/TeamsHelper.js +3 -1
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubmembership/helpers/MembershipAllGroupHelper.d.ts +3 -3
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubmembership/helpers/MembershipAllGroupHelper.js +1 -1
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubmembership/helpers/MembershipHelper.d.ts +2 -2
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubrepository/FirestartrGithubRepository.js +1 -1
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubrepository/auxiliars/RepositoryConfigAux.js +2 -2
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubrepository/helpers/ActionsHelper.d.ts +3 -3
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubrepository/helpers/ActionsHelper.js +2 -2
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubrepository/helpers/CodeownersHelper.d.ts +1 -1
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubrepository/helpers/DefaultBranchHelper.d.ts +3 -3
- package/build/provisioner/dist-cdktf/src/entities/firestartrgithubrepository/helpers/RepositoryTeamsHelper.js +5 -5
- package/build/provisioner/dist-cdktf/src/entities/firestartrterraformmodule/auxiliars/terraformModuleHelper.d.ts +3 -3
- package/build/provisioner/dist-cdktf/src/entities/firestartrterraformmodule/auxiliars/terraformModuleHelper.js +1 -1
- package/build/provisioner/dist-cdktf/src/entities/index.d.ts +1 -1
- package/build/provisioner/dist-cdktf/src/entities/system/SystemEntity.d.ts +2 -2
- package/build/provisioner/dist-cdktf/src/entities/system/SystemEntity.js +1 -1
- package/build/provisioner/dist-cdktf/src/features/index.d.ts +3 -3
- package/build/provisioner/dist-cdktf/src/features/installer.js +6 -5
- package/build/provisioner/dist-cdktf/src/features/preparer.js +8 -8
- package/build/provisioner/dist-cdktf/src/features/provisioner.js +4 -2
- package/build/provisioner/dist-cdktf/src/features/uninstaller.js +8 -6
- package/build/provisioner/dist-cdktf/src/handlers/index.js +2 -2
- package/build/provisioner/dist-cdktf/src/index.d.ts +4 -4
- package/build/provisioner/dist-cdktf/src/index.js +1 -1
- package/build/provisioner/dist-cdktf/src/providers/backend.d.ts +1 -1
- package/build/provisioner/dist-cdktf/src/providers/backend.js +5 -5
- package/build/provisioner/dist-cdktf/src/providers/provider.d.ts +3 -3
- package/build/provisioner/dist-cdktf/src/providers/provider.js +1 -1
- package/build/provisioner/dist-cdktf/src/resources/github_feature/index.d.ts +1 -1
- package/build/provisioner/dist-cdktf/src/resources/github_feature/index.js +11 -9
- package/build/provisioner/dist-cdktf/src/resources/github_feature/preprocessor.d.ts +1 -1
- package/build/provisioner/dist-cdktf/src/resources/github_feature/preprocessor.js +1 -1
- package/build/provisioner/dist-cdktf/src/resources/github_group/index.d.ts +1 -1
- package/build/provisioner/dist-cdktf/src/resources/github_group/index.js +11 -11
- package/build/provisioner/dist-cdktf/src/resources/github_membership/index.d.ts +1 -1
- package/build/provisioner/dist-cdktf/src/resources/github_membership/index.js +11 -11
- package/build/provisioner/dist-cdktf/src/resources/github_repository/index.d.ts +1 -1
- package/build/provisioner/dist-cdktf/src/resources/github_repository/index.js +11 -11
- package/build/provisioner/dist-cdktf/src/resources/resource.js +8 -12
- package/build/provisioner/dist-cdktf/src/resources/terraform_module/index.d.ts +1 -1
- package/build/provisioner/dist-cdktf/src/resources/terraform_module/index.js +5 -5
- package/build/provisioner/dist-cdktf/src/stacks/GithubStack.js +2 -2
- package/build/provisioner/dist-cdktf/src/stacks/TerraformModuleStack.d.ts +3 -3
- package/build/provisioner/dist-cdktf/src/stacks/TerraformModuleStack.js +2 -2
- package/build/provisioner/dist-cdktf/src/stacks/base.d.ts +1 -1
- package/build/provisioner/dist-cdktf/src/stacks/base.js +5 -5
- package/build/provisioner/dist-cdktf/src/stacks/index.d.ts +2 -2
- package/build/provisioner/dist-cdktf/src/terraform.js +16 -14
- package/build/provisioner/dist-cdktf/tsconfig.cdktf.tsbuildinfo +1 -1
- package/package.json +7 -3
|
@@ -33,16 +33,18 @@ const path = __importStar(require("path"));
|
|
|
33
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
|
-
let workDir = __dirname.split(path.sep).includes('packages')
|
|
37
|
-
|
|
36
|
+
let workDir = __dirname.split(path.sep).includes('packages')
|
|
37
|
+
? path.join(__dirname, '..')
|
|
38
|
+
: path.join(__dirname, 'provisioner');
|
|
39
|
+
workDir = workDir.split('/dist')[0];
|
|
38
40
|
return new Promise((ok, ko) => {
|
|
39
|
-
const cdktfProcess = (0, child_process_1.spawn)(
|
|
41
|
+
const cdktfProcess = (0, child_process_1.spawn)('cdktf', [action, '--log-level', 'DEBUG', '--auto-approve'], {
|
|
40
42
|
cwd: workDir,
|
|
41
43
|
env: {
|
|
42
44
|
...process.env,
|
|
43
45
|
PATH: process.env.PATH,
|
|
44
46
|
FIRESTARTR_CDKTF_ENTITY_PATH: entityPath,
|
|
45
|
-
FIRESTARTR_CDKTF_DEPS_PATH: depsPath ? depsPath :
|
|
47
|
+
FIRESTARTR_CDKTF_DEPS_PATH: depsPath ? depsPath : '',
|
|
46
48
|
GITHUB_APP_ID: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.githubAppId),
|
|
47
49
|
GITHUB_APP_INSTALLATION_ID: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.githubAppInstallationId),
|
|
48
50
|
GITHUB_APP_INSTALLATION_ID_PREFAPP: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.githubAppInstallationIdPrefapp),
|
|
@@ -50,23 +52,23 @@ async function runCDKTF(entityPath, action, depsPath) {
|
|
|
50
52
|
ORG: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.org),
|
|
51
53
|
KUBERNETES_SERVICE_HOST: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.kubernetesServiceHost),
|
|
52
54
|
KUBERNETES_SERVICE_PORT: catalog_common_1.default.environment.getFromEnvironment(catalog_common_1.default.types.envVars.kubernetesServicePort),
|
|
53
|
-
CDKTF_LOG_LEVEL:
|
|
54
|
-
FORCE_COLOR:
|
|
55
|
+
CDKTF_LOG_LEVEL: 'OFF',
|
|
56
|
+
FORCE_COLOR: '0',
|
|
55
57
|
DEBUG: process.env.DEBUG,
|
|
56
|
-
DEBUG_DEPTH:
|
|
57
|
-
}
|
|
58
|
+
DEBUG_DEPTH: '0',
|
|
59
|
+
},
|
|
58
60
|
});
|
|
59
61
|
let output = '';
|
|
60
|
-
cdktfProcess.stdout.on(
|
|
62
|
+
cdktfProcess.stdout.on('data', (log) => {
|
|
61
63
|
const logparsed = log.toString();
|
|
62
|
-
if (!logparsed.includes(
|
|
64
|
+
if (!logparsed.includes('Synthesizing')) {
|
|
63
65
|
output += catalog_common_1.default.io.stripAnsi(logparsed);
|
|
64
66
|
}
|
|
65
67
|
});
|
|
66
|
-
cdktfProcess.stderr.on(
|
|
68
|
+
cdktfProcess.stderr.on('data', (log) => {
|
|
67
69
|
output += catalog_common_1.default.io.stripAnsi(log.toString());
|
|
68
70
|
});
|
|
69
|
-
cdktfProcess.on(
|
|
71
|
+
cdktfProcess.on('exit', async (code) => {
|
|
70
72
|
if (code !== 0) {
|
|
71
73
|
ko({ mainCommand: action, output });
|
|
72
74
|
}
|
|
@@ -11,7 +11,7 @@ const messageLog = (0, debug_1.default)('firestartr:provisioner:config');
|
|
|
11
11
|
* @description Valid plans for the account
|
|
12
12
|
* @type {Set<string>}
|
|
13
13
|
*/
|
|
14
|
-
const VALID_PLANS = new Set([
|
|
14
|
+
const VALID_PLANS = new Set(['free', 'team', 'enterprise']);
|
|
15
15
|
/**
|
|
16
16
|
* @description Check if the account has one of the plans in the input
|
|
17
17
|
* @param plans
|
|
@@ -19,8 +19,8 @@ const VALID_PLANS = new Set(["free", "team", "enterprise"]);
|
|
|
19
19
|
*/
|
|
20
20
|
async function orgHasOneOfThesePlans(org, plans) {
|
|
21
21
|
try {
|
|
22
|
-
if (plans.some(plan => !VALID_PLANS.has(plan))) {
|
|
23
|
-
throw
|
|
22
|
+
if (plans.some((plan) => !VALID_PLANS.has(plan))) {
|
|
23
|
+
throw 'One or more plans in the input are not valid.';
|
|
24
24
|
}
|
|
25
25
|
const accountSubscriptionPlan = await getAccountPlan(org);
|
|
26
26
|
if (plans.includes(accountSubscriptionPlan)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Construct } from
|
|
2
|
-
import { TerraformModule, TerraformResource } from
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import { TerraformModule, TerraformResource } from 'cdktf';
|
|
3
3
|
declare class Metadata {
|
|
4
4
|
_metadata: any;
|
|
5
5
|
constructor(metadata: any);
|
|
@@ -7,7 +7,7 @@ exports.Entity = void 0;
|
|
|
7
7
|
const cdktf_1 = require("cdktf");
|
|
8
8
|
const debug_1 = __importDefault(require("debug"));
|
|
9
9
|
const log = (0, debug_1.default)('firestartr:provisioner:entity:base');
|
|
10
|
-
const EXTERNAL_NAME_ANNOTATION =
|
|
10
|
+
const EXTERNAL_NAME_ANNOTATION = 'firestartr.dev/external-name';
|
|
11
11
|
class Metadata {
|
|
12
12
|
_metadata;
|
|
13
13
|
constructor(metadata) {
|
|
@@ -70,7 +70,7 @@ class Entity {
|
|
|
70
70
|
const { kind, name, needsSecret } = ref;
|
|
71
71
|
if (!needsSecret) {
|
|
72
72
|
const cr = this.deps[`${kind}-${name}`].cr;
|
|
73
|
-
return cr.metadata?.annotations?.[EXTERNAL_NAME_ANNOTATION] || cr.metadata.name;
|
|
73
|
+
return (cr.metadata?.annotations?.[EXTERNAL_NAME_ANNOTATION] || cr.metadata.name);
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
76
|
if (!propertyRef) {
|
|
@@ -100,7 +100,7 @@ class Entity {
|
|
|
100
100
|
const keys = this.getKeysFrom(this.mainResource);
|
|
101
101
|
const outputs = this.spec.writeConnectionSecretToRef.outputs;
|
|
102
102
|
for (const o of outputs) {
|
|
103
|
-
log(
|
|
103
|
+
log('OUTPUT %s', o.key);
|
|
104
104
|
if (!keys.includes(o.key)) {
|
|
105
105
|
throw `resolveOutputs:
|
|
106
106
|
|
|
@@ -109,8 +109,7 @@ class Entity {
|
|
|
109
109
|
does not have the output ${o.key}`;
|
|
110
110
|
}
|
|
111
111
|
new cdktf_1.TerraformOutput(scope, o.key, {
|
|
112
|
-
value: this.mainResource
|
|
113
|
-
.getAnyMapAttribute(this.camelToSnake(o.key))
|
|
112
|
+
value: this.mainResource.getAnyMapAttribute(this.camelToSnake(o.key)),
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
115
|
}
|
|
@@ -20,9 +20,9 @@ class ConfigAux {
|
|
|
20
20
|
// Get keys from RepositoryConfig interface
|
|
21
21
|
const allKeys = Object.keys(this);
|
|
22
22
|
// remove terraform related keys
|
|
23
|
-
let untrackedProperties = allKeys.filter(key => !this.discriminateSpecialProperties().includes(key));
|
|
23
|
+
let untrackedProperties = allKeys.filter((key) => !this.discriminateSpecialProperties().includes(key));
|
|
24
24
|
// remove trackeable properties
|
|
25
|
-
untrackedProperties = untrackedProperties.filter(key => !this.getTrackeableProperties().includes(key));
|
|
25
|
+
untrackedProperties = untrackedProperties.filter((key) => !this.getTrackeableProperties().includes(key));
|
|
26
26
|
return this.toSnakeCase(untrackedProperties);
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
@@ -48,8 +48,8 @@ class ConfigAux {
|
|
|
48
48
|
* @returns
|
|
49
49
|
*/
|
|
50
50
|
toSnakeCase(camelCaseStrings) {
|
|
51
|
-
return camelCaseStrings.map(str => {
|
|
52
|
-
return str.replace(/[A-Z]/g, match => `_${match.toLowerCase()}`);
|
|
51
|
+
return camelCaseStrings.map((str) => {
|
|
52
|
+
return str.replace(/[A-Z]/g, (match) => `_${match.toLowerCase()}`);
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
}
|
package/build/provisioner/dist-cdktf/src/entities/firestartrgithubgroup/auxiliars/TeamConfigAux.js
CHANGED
|
@@ -17,7 +17,7 @@ class TeamConfigAux extends ConfigAux_1.ConfigAux {
|
|
|
17
17
|
lifecycle = undefined;
|
|
18
18
|
provider = undefined;
|
|
19
19
|
provisioners = undefined;
|
|
20
|
-
name =
|
|
20
|
+
name = '';
|
|
21
21
|
createDefaultMaintainer = undefined;
|
|
22
22
|
description = undefined;
|
|
23
23
|
id = undefined;
|
|
@@ -28,7 +28,7 @@ class TeamConfigAux extends ConfigAux_1.ConfigAux {
|
|
|
28
28
|
privacy = undefined;
|
|
29
29
|
constructor() {
|
|
30
30
|
super({
|
|
31
|
-
trackableProperties: ['name', 'description', 'id', 'ldap_dn', 'privacy']
|
|
31
|
+
trackableProperties: ['name', 'description', 'id', 'ldap_dn', 'privacy'],
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
}
|
package/build/provisioner/dist-cdktf/src/entities/firestartrgithubgroup/helpers/TeamMembersHelper.js
CHANGED
|
@@ -12,13 +12,13 @@ function provisionMembers(scope, team, fsGithubGroup) {
|
|
|
12
12
|
for (const member of fsGithubGroup.spec.members) {
|
|
13
13
|
messageLog(`Provisioning user ${member.ref.name} for group ${fsGithubGroup.metadata.name}`);
|
|
14
14
|
const tfStateKey = `_${fsGithubGroup.getTfStateKey()}-${member.ref.kind}-${member.ref.name}-tr`;
|
|
15
|
-
if (member.ref.kind ===
|
|
15
|
+
if (member.ref.kind === 'FirestartrGithubMembership') {
|
|
16
16
|
const username = fsGithubGroup.resolveRef(member.ref);
|
|
17
17
|
const config = {
|
|
18
18
|
dependsOn: [team],
|
|
19
19
|
username,
|
|
20
20
|
teamId: team.id,
|
|
21
|
-
role: member.role
|
|
21
|
+
role: member.role,
|
|
22
22
|
};
|
|
23
23
|
const membership = new team_membership_1.TeamMembership(scope, tfStateKey, config);
|
|
24
24
|
fsGithubGroup.addResourceToStack(`${team.id}:${username}`, membership);
|
package/build/provisioner/dist-cdktf/src/entities/firestartrgithubgroup/helpers/TeamsHelper.js
CHANGED
|
@@ -14,7 +14,9 @@ function provisionGroup(scope, fsGithubGroup) {
|
|
|
14
14
|
name: fsGithubGroup.metadata.name,
|
|
15
15
|
description: fsGithubGroup.spec.description,
|
|
16
16
|
privacy: fsGithubGroup.spec.privacy,
|
|
17
|
-
parentTeamId: fsGithubGroup.spec.parentTeam
|
|
17
|
+
parentTeamId: fsGithubGroup.spec.parentTeam
|
|
18
|
+
? fsGithubGroup.resolveRef(fsGithubGroup.spec.parentTeam.ref, 'id')
|
|
19
|
+
: null,
|
|
18
20
|
};
|
|
19
21
|
const tfStateKey = `_${fsGithubGroup.getTfStateKey()}`;
|
|
20
22
|
const group = new team_1.Team(scope, tfStateKey, config);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FirestartrGithubMembership } from
|
|
2
|
-
import { Construct } from
|
|
3
|
-
import { TeamMembership } from
|
|
1
|
+
import { FirestartrGithubMembership } from '../FirestartrGithubMembership';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
|
+
import { TeamMembership } from '@cdktf/provider-github/lib/team-membership';
|
|
4
4
|
export declare function provisionAllGroupMembershipRelation(scope: Construct, fsGithubMembership: FirestartrGithubMembership): TeamMembership;
|
|
@@ -12,7 +12,7 @@ function provisionAllGroupMembershipRelation(scope, fsGithubMembership) {
|
|
|
12
12
|
const config = {
|
|
13
13
|
username: fsGithubMembership.metadata.name,
|
|
14
14
|
teamId: `${fsGithubMembership.spec.org}-all`,
|
|
15
|
-
role:
|
|
15
|
+
role: 'member',
|
|
16
16
|
};
|
|
17
17
|
const teamMembership = new team_membership_1.TeamMembership(scope, `${tfStateKey}-all-group-membership`, config);
|
|
18
18
|
return teamMembership;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FirestartrGithubMembership } from
|
|
2
|
-
import { Construct } from
|
|
1
|
+
import { FirestartrGithubMembership } from '../FirestartrGithubMembership';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
3
|
import { Membership } from '@cdktf/provider-github/lib/membership';
|
|
4
4
|
export declare function provisionMembership(scope: Construct, fsGithubMembership: FirestartrGithubMembership): Membership;
|
|
@@ -17,7 +17,7 @@ class FirestartrGithubRepository extends Entity_1.Entity {
|
|
|
17
17
|
this.mainResource = (0, RepositoryHelper_1.provisionRepository)(scope, this);
|
|
18
18
|
const branchDefault = (0, DefaultBranchHelper_1.provisionDefaultBranch)(scope, this, this.mainResource);
|
|
19
19
|
(0, ActionsHelper_1.provisionOIDCSubjectClaim)(scope, this.mainResource, this);
|
|
20
|
-
if (await this.orgHasOneOfThesePlans(this.spec.org, [
|
|
20
|
+
if (await this.orgHasOneOfThesePlans(this.spec.org, ['team', 'enterprise'])) {
|
|
21
21
|
(0, RepositoryHelper_1.provisionBranchProtections)(scope, this.mainResource, this);
|
|
22
22
|
}
|
|
23
23
|
(0, CodeownersHelper_1.provisionCodeowners)(scope, this.mainResource, branchDefault, this);
|
|
@@ -32,7 +32,7 @@ class RepositoryConfigAux extends ConfigAux_1.ConfigAux {
|
|
|
32
32
|
licenseTemplate = undefined;
|
|
33
33
|
mergeCommitMessage = undefined;
|
|
34
34
|
mergeCommitTitle = undefined;
|
|
35
|
-
name =
|
|
35
|
+
name = '';
|
|
36
36
|
private = undefined;
|
|
37
37
|
squashMergeCommitMessage = undefined;
|
|
38
38
|
squashMergeCommitTitle = undefined;
|
|
@@ -65,7 +65,7 @@ class RepositoryConfigAux extends ConfigAux_1.ConfigAux {
|
|
|
65
65
|
'deleteBranchOnMerge',
|
|
66
66
|
'hasIssues',
|
|
67
67
|
'securityAndAnalysis',
|
|
68
|
-
]
|
|
68
|
+
],
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FirestartrGithubRepository } from
|
|
1
|
+
import { FirestartrGithubRepository } from '../FirestartrGithubRepository';
|
|
2
2
|
import { Construct } from 'constructs';
|
|
3
|
-
import { ActionsRepositoryOidcSubjectClaimCustomizationTemplate } from
|
|
4
|
-
import { Repository } from
|
|
3
|
+
import { ActionsRepositoryOidcSubjectClaimCustomizationTemplate } from '@cdktf/provider-github/lib/actions-repository-oidc-subject-claim-customization-template';
|
|
4
|
+
import { Repository } from '@cdktf/provider-github/lib/repository';
|
|
5
5
|
export declare function provisionOIDCSubjectClaim(scope: Construct, repo: Repository, fsGithubRepository: FirestartrGithubRepository): ActionsRepositoryOidcSubjectClaimCustomizationTemplate;
|
|
@@ -5,12 +5,12 @@ const actions_repository_oidc_subject_claim_customization_template_1 = require("
|
|
|
5
5
|
function provisionOIDCSubjectClaim(scope, repo, fsGithubRepository) {
|
|
6
6
|
const tfStateKey = `_${fsGithubRepository.getTfStateKey()}-oidc-subject-claim-template`;
|
|
7
7
|
const claimKeys = fsGithubRepository.spec.actions.oidc.includeClaimKeys;
|
|
8
|
-
|
|
8
|
+
const config = {
|
|
9
9
|
repository: repo.name,
|
|
10
10
|
useDefault: claimKeys.length < 1,
|
|
11
11
|
};
|
|
12
12
|
if (claimKeys.length > 0) {
|
|
13
|
-
config[
|
|
13
|
+
config['includeClaimKeys'] = claimKeys;
|
|
14
14
|
}
|
|
15
15
|
const actionsClaim = new actions_repository_oidc_subject_claim_customization_template_1.ActionsRepositoryOidcSubjectClaimCustomizationTemplate(scope, tfStateKey, config);
|
|
16
16
|
fsGithubRepository.addResourceToStack(fsGithubRepository.metadata.name, actionsClaim);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Repository } from '@cdktf/provider-github/lib/repository';
|
|
2
2
|
import { Construct } from 'constructs';
|
|
3
3
|
import { FirestartrGithubRepository } from '../FirestartrGithubRepository';
|
|
4
|
-
import { BranchDefault } from
|
|
4
|
+
import { BranchDefault } from '@cdktf/provider-github/lib/branch-default';
|
|
5
5
|
export declare function provisionCodeowners(scope: Construct, repo: Repository, branchDefault: BranchDefault, fsGithubRepository: FirestartrGithubRepository): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BranchDefault } from
|
|
1
|
+
import { BranchDefault } from '@cdktf/provider-github/lib/branch-default';
|
|
2
2
|
import { Construct } from 'constructs';
|
|
3
|
-
import { Repository } from
|
|
4
|
-
import { FirestartrGithubRepository } from
|
|
3
|
+
import { Repository } from '@cdktf/provider-github/lib/repository';
|
|
4
|
+
import { FirestartrGithubRepository } from '../FirestartrGithubRepository';
|
|
5
5
|
export declare function provisionDefaultBranch(scope: Construct, fsGithubRepository: FirestartrGithubRepository, repo: Repository): BranchDefault;
|
|
@@ -11,19 +11,19 @@ const messageLog = (0, debug_1.default)('firestartr:provisioner:entities:compone
|
|
|
11
11
|
function provisionPermissions(scope, repo, fsGithubRepository) {
|
|
12
12
|
messageLog(`provisionRepositoryTeams with name ${fsGithubRepository.metadata.name} in org ${fsGithubRepository.spec.org}`);
|
|
13
13
|
for (const permission of fsGithubRepository.spec.permissions) {
|
|
14
|
-
if (
|
|
14
|
+
if ('ref' in permission) {
|
|
15
15
|
const tfStateKey = `_${fsGithubRepository.getTfStateKey()}-${permission.ref.kind}-${permission.ref.name}-tr`;
|
|
16
|
-
if (permission.ref.kind ===
|
|
17
|
-
const teamId = fsGithubRepository.resolveRef(permission.ref,
|
|
16
|
+
if (permission.ref.kind === 'FirestartrGithubGroup') {
|
|
17
|
+
const teamId = fsGithubRepository.resolveRef(permission.ref, 'id');
|
|
18
18
|
const config = {
|
|
19
19
|
repository: repo.name,
|
|
20
20
|
teamId,
|
|
21
|
-
permission: permission.role
|
|
21
|
+
permission: permission.role,
|
|
22
22
|
};
|
|
23
23
|
const teamsRepository = new team_repository_1.TeamRepository(scope, tfStateKey, config);
|
|
24
24
|
fsGithubRepository.addResourceToStack(`${teamId}:${fsGithubRepository.metadata.name}`, teamsRepository);
|
|
25
25
|
}
|
|
26
|
-
else if (permission.ref.kind ===
|
|
26
|
+
else if (permission.ref.kind === 'FirestartrGithubMembership') {
|
|
27
27
|
const username = fsGithubRepository.resolveRef(permission.ref);
|
|
28
28
|
const config = {
|
|
29
29
|
repository: repo.name,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Construct } from
|
|
2
|
-
import { FirestartrTerraformModuleEntity } from
|
|
3
|
-
import { TerraformModule } from
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import { FirestartrTerraformModuleEntity } from '../FirestartrTerraformModule';
|
|
3
|
+
import { TerraformModule } from 'cdktf';
|
|
4
4
|
export declare class GenericTerraformModule extends TerraformModule {
|
|
5
5
|
private readonly inputs;
|
|
6
6
|
constructor(scope: Construct, name: string, inputs: any, source: string);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Entity } from
|
|
1
|
+
import { Entity } from './base/Entity';
|
|
2
2
|
export declare function getEntityInstance(entity: any, deps: any): Entity;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Construct } from
|
|
2
|
-
import { Entity } from
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import { Entity } from '../base/Entity';
|
|
3
3
|
export declare class SystemEntity extends Entity {
|
|
4
4
|
constructor(entity: any);
|
|
5
5
|
loadResources(data: {
|
|
@@ -12,7 +12,7 @@ class SystemEntity extends Entity_1.Entity {
|
|
|
12
12
|
super(entity);
|
|
13
13
|
}
|
|
14
14
|
async loadResources(data) {
|
|
15
|
-
messageLog(
|
|
15
|
+
messageLog('This is a system artifact, nothing to provision');
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.SystemEntity = SystemEntity;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { installFeaturesForComponent } from
|
|
2
|
-
import { prepareFeaturesForComponent } from
|
|
3
|
-
import { untrackManagedFiles } from
|
|
1
|
+
import { installFeaturesForComponent } from './installer';
|
|
2
|
+
import { prepareFeaturesForComponent } from './preparer';
|
|
3
|
+
import { untrackManagedFiles } from './uninstaller';
|
|
4
4
|
export { prepareFeaturesForComponent, installFeaturesForComponent, untrackManagedFiles, };
|
|
@@ -35,11 +35,12 @@ const messageLog = (0, debug_1.default)('firestartr:provisioner:features:install
|
|
|
35
35
|
async function installFeaturesForComponent(component, store) {
|
|
36
36
|
const componentFeatures = component.spec?.provisioner?.features || '[]';
|
|
37
37
|
const componentFeaturesToInstall = componentFeatures.filter((feature) => {
|
|
38
|
-
return feature.status.value ===
|
|
38
|
+
return (feature.status.value ===
|
|
39
|
+
catalog_common_1.default.types.FeatureStatuses.pendingInstallStatus);
|
|
39
40
|
});
|
|
40
41
|
if (componentFeaturesToInstall.length > 0) {
|
|
41
42
|
for (const feature of componentFeaturesToInstall) {
|
|
42
|
-
messageLog(
|
|
43
|
+
messageLog('Installing feature %s for component %s', feature.name, component.metadata.name);
|
|
43
44
|
// Get feature config
|
|
44
45
|
const featureConfig = catalog_common_1.default.features.features.getFeatureRenderedConfigForComponent(component, feature.name);
|
|
45
46
|
// prepare files
|
|
@@ -90,9 +91,9 @@ function updateFileContent(fileSrc, fileContent) {
|
|
|
90
91
|
fs.writeFileSync(fileSrc, fileContent);
|
|
91
92
|
}
|
|
92
93
|
function isFreshInstallation(featureName, component) {
|
|
93
|
-
if (component[
|
|
94
|
-
const featuresToInstall = JSON.parse(component[
|
|
95
|
-
const featureToInstall = featuresToInstall.find((feature) => feature[
|
|
94
|
+
if (component['metadata']['annotations']['fire-starter.dev/features-to-install']) {
|
|
95
|
+
const featuresToInstall = JSON.parse(component['metadata']['annotations']['fire-starter.dev/features-to-install']);
|
|
96
|
+
const featureToInstall = featuresToInstall.find((feature) => feature['name'] === featureName);
|
|
96
97
|
if (featureToInstall) {
|
|
97
98
|
return true;
|
|
98
99
|
}
|
|
@@ -36,17 +36,17 @@ async function prepareFeaturesForComponent(component, store) {
|
|
|
36
36
|
// those are the features to maintain
|
|
37
37
|
let componentFeatures = component.spec?.provisioner?.features || [];
|
|
38
38
|
// let's include the features to uninstall
|
|
39
|
-
if (component.metadata.annotations[
|
|
40
|
-
componentFeatures = componentFeatures.concat(JSON.parse(component.metadata.annotations[
|
|
39
|
+
if (component.metadata.annotations['fire-starter.dev/features-to-uninstall']) {
|
|
40
|
+
componentFeatures = componentFeatures.concat(JSON.parse(component.metadata.annotations['fire-starter.dev/features-to-uninstall']));
|
|
41
41
|
}
|
|
42
42
|
// let's include the features to install
|
|
43
|
-
if (component.metadata.annotations[
|
|
44
|
-
componentFeatures = componentFeatures.concat(JSON.parse(component.metadata.annotations[
|
|
43
|
+
if (component.metadata.annotations['fire-starter.dev/features-to-install']) {
|
|
44
|
+
componentFeatures = componentFeatures.concat(JSON.parse(component.metadata.annotations['fire-starter.dev/features-to-install']));
|
|
45
45
|
}
|
|
46
46
|
if (componentFeatures.length > 0) {
|
|
47
47
|
const entityPath = dumpArtifactYaml(component);
|
|
48
48
|
for (const feature of componentFeatures) {
|
|
49
|
-
messageLog(
|
|
49
|
+
messageLog('Installing feature %s for component %s', feature.name, component.metadata.name);
|
|
50
50
|
await features_preparer_1.default.getFeatureConfig(feature.name, feature.version, entityPath);
|
|
51
51
|
// Get feature config
|
|
52
52
|
const featureConfig = catalog_common_1.default.features.features.getFeatureRenderedConfigForComponent(component, feature.name);
|
|
@@ -58,7 +58,7 @@ async function prepareFeaturesForComponent(component, store) {
|
|
|
58
58
|
}
|
|
59
59
|
exports.prepareFeaturesForComponent = prepareFeaturesForComponent;
|
|
60
60
|
function dumpArtifactYaml(component) {
|
|
61
|
-
fs.mkdirSync(
|
|
62
|
-
catalog_common_1.default.io.writeEntity(component,
|
|
63
|
-
return catalog_common_1.default.io.getEntityPath(
|
|
61
|
+
fs.mkdirSync('/tmp/components', { recursive: true });
|
|
62
|
+
catalog_common_1.default.io.writeEntity(component, '/tmp');
|
|
63
|
+
return catalog_common_1.default.io.getEntityPath('components', component.metadata.name, '/tmp');
|
|
64
64
|
}
|
|
@@ -14,7 +14,9 @@ function provisionFeatureFiles(scope, feature) {
|
|
|
14
14
|
if (feature.spec.files) {
|
|
15
15
|
for (const file of feature.spec.files) {
|
|
16
16
|
messageLog('Provisioning file %O', file);
|
|
17
|
-
const lifecycleArg = file.userManaged
|
|
17
|
+
const lifecycleArg = file.userManaged
|
|
18
|
+
? { ignoreChanges: ['content'] }
|
|
19
|
+
: {};
|
|
18
20
|
const repoConfig = {
|
|
19
21
|
branch: feature.spec.repositoryTarget.branch,
|
|
20
22
|
commitMessage: `feat: ${feature.spec.type} ${feature.spec.version}`,
|
|
@@ -22,7 +24,7 @@ function provisionFeatureFiles(scope, feature) {
|
|
|
22
24
|
file: file.path,
|
|
23
25
|
repository: feature.resolveRef(feature.spec.repositoryTarget.ref),
|
|
24
26
|
overwriteOnCreate: true,
|
|
25
|
-
lifecycle: lifecycleArg
|
|
27
|
+
lifecycle: lifecycleArg,
|
|
26
28
|
};
|
|
27
29
|
new repository_file_1.RepositoryFile(scope, `${feature.spec.type}-${file.path}`, repoConfig);
|
|
28
30
|
}
|
|
@@ -36,18 +36,20 @@ const messageLog = (0, debug_1.default)('firestartr:provisioner:features:uninsta
|
|
|
36
36
|
async function untrackManagedFiles(feature, deps) {
|
|
37
37
|
if (!feature.spec.files || feature.spec.files.length < 1)
|
|
38
38
|
return;
|
|
39
|
-
messageLog(
|
|
40
|
-
messageLog(
|
|
39
|
+
messageLog('Removing managed files from the Terraform State');
|
|
40
|
+
messageLog('Synthing the project...');
|
|
41
41
|
const randomFilenameFeature = `${catalog_common_1.default.generic.randomString(20)}.yaml`;
|
|
42
42
|
const randomFilenameDeps = `${catalog_common_1.default.generic.randomString(20)}_deps.yaml`;
|
|
43
|
-
catalog_common_1.default.io.writeYamlFile(randomFilenameFeature, feature,
|
|
44
|
-
catalog_common_1.default.io.writeYamlFile(randomFilenameDeps, deps,
|
|
45
|
-
await (0, cdktf_1.runCDKTF)(path.join(
|
|
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));
|
|
46
46
|
await (0, terraform_1.runTerraform)(feature, ['init']);
|
|
47
47
|
for (const file of feature.spec.files.filter((file) => file.userManaged === true)) {
|
|
48
48
|
messageLog(`Removing from the state file ${file.path}`);
|
|
49
49
|
// Terraform replaces / with -- and . with - in the state file names, so we do the same to get the state file name
|
|
50
|
-
|
|
50
|
+
const stateFileName = `${feature.spec.type}-${file.path}`
|
|
51
|
+
.replace(/\//g, '--')
|
|
52
|
+
.replace(/\./g, '');
|
|
51
53
|
await (0, terraform_1.runTerraform)(feature, ['state', 'rm', `github_repository_file.${stateFileName}`]);
|
|
52
54
|
}
|
|
53
55
|
// messageLog(`Removing the files from the state`)
|
|
@@ -22,10 +22,10 @@ function getActionByStatus(status) {
|
|
|
22
22
|
case catalog_common_1.default.types.ArtifactStatuses.pendingProvisioningStatus:
|
|
23
23
|
case catalog_common_1.default.types.ArtifactStatuses.pendingRenameStatus:
|
|
24
24
|
case catalog_common_1.default.types.ArtifactStatuses.creatingStatus:
|
|
25
|
-
return
|
|
25
|
+
return 'deploy';
|
|
26
26
|
case catalog_common_1.default.types.ArtifactStatuses.pendingDeleteStatus:
|
|
27
27
|
case catalog_common_1.default.types.ArtifactStatuses.deletingStatus:
|
|
28
|
-
return
|
|
28
|
+
return 'destroy';
|
|
29
29
|
default:
|
|
30
30
|
return catalog_common_1.default.types.ArtifactStatuses.unknownStatus;
|
|
31
31
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getActionByStatus } from
|
|
2
|
-
import { runCDKTF } from
|
|
3
|
-
import { runTerraform } from
|
|
4
|
-
import { untrackManagedFiles } from
|
|
1
|
+
import { getActionByStatus } from './handlers';
|
|
2
|
+
import { runCDKTF } from './cdktf';
|
|
3
|
+
import { runTerraform } from './terraform';
|
|
4
|
+
import { untrackManagedFiles } from './features';
|
|
5
5
|
declare const _default: {
|
|
6
6
|
runCDKTF: typeof runCDKTF;
|
|
7
7
|
getActionByStatus: typeof getActionByStatus;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FirestartrTerraformBackendProvider } from
|
|
1
|
+
import { FirestartrTerraformBackendProvider } from '.';
|
|
2
2
|
export declare class BackendError extends Error {
|
|
3
3
|
backend: FirestartrTerraformBackendProvider;
|
|
4
4
|
constructor(backend: FirestartrTerraformBackendProvider);
|
|
@@ -21,22 +21,22 @@ function createBackend(scope, provider, tfStateKey, config) {
|
|
|
21
21
|
case _1.FirestartrTerraformBackendProvider.AWS:
|
|
22
22
|
new cdktf_1.S3Backend(scope, {
|
|
23
23
|
...updatedConfig,
|
|
24
|
-
key: tfStateKey
|
|
24
|
+
key: tfStateKey,
|
|
25
25
|
});
|
|
26
26
|
break;
|
|
27
27
|
case _1.FirestartrTerraformBackendProvider.AZURERM:
|
|
28
28
|
new cdktf_1.AzurermBackend(scope, {
|
|
29
29
|
...updatedConfig,
|
|
30
|
-
key: tfStateKey
|
|
30
|
+
key: tfStateKey,
|
|
31
31
|
});
|
|
32
32
|
break;
|
|
33
33
|
case _1.FirestartrTerraformBackendProvider.KUBERNETES:
|
|
34
|
-
scope.addOverride(
|
|
34
|
+
scope.addOverride('terraform.backend.kubernetes', {
|
|
35
35
|
// In this case we do not need to replace the config keys case
|
|
36
36
|
...config,
|
|
37
|
-
secret_suffix: tfStateKey.split(
|
|
37
|
+
secret_suffix: tfStateKey.split('/').join('-'),
|
|
38
38
|
});
|
|
39
|
-
scope.addOverride(
|
|
39
|
+
scope.addOverride('terraform.backend.local', null);
|
|
40
40
|
break;
|
|
41
41
|
default:
|
|
42
42
|
throw new BackendError(provider);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Construct } from
|
|
2
|
-
import { TerraformProvider } from
|
|
3
|
-
import { FirestartrTerraformProvider } from
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import { TerraformProvider } from 'cdktf';
|
|
3
|
+
import { FirestartrTerraformProvider } from '.';
|
|
4
4
|
export declare function createProvider(scope: Construct, provider: FirestartrTerraformProvider, id: string, config: any): TerraformProvider;
|
|
@@ -17,7 +17,7 @@ function createProvider(scope, provider, id, config) {
|
|
|
17
17
|
case _1.FirestartrTerraformProvider.AZURERM:
|
|
18
18
|
return new provider_3.AzurermProvider(scope, id, {
|
|
19
19
|
...updatedConfig,
|
|
20
|
-
features: {}
|
|
20
|
+
features: {},
|
|
21
21
|
});
|
|
22
22
|
case _1.FirestartrTerraformProvider.GITHUB:
|
|
23
23
|
return new provider_1.GithubProvider(scope, id, updatedConfig);
|