Skip to content

Commit ce22272

Browse files
flanakinmsbrett
andauthored
Break out bicep modules for hubs extensibility (#1800)
Co-authored-by: msbrett <msbrett@users.no-reply.github.com>
1 parent b5a65be commit ce22272

71 files changed

Lines changed: 6875 additions & 6679 deletions

File tree

Some content is hidden

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

‎.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,8 @@ venv/
368368
ENV/
369369
env/
370370

371+
# Claude settings
372+
.claude/
373+
claude.settings.local.json
374+
settings.local.json
375+

‎.vscode/settings.json‎

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
{
2+
"[bicep]": {
3+
"editor.formatOnSave": true,
4+
"editor.defaultFormatter": "esbenp.prettier-vscode"
5+
},
6+
"[json]": {
7+
"editor.formatOnSave": true,
8+
"editor.defaultFormatter": "esbenp.prettier-vscode"
9+
},
10+
"[markdown]": {
11+
"editor.formatOnSave": true,
12+
"editor.defaultFormatter": "esbenp.prettier-vscode"
13+
},
14+
"[powerquery]": {
15+
"editor.formatOnSave": false
16+
},
17+
"[powershell]": {
18+
"editor.formatOnSave": true,
19+
"editor.defaultFormatter": "ms-vscode.powershell"
20+
},
221
"cSpell.words": [
322
"ADLS",
423
"architecting",
@@ -51,10 +70,15 @@
5170
"Unhide",
5271
"westus"
5372
],
54-
"markdown.preview.typographer": false,
73+
"editor.detectIndentation": false,
74+
"editor.formatOnSave": true,
75+
"editor.codeActionsOnSave": {
76+
"source.fixAll": "explicit"
77+
},
5578
"markdown.extension.italic.indicator": "_",
5679
"markdown.extension.toc.levels": "2..2",
5780
"markdown.extension.toc.orderedList": false,
81+
"markdown.preview.typographer": false,
5882
"markdown.updateLinksOnFileMove.enabled": "prompt",
5983
"markdownlint.config": {
6084
"line-length": false,
@@ -70,9 +94,13 @@
7094
"powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
7195
"powershell.codeFormatting.whitespaceBeforeOpenParen": true,
7296
"powershell.codeFormatting.whitespaceInsideBrace": true,
73-
"[powerquery]": {
74-
"editor.formatOnSave": false
75-
},
7697
"powerquery.general.experimental": false,
77-
"editor.detectIndentation": false
98+
"terminal.integrated.defaultProfile.osx": "pwsh",
99+
"terminal.integrated.profiles.osx": {
100+
"pwsh": {
101+
"path": "pwsh",
102+
"args": ["-NoLogo"]
103+
}
104+
},
105+
"workbench.editor.enablePreview": false
78106
}

‎CLAUDE.md‎

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Repository Overview
6+
7+
The FinOps Toolkit is an open-source collection of tools for adopting and implementing FinOps capabilities in the Microsoft Cloud. It contains templates, PowerShell modules, workbooks, optimization engines, and supporting documentation organized in a modular architecture.
8+
9+
## Common Commands
10+
11+
### Building and Development
12+
13+
```bash
14+
# Build entire toolkit
15+
npm run build
16+
# or
17+
pwsh -Command ./src/scripts/Build-Toolkit
18+
19+
# Build FinOps hubs
20+
pwsh -Command ./src/scripts/Build-Toolkit finops-hub
21+
22+
# Build specific components
23+
npm run build-ps # PowerShell module only
24+
pwsh -Command ./src/scripts/Build-Bicep # Bicep templates
25+
pwsh -Command ./src/scripts/Build-Workbook # Azure Monitor workbooks
26+
pwsh -Command ./src/scripts/Build-OpenData # Open data files
27+
28+
# Deploy for testing
29+
npm run deploy-test
30+
# or
31+
pwsh -Command ./src/scripts/Deploy-Toolkit -Build -Test
32+
33+
# Package for release
34+
npm run package
35+
# or
36+
pwsh -Command ./src/scripts/Package-Toolkit -Build
37+
```
38+
39+
### Testing
40+
41+
```bash
42+
# Run PowerShell unit tests
43+
npm run pester
44+
# or
45+
pwsh -Command Invoke-Pester -Output Detailed -Path ./src/powershell/Tests/Unit/*
46+
47+
# Run integration tests
48+
pwsh -Command ./src/scripts/Test-PowerShell -Integration
49+
50+
# Run specific test categories
51+
pwsh -Command ./src/scripts/Test-PowerShell -Hubs -Exports
52+
53+
# Lint PowerShell code
54+
pwsh -Command ./src/scripts/Test-PowerShell -Lint
55+
```
56+
57+
### Bicep Development
58+
59+
```bash
60+
# Validate Bicep templates
61+
bicep build path/to/template.bicep --stdout
62+
63+
# Test template deployment
64+
az deployment group what-if --resource-group myRG --template-file template.bicep
65+
```
66+
67+
## Architecture and Code Organization
68+
69+
### High-Level Structure
70+
71+
- **`/src/templates/`** - ARM/Bicep infrastructure templates with modular namespace organization
72+
- **`/src/powershell/`** - PowerShell module with public/private functions and comprehensive tests
73+
- **`/src/optimization-engine/`** - Azure Optimization Engine for cost recommendations
74+
- **`/src/workbooks/`** - Azure Monitor workbooks for governance and optimization
75+
- **`/src/open-data/`** - Reference data (pricing, regions, services) with utilities
76+
- **`/src/scripts/`** - Build automation and development tools
77+
- **`/docs/`** - Jekyll documentation website
78+
- **`/docs-mslearn/`** - Microsoft Learn documentation website
79+
- **`/docs-wiki/`** - GitHub wiki documentation
80+
81+
### Current Architectural Reorganization
82+
83+
The FinOps hubs solution is actively migrating to a namespace-based modular structure:
84+
85+
- **`Microsoft.FinOpsHubs/`** - Core FinOps Hub infrastructure modules
86+
- **`Microsoft.CostManagement/`** - Cost management exports and schemas
87+
- **`fx/`** - Shared foundation components (hub-types, scripts, utilities)
88+
89+
### Template Architecture
90+
91+
Templates use a multi-target build system that generates:
92+
93+
- Azure Quickstart Templates (ARM JSON)
94+
- Bicep Registry modules
95+
- Standalone deployments
96+
- Azure portal UI definitions
97+
98+
Key patterns:
99+
100+
- **`.build.config`** files control build behavior per template
101+
- **`settings.json`** contains component-specific configuration
102+
- **`ftkver.txt`** files maintain version synchronization
103+
- **Conditional resource deployment** based on parameters
104+
105+
### PowerShell Module Structure
106+
107+
- **`Public/`** - User-facing cmdlets (Get-_, Set-_, New-\*, etc.)
108+
- **`Private/`** - Internal utilities and helpers
109+
- **`Tests/Unit/`** - Pester unit tests with mocking
110+
- **`Tests/Integration/`** - End-to-end Azure integration tests
111+
- **Module manifest** defines exports and dependencies
112+
113+
### Data Flow and Integration
114+
115+
- **Open data** provides reference information consumed by templates and PowerShell
116+
- **Build scripts** orchestrate compilation across all components
117+
- **Version management** is centralized through `Update-Version.ps1`
118+
- **Templates reference** shared schemas and types from `fx/` namespace
119+
120+
## Key Development Patterns
121+
122+
### Template Development
123+
124+
- Use `newApp()` and `newHub()` functions from `fx/hub-types.bicep` for consistent resource naming
125+
- Follow the conditional deployment pattern: `resource foo 'type' = if (condition) { ... }`
126+
- Implement proper parameter validation with `@allowed`, `@minValue`, `@maxValue`
127+
- Include telemetry tracking via `defaultTelemetry` parameter
128+
129+
### PowerShell Development
130+
131+
- All public functions must have comment-based help
132+
- Use approved verbs from `Get-Verb`
133+
- Implement comprehensive parameter validation
134+
- Support `-WhatIf` and `-Confirm` for destructive operations
135+
- Include Pester tests for all functions
136+
137+
### Testing Strategy
138+
139+
- **Lint tests** validate syntax and coding standards
140+
- **Unit tests** test isolated function behavior with mocks
141+
- **Integration tests** perform end-to-end validation against Azure
142+
- **Template validation** uses `bicep build` and ARM what-if deployments
143+
144+
### Build System Integration
145+
146+
The PowerShell-based build system:
147+
148+
- Compiles templates to multiple target formats
149+
- Validates all code before packaging
150+
- Maintains version consistency across components
151+
- Generates release artifacts automatically
152+
153+
### Version Management
154+
155+
- Central version in `package.json` (currently 12.0.0)
156+
- Synchronized across all components via build scripts
157+
- Individual `ftkver.txt` files distributed to modules
158+
- Git tags correspond to release versions
159+
160+
## Repository Conventions
161+
162+
### Branch Strategy
163+
164+
- **`dev`** - Main integration branch
165+
- Feature branches merge into `dev`
166+
- Releases are tagged from `dev`
167+
168+
### File Organization
169+
170+
- Templates follow namespace/module/component structure
171+
- PowerShell follows standard module layout
172+
- Documentation uses Jekyll conventions
173+
- Build artifacts are generated, not checked in
174+
175+
### Coding Standards
176+
177+
- Always follow the content and coding standards defined in `docs-wiki/Coding-guidelines.md`
178+
- Content (text strings): Follow the Microsoft style guide and always use sentence casing except for proper nouns
179+
- Bicep: Follow Azure Bicep style guide
180+
- PowerShell: Use PowerShell best practices and approved verbs
181+
- Documentation: Use markdown with consistent formatting
182+
- Commit messages: Use conventional commit format

0 commit comments

Comments
 (0)