Skip to content

Commit 8aa0e6f

Browse files
committed
feat: add BBD snippet support + some UI improvements
* Also added platform order
1 parent 192830d commit 8aa0e6f

File tree

8 files changed

+350
-113
lines changed

8 files changed

+350
-113
lines changed

index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ function findPlatforms(): Platform[] {
5050
const platformDir: string = path.join(repoRoot, dir.name);
5151
const platformLogo = getPlatformLogoOrThrow(platformDir, dir.name);
5252
const platformReadme = getPlatformReadmeOrThrow(platformDir);
53-
const { name, description, content } = extractReadmeFrontMatter(platformReadme);
53+
const { name, description, category, content } = extractReadmeFrontMatter(platformReadme);
5454
const terraformSnippet = getTerraformSnippet(platformDir);
5555

5656
return {
5757
platformType: dir.name,
5858
name,
5959
description,
60+
category,
6061
logo: platformLogo,
6162
readme: content,
6263
terraformSnippet
@@ -81,11 +82,11 @@ function getPlatformReadmeOrThrow(platformDir: string) {
8182
try {
8283
return fs.readFileSync(path.join(platformDir, "README.md"), "utf-8");
8384
} catch {
84-
throw new Error('Platform README.md not found. Each platform should have a README.md file.');
85+
throw new Error(`Platform README.md not found for ${platformDir}. Each platform should have a README.md file.`);
8586
}
8687
}
8788

88-
function extractReadmeFrontMatter(platformReadme: string): { name: string; description: string; content: string } {
89+
function extractReadmeFrontMatter(platformReadme: string): { name: string; description: string; category?: string; content: string } {
8990
const { data, content } = matter(platformReadme);
9091

9192
const name = data.name;
@@ -98,10 +99,13 @@ function extractReadmeFrontMatter(platformReadme: string): { name: string; descr
9899
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.');
99100
}
100101

102+
const category = data.category;
103+
101104
return {
102105
name,
103106
description,
104-
content
107+
content,
108+
category
105109
}
106110
}
107111

@@ -169,12 +173,16 @@ function parseReadme(filePath) {
169173
? getBuildingBlockFolderUrl(backplaneDir)
170174
: null;
171175

176+
const terraformSnippetDir = path.join(buildingBlockDir, "..");
177+
const terraformSnippet = getTerraformSnippet(terraformSnippetDir);
178+
172179
return {
173180
id,
174181
platformType: platform,
175182
logo: buildingBlockLogoPath,
176183
buildingBlockUrl,
177184
backplaneUrl,
185+
terraformSnippet,
178186
...data,
179187
howToUse: extractSection(/## How to Use([\s\S]*?)(##|$)/),
180188
resources: parseTable(body.match(/## Resources([\s\S]*)/)),
@@ -224,5 +232,6 @@ export interface Platform {
224232
description: string;
225233
logo: string;
226234
readme: string;
235+
category?: string;
227236
terraformSnippet?: string;
228237
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# TODO: this is actual not a correct file but just acts as an example for now
2+
3+
locals {
4+
name = "azure-storage-account"
5+
scope = "/subscriptions/00000000-0000-0000-0000-000000000000"
6+
existing_principal_ids = [
7+
"00000000-0000-0000-0000-000000000000"
8+
]
9+
service_principal_name = "storage-account-deployer"
10+
11+
workspace_identifier = "my-workspace"
12+
}
13+
14+
provider "meshstack" {
15+
# Configure meshStack API credentials here or use environment variables.
16+
# endpoint = "https://api.my.meshstack.io"
17+
# apikey = "00000000-0000-0000-0000-000000000000"
18+
# apisecret = "uFOu4OjbE4JiewPxezDuemSP3DUrCYmw"
19+
}
20+
21+
provider "azurerm" {
22+
features {}
23+
}
24+
25+
# Import the backplane module to get IAM and other required outputs
26+
module "backplane" {
27+
source = "./backplane"
28+
name = local.name
29+
scope = local.scope
30+
existing_principal_ids = local.existing_principal_ids
31+
create_service_principal_name = local.service_principal_name
32+
workload_identity_federation = {} # TODO this should come from data_source
33+
}
34+
35+
# Import the building block definition into meshStack
36+
# NOTE: meshstack_buildingblock_definition is a placeholder for demonstration. Replace with the actual resource if available.
37+
resource "meshstack_buildingblock_definition" "storage_account" {
38+
metadata = {
39+
name = "azure-storage-account"
40+
owned_by_workspace = local.workspace_identifier
41+
}
42+
43+
spec = {
44+
display_name = "Azure Storage Account"
45+
description = "Provision Azure Storage Accounts with encryption and access control"
46+
47+
supported_platforms = ["azure"]
48+
49+
source = {
50+
git = {
51+
url = "https://github.com/meshcloud/meshstack-hub.git"
52+
ref = "main"
53+
path = "modules/azure/storage-account/buildingblock"
54+
}
55+
}
56+
57+
implementation_type = "Terraform"
58+
# Pass IAM outputs as inputs if required by your building block
59+
role_definition_id = module.backplane.role_definition_id
60+
role_assignment_ids = module.backplane.role_assignment_ids
61+
principal_ids = module.backplane.role_assignment_principal_ids
62+
service_principal = module.backplane.created_service_principal
63+
application = module.backplane.created_application
64+
scope = module.backplane.scope
65+
}
66+
}

modules/meshstack/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
name: meshStack
3+
description: meshStack is a cloud management platform that provides a unified interface for managing and governing cloud environments
4+
---
5+
6+

website/src/app/core/template.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ export interface Template {
88
buildingBlockUrl: string;
99
backplaneUrl: string | null;
1010
supportedPlatforms: string[];
11+
terraformSnippet?: string;
1112
}

0 commit comments

Comments
 (0)