Skip to content

Commit 42c5f88

Browse files
authored
Merge pull request #100 from meshcloud/feature/platform-integration-page
2 parents 6783f24 + 1a51c44 commit 42c5f88

File tree

75 files changed

+2109
-9361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2109
-9361
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ repos:
55
- id: terraform_docs
66
args:
77
- --args=--config=.terraform-docs.yml
8+
files: ^modules/[^/]+/[^/]+/.+\.tf$ # Only run on .tf files in modules/*/*/ directories
89
- id: terraform_fmt
910
- id: terragrunt_fmt
1011
- repo: https://github.com/pre-commit/pre-commit-hooks

.terraform-docs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ version: ""
44

55
recursive:
66
enabled: false
7-
path: kit
87

98
content: ""
109

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ AWS S3 Module – Provision S3 buckets with encryption and logging.
2121
All Terraform modules are listed in the `modules/` directory.
2222
This directory is split into subdirectories for each platform.
2323
In a platform's directory, you will find all modules that are available for that platform.
24+
Additionally, you might also find a `meshstack_integration.tf` and `README.md` file in a platform
25+
directory. These allow you to integrate a given platform directly with meshStack.
26+
27+
```
2428
2529
A single module is structured as follows:
2630

index.ts

Lines changed: 80 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ const path = require("path");
33
const matter = require("gray-matter");
44
const { execSync } = require("child_process");
55

6+
const repoRoot = path.resolve(__dirname, "modules");
7+
const assetsDir = path.resolve(__dirname, "website/public/assets/logos");
8+
69
function getGitHubRemoteUrl() {
710
try {
811
const remoteUrl = execSync("git config --get remote.origin.url")
@@ -38,44 +41,76 @@ function findReadmes(dir){
3841
});
3942
}
4043

41-
function copyFilesToAssets(
42-
sourceDir,
43-
destinationDir,
44-
fileFilter
45-
){
46-
const copiedFiles = {};
44+
function findPlatforms(): Platform[] {
45+
fs.mkdirSync(assetsDir, { recursive: true });
4746

48-
fs.readdirSync(sourceDir, { withFileTypes: true })
47+
return fs.readdirSync(repoRoot, { withFileTypes: true })
4948
.filter((dirent) => dirent.isDirectory() && dirent.name !== ".github")
50-
.forEach((dir) => {
51-
const platformDir = path.join(sourceDir, dir.name);
52-
fs.readdirSync(platformDir)
53-
.filter(fileFilter)
54-
.forEach((file) => {
55-
const sourcePath = path.join(platformDir, file);
56-
const destinationPath = path.join(
57-
destinationDir,
58-
`${dir.name}${path.extname(file)}`
59-
);
60-
61-
fs.mkdirSync(destinationDir, { recursive: true });
62-
fs.copyFileSync(sourcePath, destinationPath);
63-
64-
copiedFiles[dir.name] = destinationPath
65-
.replace(path.resolve(__dirname, "website/public"), "")
66-
.replace(/^\/+/g, "");
67-
});
49+
.map((dir) => {
50+
const platformDir: string = path.join(repoRoot, dir.name);
51+
const platformLogo = getPlatformLogoOrThrow(platformDir, dir.name);
52+
const platformReadme = getPlatformReadmeOrThrow(platformDir);
53+
const { name, description, content } = extractReadmeFrontMatter(platformReadme);
54+
const terraformSnippet = getTerraformSnippet(platformDir);
55+
56+
return {
57+
platformType: dir.name,
58+
name,
59+
description,
60+
logo: platformLogo,
61+
readme: content,
62+
terraformSnippet
63+
};
6864
});
65+
}
6966

70-
return copiedFiles;
67+
// Finds the logo, copies it to website assets and returns the path.
68+
function getPlatformLogoOrThrow(platformDir: string, platformType: string): string {
69+
const logoFile = fs.readdirSync(platformDir).find(f => f.endsWith('.png') || f.endsWith('.svg'));
70+
if (logoFile) {
71+
const sourcePath = path.join(platformDir, logoFile);
72+
const destPath = path.join(assetsDir, `${platformType}${path.extname(logoFile)}`);
73+
fs.copyFileSync(sourcePath, destPath);
74+
return destPath.replace(path.resolve(__dirname, "website/public"), "").replace(/^\/+/g, "");
75+
}
76+
77+
throw new Error(`Logo file not found for platform: ${platformType} in directory: ${platformDir}. Each platform should have a logo.`);
7178
}
7279

73-
function copyPlatformLogosToAssets() {
74-
const modulesDir = path.resolve(__dirname, "modules");
75-
const assetsDir = path.resolve(__dirname, "website/public/assets/logos");
76-
return copyFilesToAssets(modulesDir, assetsDir, (file) =>
77-
file.endsWith(".png") || file.endsWith(".svg")
78-
);
80+
function getPlatformReadmeOrThrow(platformDir: string) {
81+
try {
82+
return fs.readFileSync(path.join(platformDir, "README.md"), "utf-8");
83+
} catch {
84+
throw new Error('Platform README.md not found. Each platform should have a README.md file.');
85+
}
86+
}
87+
88+
function extractReadmeFrontMatter(platformReadme: string): { name: string; description: string; content: string } {
89+
const { data, content } = matter(platformReadme);
90+
91+
const name = data.name;
92+
if (!name) {
93+
throw new Error('Property "name" is missing in the front matter of the platform README.md. Each platform README.md should have a name defined in the front matter.');
94+
}
95+
96+
const description = data.description;
97+
if (!description) {
98+
throw new Error('Property "description" is missing in the front matter of the platform README.md. Each platform README.md should have a description defined in the front matter.');
99+
}
100+
101+
return {
102+
name,
103+
description,
104+
content
105+
}
106+
}
107+
108+
function getTerraformSnippet(platformDir: string): string | null {
109+
try {
110+
return fs.readFileSync(path.join(platformDir, "meshstack_integration.tf"), "utf-8")
111+
} catch {
112+
return null;
113+
}
79114
}
80115

81116
function copyBuildingBlockLogoToAssets(buildingBlockDir) {
@@ -161,15 +196,13 @@ function getIdAndPlatform(filePath) {
161196

162197
// Main execution
163198
function main() {
164-
const repoRoot = path.resolve(__dirname, "modules");
165-
166-
const platformLogos = copyPlatformLogosToAssets();
199+
const platforms = findPlatforms();
167200
fs.writeFileSync(
168-
"website/public/assets/platform-logos.json",
169-
JSON.stringify(platformLogos, null, 2)
201+
"website/public/assets/platform.json",
202+
JSON.stringify(platforms, null, 2)
170203
);
171204
console.log(
172-
`✅ Successfully processed ${Object.entries(platformLogos).length} platform logos. Output saved to platform-logos.json`
205+
`✅ Successfully processed ${platforms.length} platforms. Output saved to platform.json`
173206
);
174207

175208
const readmeFiles = findReadmes(repoRoot);
@@ -184,3 +217,12 @@ function main() {
184217
}
185218

186219
main();
220+
221+
export interface Platform {
222+
platformType: string;
223+
name: string;
224+
description: string;
225+
logo: string;
226+
readme: string;
227+
terraformSnippet?: string;
228+
}

modules/aks/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
name: Azure Kubernetes Service
3+
description: Managed Kubernetes service on Azure
4+
category: hyperscaler
5+
---
6+
7+
A meshStack integration of AKS allows you to automatically provision and manage Kubernetes namespaces for meshStack projects, enforce policies and enable secure authentication for your AKS workloads, and track usage to enable billing across namespaces.

modules/aws/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
name: Amazon Web Services
3+
description: Scalable cloud computing platform by Amazon
4+
category: hyperscaler
5+
---
6+
7+
meshStack integration with AWS enables automated account provisioning, policy enforcement, and unified billing for AWS resources across your organization.

modules/azure/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
name: Microsoft Azure
3+
description: Cloud computing platform and services by Microsoft
4+
category: hyperscaler
5+
---
6+
7+
meshStack integration with Azure streamlines subscription management, enforces governance, and enables cost tracking for Azure resources in your organization.

modules/azuredevops/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
name: Azure DevOps
3+
description: Developer services for support teams to plan, build, and ship software
4+
category: devops
5+
---
6+
7+
meshStack integration with Azure DevOps automates project and repository setup, ensuring consistent governance and access management for your development workflows.

modules/cloudfoundry/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
name: Cloud Foundry
3+
description: Open source cloud application platform
4+
category: private-cloud
5+
---
6+
7+
meshStack integration with Cloud Foundry automates org and space provisioning, policy enforcement, and enables usage-based billing for your cloud-native applications.

modules/datadog/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
name: Datadog
3+
description: Monitoring and security platform for cloud applications
4+
category: devops
5+
---
6+
7+
meshStack integration with Datadog enables automated account management and unified monitoring setup for your cloud environments.

0 commit comments

Comments
 (0)