|
| 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 | +This repository contains the Pulumi Azure Native provider, which enables Pulumi users to manage Azure resources using TypeScript, Python, Go, .NET, and Java. The provider directly calls the Azure Resource Manager (ARM) REST API, providing comprehensive coverage of Azure services. |
| 8 | + |
| 9 | +## Build and Development Commands |
| 10 | + |
| 11 | +### Setup and Dependencies |
| 12 | + |
| 13 | +- **Dependencies**: |
| 14 | + - Go 1.21+ |
| 15 | + - NodeJS 18.X.X+ |
| 16 | + - Python 3.10+ |
| 17 | + - .NET 6+ |
| 18 | + - Gradle 8+ |
| 19 | + |
| 20 | +### Core Build Commands |
| 21 | + |
| 22 | +```bash |
| 23 | +# Full build (generate schema, SDKs, and build the provider) |
| 24 | +make |
| 25 | + |
| 26 | +# Generate schema only |
| 27 | +make schema |
| 28 | + |
| 29 | +# Regenerate schema and update docs |
| 30 | +make generate_schema generate_docs |
| 31 | + |
| 32 | +# Generate SDKs for all languages |
| 33 | +make generate |
| 34 | + |
| 35 | +# Build the provider binary |
| 36 | +make provider |
| 37 | + |
| 38 | +# Install the provider locally (used for testing) |
| 39 | +make install_provider |
| 40 | + |
| 41 | +# Clean the build |
| 42 | +make clean |
| 43 | +``` |
| 44 | + |
| 45 | +### SDK Generation and Building |
| 46 | + |
| 47 | +```bash |
| 48 | +# Generate SDKs for specific languages |
| 49 | +make generate_java |
| 50 | +make generate_nodejs |
| 51 | +make generate_python |
| 52 | +make generate_dotnet |
| 53 | +make generate_go |
| 54 | + |
| 55 | +# Build SDKs for specific languages |
| 56 | +make build_nodejs |
| 57 | +make build_python |
| 58 | +make build_dotnet |
| 59 | +make build_java |
| 60 | +make build_go |
| 61 | +``` |
| 62 | + |
| 63 | +### Testing |
| 64 | + |
| 65 | +```bash |
| 66 | +# Run all tests |
| 67 | +make test |
| 68 | + |
| 69 | +# Run tests for specific languages |
| 70 | +make test_dotnet |
| 71 | +make test_python |
| 72 | +make test_go |
| 73 | +make test_nodejs |
| 74 | + |
| 75 | +# Run provider tests |
| 76 | +make test_provider |
| 77 | + |
| 78 | +# Run specific test by name |
| 79 | +make test TEST_NAME=TestXXX |
| 80 | + |
| 81 | +# Run specific test category |
| 82 | +make test TEST_TAGS=nodejs |
| 83 | +``` |
| 84 | + |
| 85 | +### Schema Management |
| 86 | + |
| 87 | +```bash |
| 88 | +# Generate schema squeeze (for major version releases) |
| 89 | +make schema_squeeze |
| 90 | +``` |
| 91 | + |
| 92 | +## Code Architecture |
| 93 | + |
| 94 | +### Key Components |
| 95 | + |
| 96 | +1. **Azure Specifications**: The repository uses Azure's REST API specifications from the `azure-rest-api-specs` submodule. |
| 97 | + |
| 98 | +2. **Provider**: The core provider implementation is in `provider/pkg`, which handles: |
| 99 | + - Authentication with Azure |
| 100 | + - CRUD operations for resources |
| 101 | + - Type conversions between Pulumi and Azure |
| 102 | + - Handling of special cases and customizations |
| 103 | + |
| 104 | +3. **Code Generator**: The `pulumi-gen-azure-native` tool generates schemas and SDKs based on Azure's OpenAPI specifications. |
| 105 | + |
| 106 | +4. **SDKs**: Generated SDKs for multiple languages in the `sdk/` directory: |
| 107 | + - TypeScript/JavaScript (`sdk/nodejs`) |
| 108 | + - Python (`sdk/python`) |
| 109 | + - .NET (`sdk/dotnet`) |
| 110 | + - Go (`sdk/go`) |
| 111 | + - Java (`sdk/java`) |
| 112 | + |
| 113 | +5. **Version Management**: The provider supports multiple API versions through configuration in the `versions/` directory: |
| 114 | + - Each major version has its own configuration |
| 115 | + - API versions are selectively included based on compatibility and features |
| 116 | + |
| 117 | +### Important Subsystems |
| 118 | + |
| 119 | +#### Sub-Resources |
| 120 | + |
| 121 | +The provider handles "sub-resource properties" specially. These are resources that can be defined inline with a parent resource or as standalone resources. The provider ensures that: |
| 122 | +- On Create: Default values are set for unset sub-resource properties |
| 123 | +- On Update: Existing sub-resources are preserved during updates |
| 124 | +- On Read: Unset sub-resource properties are reset to empty values |
| 125 | + |
| 126 | +#### Custom Resources |
| 127 | + |
| 128 | +Some Azure resources require special handling beyond what can be generated from the OpenAPI specs. These custom implementations are in `provider/pkg/resources/customresources/`. |
| 129 | + |
| 130 | +## Development Workflow |
| 131 | + |
| 132 | +1. **Understanding API Versions**: Azure's REST API has many versions with ISO date format (e.g., `2020-01-01`). |
| 133 | + - Not all versions contain all resources |
| 134 | + - Preview versions (`-preview` suffix) are sometimes stable for everyday use |
| 135 | + - The provider selectively includes versions to maintain compatibility |
| 136 | + |
| 137 | +2. **Making Changes**: |
| 138 | + - For schema changes, modify files in `versions/` directory |
| 139 | + - For provider behavior changes, modify files in `provider/pkg/` |
| 140 | + - For custom resource implementations, modify files in `provider/pkg/resources/customresources/` |
| 141 | + |
| 142 | +3. **Testing Changes**: |
| 143 | + - Run unit tests with `make test_provider` |
| 144 | + - Test examples with `make test` or language-specific tests |
| 145 | + |
| 146 | +4. **Adding Resource Documentation**: |
| 147 | + - Add documentation in `docs/resources/` folder |
| 148 | + - File naming follows the pattern: `[module]-[Resource].md` (e.g., `sql-Server.md`) |
| 149 | + - Regenerate docs with `make generate generate_docs` |
| 150 | + |
| 151 | +## Common Issues and Solutions |
| 152 | + |
| 153 | +1. **Schema Generation**: If schema generation fails, check that the Azure REST API specs submodule is properly initialized: |
| 154 | + ```bash |
| 155 | + git submodule update --init --recursive |
| 156 | + ``` |
| 157 | + |
| 158 | +2. **Sub-resource Handling**: When troubleshooting issues with resources that contain sub-resources, check the implementation in `provider/pkg/provider/`. |
| 159 | + |
| 160 | +3. **Version Compatibility**: When adding support for new API versions, check for compatibility with existing versions in the `versions/` directory. |
0 commit comments