infra-lang 0.1.0__tar.gz

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.
Files changed (71) hide show
  1. infra_lang-0.1.0/.gitignore +45 -0
  2. infra_lang-0.1.0/LICENSE +21 -0
  3. infra_lang-0.1.0/PKG-INFO +262 -0
  4. infra_lang-0.1.0/README.md +211 -0
  5. infra_lang-0.1.0/pyproject.toml +121 -0
  6. infra_lang-0.1.0/src/infra/__init__.py +79 -0
  7. infra_lang-0.1.0/src/infra/__main__.py +4 -0
  8. infra_lang-0.1.0/src/infra/analyzer/__init__.py +0 -0
  9. infra_lang-0.1.0/src/infra/analyzer/reliability.py +347 -0
  10. infra_lang-0.1.0/src/infra/analyzer/security.py +264 -0
  11. infra_lang-0.1.0/src/infra/analyzer/symbols.py +153 -0
  12. infra_lang-0.1.0/src/infra/analyzer/types.py +228 -0
  13. infra_lang-0.1.0/src/infra/analyzer/validator.py +551 -0
  14. infra_lang-0.1.0/src/infra/backends/__init__.py +45 -0
  15. infra_lang-0.1.0/src/infra/backends/_images.py +25 -0
  16. infra_lang-0.1.0/src/infra/backends/base.py +287 -0
  17. infra_lang-0.1.0/src/infra/backends/compose.py +354 -0
  18. infra_lang-0.1.0/src/infra/backends/github.py +243 -0
  19. infra_lang-0.1.0/src/infra/backends/helm.py +505 -0
  20. infra_lang-0.1.0/src/infra/backends/kubernetes.py +1060 -0
  21. infra_lang-0.1.0/src/infra/backends/terraform.py +425 -0
  22. infra_lang-0.1.0/src/infra/cli/__init__.py +0 -0
  23. infra_lang-0.1.0/src/infra/cli/check.py +28 -0
  24. infra_lang-0.1.0/src/infra/cli/compile.py +251 -0
  25. infra_lang-0.1.0/src/infra/cli/diff.py +33 -0
  26. infra_lang-0.1.0/src/infra/cli/docs.py +64 -0
  27. infra_lang-0.1.0/src/infra/cli/feedback_cmd.py +52 -0
  28. infra_lang-0.1.0/src/infra/cli/fmt.py +51 -0
  29. infra_lang-0.1.0/src/infra/cli/graph.py +122 -0
  30. infra_lang-0.1.0/src/infra/cli/init.py +224 -0
  31. infra_lang-0.1.0/src/infra/cli/lsp_cmd.py +31 -0
  32. infra_lang-0.1.0/src/infra/cli/main.py +77 -0
  33. infra_lang-0.1.0/src/infra/cli/printer.py +478 -0
  34. infra_lang-0.1.0/src/infra/cli/repl.py +137 -0
  35. infra_lang-0.1.0/src/infra/cli/validate.py +102 -0
  36. infra_lang-0.1.0/src/infra/config.py +126 -0
  37. infra_lang-0.1.0/src/infra/diff/__init__.py +0 -0
  38. infra_lang-0.1.0/src/infra/diff/engine.py +242 -0
  39. infra_lang-0.1.0/src/infra/errors/__init__.py +0 -0
  40. infra_lang-0.1.0/src/infra/errors/exceptions.py +232 -0
  41. infra_lang-0.1.0/src/infra/errors/reporter.py +194 -0
  42. infra_lang-0.1.0/src/infra/feedback.py +136 -0
  43. infra_lang-0.1.0/src/infra/lexer/__init__.py +0 -0
  44. infra_lang-0.1.0/src/infra/lexer/grammar.lark +861 -0
  45. infra_lang-0.1.0/src/infra/lexer/tokens.py +201 -0
  46. infra_lang-0.1.0/src/infra/lsp/__init__.py +0 -0
  47. infra_lang-0.1.0/src/infra/lsp/__main__.py +5 -0
  48. infra_lang-0.1.0/src/infra/lsp/completion.py +294 -0
  49. infra_lang-0.1.0/src/infra/lsp/folding.py +71 -0
  50. infra_lang-0.1.0/src/infra/lsp/quickfix.py +104 -0
  51. infra_lang-0.1.0/src/infra/lsp/semantic_tokens.py +175 -0
  52. infra_lang-0.1.0/src/infra/lsp/server.py +823 -0
  53. infra_lang-0.1.0/src/infra/lsp/signature.py +117 -0
  54. infra_lang-0.1.0/src/infra/lsp/symbols.py +257 -0
  55. infra_lang-0.1.0/src/infra/lsp/workspace_index.py +229 -0
  56. infra_lang-0.1.0/src/infra/lsp/workspace_symbols.py +99 -0
  57. infra_lang-0.1.0/src/infra/parser/__init__.py +165 -0
  58. infra_lang-0.1.0/src/infra/parser/ast_nodes.py +1064 -0
  59. infra_lang-0.1.0/src/infra/parser/location.py +19 -0
  60. infra_lang-0.1.0/src/infra/parser/transformer.py +2017 -0
  61. infra_lang-0.1.0/src/infra/resolver/__init__.py +0 -0
  62. infra_lang-0.1.0/src/infra/resolver/extends.py +116 -0
  63. infra_lang-0.1.0/src/infra/resolver/imports.py +117 -0
  64. infra_lang-0.1.0/src/infra/stdlib/__init__.py +0 -0
  65. infra_lang-0.1.0/src/infra/stdlib/functions.py +272 -0
  66. infra_lang-0.1.0/src/infra/stdlib/prelude.infra +24 -0
  67. infra_lang-0.1.0/src/infra/utils/__init__.py +0 -0
  68. infra_lang-0.1.0/src/infra/validation/__init__.py +8 -0
  69. infra_lang-0.1.0/src/infra/validation/k8s_validator.py +286 -0
  70. infra_lang-0.1.0/src/infra/validation/schema_validator.py +151 -0
  71. infra_lang-0.1.0/src/infra/version.py +4 -0
@@ -0,0 +1,45 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ build/
7
+ dist/
8
+ .venv/
9
+ venv/
10
+
11
+ # Tooling
12
+ .coverage
13
+ .coverage.*
14
+ htmlcov/
15
+ .mypy_cache/
16
+ .pytest_cache/
17
+ .ruff_cache/
18
+ .node_modules/
19
+
20
+ # Project output
21
+ infra-out/
22
+ *.pyc
23
+
24
+ # Editors / OS
25
+ .idea/
26
+ .vscode/
27
+ .DS_Store
28
+ *.swp
29
+
30
+ # Env files
31
+ .env
32
+ .env.*
33
+ !.env.example
34
+
35
+ # VS Code extension build artifacts
36
+ vscode-infra-lang/node_modules/
37
+ vscode-infra-lang/out/
38
+
39
+ # MkDocs build output
40
+ site/
41
+ .mutmut-cache/
42
+
43
+ # Local E2E tools
44
+ .tools/
45
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Infra Lang contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,262 @@
1
+ Metadata-Version: 2.5
2
+ Name: infra-lang
3
+ Version: 0.1.0
4
+ Summary: Write infrastructure once, compile it to Kubernetes, Compose, or GitHub Actions
5
+ Project-URL: Homepage, https://github.com/TuviDev/infra-lang
6
+ Project-URL: Repository, https://github.com/TuviDev/infra-lang
7
+ Project-URL: Documentation, https://github.com/TuviDev/infra-lang#readme
8
+ Project-URL: Bug Tracker, https://github.com/TuviDev/infra-lang/issues
9
+ Project-URL: Changelog, https://github.com/TuviDev/infra-lang/blob/main/CHANGELOG.md
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: devops,docker-compose,dsl,github-actions,iac,infrastructure,infrastructure-as-code,kubernetes,platform-engineering,sre,terraform
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: System Administrators
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: Implementation :: CPython
24
+ Classifier: Topic :: Software Development :: Build Tools
25
+ Classifier: Topic :: Software Development :: Compilers
26
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
+ Classifier: Topic :: System :: Systems Administration
28
+ Classifier: Typing :: Typed
29
+ Requires-Python: >=3.11
30
+ Requires-Dist: lark>=1.1.0
31
+ Requires-Dist: prompt-toolkit>=3.0.0
32
+ Requires-Dist: pyyaml>=6.0
33
+ Requires-Dist: rich>=13.0.0
34
+ Requires-Dist: ruamel-yaml>=0.18.0
35
+ Requires-Dist: typer>=0.9.0
36
+ Requires-Dist: watchdog>=4.0.0
37
+ Provides-Extra: dev
38
+ Requires-Dist: black>=24.0.0; extra == 'dev'
39
+ Requires-Dist: hypothesis>=6.0.0; extra == 'dev'
40
+ Requires-Dist: mypy>=1.0.0; extra == 'dev'
41
+ Requires-Dist: pygls<2.0,>=1.3.0; extra == 'dev'
42
+ Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
43
+ Requires-Dist: pytest-xdist>=3.0.0; extra == 'dev'
44
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
45
+ Requires-Dist: ruff>=0.4.0; extra == 'dev'
46
+ Provides-Extra: docs
47
+ Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
48
+ Provides-Extra: lsp
49
+ Requires-Dist: pygls<2.0,>=1.3.0; extra == 'lsp'
50
+ Description-Content-Type: text/markdown
51
+
52
+ # Infra Lang
53
+
54
+ **Write infrastructure once, compile it to Kubernetes, Compose, or GitHub Actions.**
55
+
56
+ [![CI](https://img.shields.io/github/actions/workflow/status/TuviDev/infra-lang/ci.yml?branch=main)](https://github.com/TuviDev/infra-lang/actions)
57
+ [![Docs](https://img.shields.io/badge/docs-online-blue)](https://TuviDev.github.io/infra-lang/)
58
+ [![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
59
+ [![Python](https://img.shields.io/badge/python-3.11%2B-blue)](https://www.python.org/)
60
+
61
+ Infra Lang is an Infrastructure-as-Code DSL for DevOps engineers, SREs, and
62
+ platform teams. You describe your application — services, databases, queues,
63
+ secrets, and pipelines — in one declarative `.infra` file, and Infra Lang
64
+ compiles it to Kubernetes YAML, Docker Compose, Terraform HCL, or a GitHub
65
+ Actions workflow. Instead of hand-writing and maintaining the same app in four
66
+ different formats, you maintain one source of truth.
67
+
68
+ ## Quick demo
69
+
70
+ A single `.infra` file describes a service:
71
+
72
+ ```infra
73
+ # app.infra
74
+ service api {
75
+ image: "myapp/api:v1.0.0"
76
+ replicas: 3
77
+ port 8080
78
+ health http("/health")
79
+ resources {
80
+ requests { cpu: 200m, memory: 256Mi }
81
+ limits { cpu: 1000m, memory: 512Mi }
82
+ }
83
+ }
84
+ ```
85
+
86
+ Compile it to Kubernetes:
87
+
88
+ ```bash
89
+ infra compile app.infra --target kubernetes
90
+ ```
91
+
92
+ Infra Lang produces the matching Deployment and Service:
93
+
94
+ ```yaml
95
+ apiVersion: apps/v1
96
+ kind: Deployment
97
+ metadata:
98
+ name: api
99
+ spec:
100
+ replicas: 3
101
+ selector:
102
+ matchLabels:
103
+ app.kubernetes.io/name: api
104
+ template:
105
+ spec:
106
+ containers:
107
+ - name: api
108
+ image: myapp/api:v1.0.0
109
+ ports:
110
+ - containerPort: 8080
111
+ name: port-0
112
+ resources:
113
+ requests: { cpu: 200m, memory: 256Mi }
114
+ limits: { cpu: 1000m, memory: 512Mi }
115
+ readinessProbe:
116
+ httpGet: { path: /health, port: 8080 }
117
+ ---
118
+ apiVersion: v1
119
+ kind: Service
120
+ metadata:
121
+ name: api
122
+ spec:
123
+ selector:
124
+ app.kubernetes.io/name: api
125
+ ports:
126
+ - port: 8080
127
+ targetPort: 8080
128
+ ```
129
+
130
+ The same file compiles to Docker Compose with no rewriting:
131
+
132
+ ```bash
133
+ infra compile app.infra --target compose
134
+ ```
135
+
136
+ A `pipeline` block compiles to a GitHub Actions workflow:
137
+
138
+ ```infra
139
+ pipeline ci {
140
+ trigger { branches: ["main"] }
141
+ stages {
142
+ test: { runsOn: "ubuntu-latest" steps { t: { run: "pytest" } } }
143
+ }
144
+ }
145
+ ```
146
+
147
+ ```bash
148
+ infra compile app.infra --target github
149
+ ```
150
+
151
+ ## Features
152
+
153
+ - **11 top-level resource types** — `service`, `database`, `cache`, `queue`,
154
+ `storage`, `network`, `secret`, `config`, `pipeline`, `environment`,
155
+ `cluster`.
156
+ - **5 compilation targets** — Kubernetes (17 resource kinds), **Helm charts**,
157
+ Docker Compose, Terraform HCL (AWS/GCP/Azure), GitHub Actions.
158
+ - **Compiler-grade validation** — 30+ error codes with source locations and
159
+ actionable hints; invalid configs fail before anything is emitted.
160
+ - **Built-in security linter** (SEC001–SEC010) and **reliability linter**
161
+ (REL001–REL014); `Error`-severity findings block compilation.
162
+ - **A language server** — context-aware completion, hover docs, live
163
+ diagnostics with links and related info, go-to-definition, find-references,
164
+ workspace symbols, symbol rename, signature help, document highlight,
165
+ semantic tokens, folding, formatting, and quick-fixes — all across every
166
+ `.infra` file on disk.
167
+ - **A formatter, REPL, and diff engine** — `infra fmt`, `infra repl`, and
168
+ `infra diff` for reviewing changes.
169
+ - **Reusable pieces** — template-string interpolation, `import` with cycle
170
+ detection, `extends` inheritance, 25+ stdlib functions and a prelude of
171
+ shared constants.
172
+
173
+ ## Try it in Codespaces
174
+
175
+ Click the button below to open this project in GitHub Codespaces:
176
+
177
+ [![Open in Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/TuviDev/infra-lang)
178
+
179
+ No local installation needed — full dev environment in about 2 minutes
180
+ (Python 3.12, Docker-in-Docker, kubectl/helm, Ruff/Mypy extensions).
181
+
182
+ ## Installation
183
+
184
+ ```bash
185
+ pip install git+https://github.com/TuviDev/infra-lang.git
186
+ ```
187
+
188
+ With the language server (recommended for VS Code):
189
+
190
+ ```bash
191
+ pip install 'infra-lang[lsp]'
192
+ ```
193
+
194
+ Verify:
195
+
196
+ ```bash
197
+ infra --version
198
+ infra --help
199
+ ```
200
+
201
+ > **Note:** PyPI publishing is coming soon. Until then, install from Git.
202
+
203
+ **Requirements:** Python 3.11+.
204
+
205
+ ## Getting started
206
+
207
+ Full documentation is hosted at **[TuviDev.github.io/infra-lang](https://TuviDev.github.io/infra-lang/)**.
208
+
209
+ The fastest path is the [5-minute quickstart](https://TuviDev.github.io/infra-lang/quickstart/). In short:
210
+
211
+ 1. **Write** a `.infra` file (see the demo above).
212
+ 2. **Validate** it: `infra validate app.infra`
213
+ 3. **Compile** to a target: `infra compile app.infra --target kubernetes`
214
+ 4. **Inspect** the output in `infra-out/`, or preview with `--dry-run`.
215
+ 5. **Iterate** with `infra fmt app.infra` and `infra diff app.infra app2.infra`.
216
+
217
+ There is also a [guided tutorial](https://TuviDev.github.io/infra-lang/tutorial/) and
218
+ commented [examples](examples/).
219
+
220
+ ## Supported targets
221
+
222
+ | Target | Command | What it generates |
223
+ |--------|---------|-------------------|
224
+ | **Kubernetes** | `-t kubernetes` | Deployments, Services, Ingress, StatefulSets, PVCs, ConfigMaps, Secrets, CronJobs, HPA, PDBs, NetworkPolicies, ResourceQuotas, Namespaces, RBAC, TopologySpreadConstraints |
225
+ | **Helm** | `-t helm` | A complete chart: `Chart.yaml`, `values.yaml`, `templates/`, `_helpers.tpl`, `.helmignore` |
226
+ | **Docker Compose** | `-t compose` | `docker-compose.yml`, `.env.example`, `Makefile` |
227
+ | **Terraform** | `-t terraform` | `main.tf`, `variables.tf`, `outputs.tf`, `providers.tf` (AWS/GCP/Azure) |
228
+ | **GitHub Actions** | `-t github` | `.github/workflows/*.yml`, `dependabot.yml` |
229
+
230
+ Not every resource type maps to every target — for example, `pipeline` compiles
231
+ only to GitHub Actions, and `cluster` only to Terraform. See the
232
+ [support matrix](https://TuviDev.github.io/infra-lang/support_matrix/) for the
233
+ full mapping.
234
+
235
+ ## Documentation
236
+
237
+ The documentation is hosted at **[TuviDev.github.io/infra-lang](https://TuviDev.github.io/infra-lang/)**.
238
+
239
+ | Doc | What it covers |
240
+ |-----|----------------|
241
+ | [Quickstart](https://TuviDev.github.io/infra-lang/quickstart/) | 5-minute first run |
242
+ | [Language spec](https://TuviDev.github.io/infra-lang/language_spec/) | Full DSL reference (blocks, fields, error codes) |
243
+ | [Support matrix](https://TuviDev.github.io/infra-lang/support_matrix/) | Which resources map to which targets |
244
+ | [LSP / editor support](https://TuviDev.github.io/infra-lang/lsp/) | VS Code extension and language server |
245
+ | [Known limitations](https://TuviDev.github.io/infra-lang/known_limitations/) | Honest boundaries of the project |
246
+
247
+ ## Contributing
248
+
249
+ Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for how to
250
+ set up a dev environment, add a backend or a grammar rule, and the coding
251
+ standards (ruff, mypy). Please read our [Security policy](SECURITY.md) before
252
+ reporting a vulnerability.
253
+
254
+ ## License
255
+
256
+ Licensed under the [MIT License](LICENSE).
257
+
258
+ ---
259
+
260
+ Infra Lang is inspired by the ideas behind [Terraform](https://www.terraform.io/),
261
+ [Score](https://score.dev/), and [Pulumi](https://www.pulumi.com/): declarative
262
+ infrastructure that is easy to read and hard to get wrong.
@@ -0,0 +1,211 @@
1
+ # Infra Lang
2
+
3
+ **Write infrastructure once, compile it to Kubernetes, Compose, or GitHub Actions.**
4
+
5
+ [![CI](https://img.shields.io/github/actions/workflow/status/TuviDev/infra-lang/ci.yml?branch=main)](https://github.com/TuviDev/infra-lang/actions)
6
+ [![Docs](https://img.shields.io/badge/docs-online-blue)](https://TuviDev.github.io/infra-lang/)
7
+ [![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
8
+ [![Python](https://img.shields.io/badge/python-3.11%2B-blue)](https://www.python.org/)
9
+
10
+ Infra Lang is an Infrastructure-as-Code DSL for DevOps engineers, SREs, and
11
+ platform teams. You describe your application — services, databases, queues,
12
+ secrets, and pipelines — in one declarative `.infra` file, and Infra Lang
13
+ compiles it to Kubernetes YAML, Docker Compose, Terraform HCL, or a GitHub
14
+ Actions workflow. Instead of hand-writing and maintaining the same app in four
15
+ different formats, you maintain one source of truth.
16
+
17
+ ## Quick demo
18
+
19
+ A single `.infra` file describes a service:
20
+
21
+ ```infra
22
+ # app.infra
23
+ service api {
24
+ image: "myapp/api:v1.0.0"
25
+ replicas: 3
26
+ port 8080
27
+ health http("/health")
28
+ resources {
29
+ requests { cpu: 200m, memory: 256Mi }
30
+ limits { cpu: 1000m, memory: 512Mi }
31
+ }
32
+ }
33
+ ```
34
+
35
+ Compile it to Kubernetes:
36
+
37
+ ```bash
38
+ infra compile app.infra --target kubernetes
39
+ ```
40
+
41
+ Infra Lang produces the matching Deployment and Service:
42
+
43
+ ```yaml
44
+ apiVersion: apps/v1
45
+ kind: Deployment
46
+ metadata:
47
+ name: api
48
+ spec:
49
+ replicas: 3
50
+ selector:
51
+ matchLabels:
52
+ app.kubernetes.io/name: api
53
+ template:
54
+ spec:
55
+ containers:
56
+ - name: api
57
+ image: myapp/api:v1.0.0
58
+ ports:
59
+ - containerPort: 8080
60
+ name: port-0
61
+ resources:
62
+ requests: { cpu: 200m, memory: 256Mi }
63
+ limits: { cpu: 1000m, memory: 512Mi }
64
+ readinessProbe:
65
+ httpGet: { path: /health, port: 8080 }
66
+ ---
67
+ apiVersion: v1
68
+ kind: Service
69
+ metadata:
70
+ name: api
71
+ spec:
72
+ selector:
73
+ app.kubernetes.io/name: api
74
+ ports:
75
+ - port: 8080
76
+ targetPort: 8080
77
+ ```
78
+
79
+ The same file compiles to Docker Compose with no rewriting:
80
+
81
+ ```bash
82
+ infra compile app.infra --target compose
83
+ ```
84
+
85
+ A `pipeline` block compiles to a GitHub Actions workflow:
86
+
87
+ ```infra
88
+ pipeline ci {
89
+ trigger { branches: ["main"] }
90
+ stages {
91
+ test: { runsOn: "ubuntu-latest" steps { t: { run: "pytest" } } }
92
+ }
93
+ }
94
+ ```
95
+
96
+ ```bash
97
+ infra compile app.infra --target github
98
+ ```
99
+
100
+ ## Features
101
+
102
+ - **11 top-level resource types** — `service`, `database`, `cache`, `queue`,
103
+ `storage`, `network`, `secret`, `config`, `pipeline`, `environment`,
104
+ `cluster`.
105
+ - **5 compilation targets** — Kubernetes (17 resource kinds), **Helm charts**,
106
+ Docker Compose, Terraform HCL (AWS/GCP/Azure), GitHub Actions.
107
+ - **Compiler-grade validation** — 30+ error codes with source locations and
108
+ actionable hints; invalid configs fail before anything is emitted.
109
+ - **Built-in security linter** (SEC001–SEC010) and **reliability linter**
110
+ (REL001–REL014); `Error`-severity findings block compilation.
111
+ - **A language server** — context-aware completion, hover docs, live
112
+ diagnostics with links and related info, go-to-definition, find-references,
113
+ workspace symbols, symbol rename, signature help, document highlight,
114
+ semantic tokens, folding, formatting, and quick-fixes — all across every
115
+ `.infra` file on disk.
116
+ - **A formatter, REPL, and diff engine** — `infra fmt`, `infra repl`, and
117
+ `infra diff` for reviewing changes.
118
+ - **Reusable pieces** — template-string interpolation, `import` with cycle
119
+ detection, `extends` inheritance, 25+ stdlib functions and a prelude of
120
+ shared constants.
121
+
122
+ ## Try it in Codespaces
123
+
124
+ Click the button below to open this project in GitHub Codespaces:
125
+
126
+ [![Open in Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/TuviDev/infra-lang)
127
+
128
+ No local installation needed — full dev environment in about 2 minutes
129
+ (Python 3.12, Docker-in-Docker, kubectl/helm, Ruff/Mypy extensions).
130
+
131
+ ## Installation
132
+
133
+ ```bash
134
+ pip install git+https://github.com/TuviDev/infra-lang.git
135
+ ```
136
+
137
+ With the language server (recommended for VS Code):
138
+
139
+ ```bash
140
+ pip install 'infra-lang[lsp]'
141
+ ```
142
+
143
+ Verify:
144
+
145
+ ```bash
146
+ infra --version
147
+ infra --help
148
+ ```
149
+
150
+ > **Note:** PyPI publishing is coming soon. Until then, install from Git.
151
+
152
+ **Requirements:** Python 3.11+.
153
+
154
+ ## Getting started
155
+
156
+ Full documentation is hosted at **[TuviDev.github.io/infra-lang](https://TuviDev.github.io/infra-lang/)**.
157
+
158
+ The fastest path is the [5-minute quickstart](https://TuviDev.github.io/infra-lang/quickstart/). In short:
159
+
160
+ 1. **Write** a `.infra` file (see the demo above).
161
+ 2. **Validate** it: `infra validate app.infra`
162
+ 3. **Compile** to a target: `infra compile app.infra --target kubernetes`
163
+ 4. **Inspect** the output in `infra-out/`, or preview with `--dry-run`.
164
+ 5. **Iterate** with `infra fmt app.infra` and `infra diff app.infra app2.infra`.
165
+
166
+ There is also a [guided tutorial](https://TuviDev.github.io/infra-lang/tutorial/) and
167
+ commented [examples](examples/).
168
+
169
+ ## Supported targets
170
+
171
+ | Target | Command | What it generates |
172
+ |--------|---------|-------------------|
173
+ | **Kubernetes** | `-t kubernetes` | Deployments, Services, Ingress, StatefulSets, PVCs, ConfigMaps, Secrets, CronJobs, HPA, PDBs, NetworkPolicies, ResourceQuotas, Namespaces, RBAC, TopologySpreadConstraints |
174
+ | **Helm** | `-t helm` | A complete chart: `Chart.yaml`, `values.yaml`, `templates/`, `_helpers.tpl`, `.helmignore` |
175
+ | **Docker Compose** | `-t compose` | `docker-compose.yml`, `.env.example`, `Makefile` |
176
+ | **Terraform** | `-t terraform` | `main.tf`, `variables.tf`, `outputs.tf`, `providers.tf` (AWS/GCP/Azure) |
177
+ | **GitHub Actions** | `-t github` | `.github/workflows/*.yml`, `dependabot.yml` |
178
+
179
+ Not every resource type maps to every target — for example, `pipeline` compiles
180
+ only to GitHub Actions, and `cluster` only to Terraform. See the
181
+ [support matrix](https://TuviDev.github.io/infra-lang/support_matrix/) for the
182
+ full mapping.
183
+
184
+ ## Documentation
185
+
186
+ The documentation is hosted at **[TuviDev.github.io/infra-lang](https://TuviDev.github.io/infra-lang/)**.
187
+
188
+ | Doc | What it covers |
189
+ |-----|----------------|
190
+ | [Quickstart](https://TuviDev.github.io/infra-lang/quickstart/) | 5-minute first run |
191
+ | [Language spec](https://TuviDev.github.io/infra-lang/language_spec/) | Full DSL reference (blocks, fields, error codes) |
192
+ | [Support matrix](https://TuviDev.github.io/infra-lang/support_matrix/) | Which resources map to which targets |
193
+ | [LSP / editor support](https://TuviDev.github.io/infra-lang/lsp/) | VS Code extension and language server |
194
+ | [Known limitations](https://TuviDev.github.io/infra-lang/known_limitations/) | Honest boundaries of the project |
195
+
196
+ ## Contributing
197
+
198
+ Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for how to
199
+ set up a dev environment, add a backend or a grammar rule, and the coding
200
+ standards (ruff, mypy). Please read our [Security policy](SECURITY.md) before
201
+ reporting a vulnerability.
202
+
203
+ ## License
204
+
205
+ Licensed under the [MIT License](LICENSE).
206
+
207
+ ---
208
+
209
+ Infra Lang is inspired by the ideas behind [Terraform](https://www.terraform.io/),
210
+ [Score](https://score.dev/), and [Pulumi](https://www.pulumi.com/): declarative
211
+ infrastructure that is easy to read and hard to get wrong.
@@ -0,0 +1,121 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "infra-lang"
7
+ version = "0.1.0"
8
+ description = "Write infrastructure once, compile it to Kubernetes, Compose, or GitHub Actions"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.11"
13
+ keywords = [
14
+ "infrastructure", "kubernetes", "docker-compose", "github-actions",
15
+ "terraform", "devops", "dsl", "iac", "infrastructure-as-code",
16
+ "platform-engineering", "sre",
17
+ ]
18
+ classifiers = [
19
+ "Development Status :: 3 - Alpha",
20
+ "Environment :: Console",
21
+ "Intended Audience :: Developers",
22
+ "Intended Audience :: System Administrators",
23
+ "License :: OSI Approved :: MIT License",
24
+ "Operating System :: OS Independent",
25
+ "Programming Language :: Python :: 3",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
28
+ "Programming Language :: Python :: 3.13",
29
+ "Programming Language :: Python :: Implementation :: CPython",
30
+ "Topic :: Software Development :: Build Tools",
31
+ "Topic :: Software Development :: Compilers",
32
+ "Topic :: Software Development :: Libraries :: Python Modules",
33
+ "Topic :: System :: Systems Administration",
34
+ "Typing :: Typed",
35
+ ]
36
+ dependencies = [
37
+ "lark>=1.1.0",
38
+ "typer>=0.9.0",
39
+ "rich>=13.0.0",
40
+ "ruamel.yaml>=0.18.0",
41
+ "pyyaml>=6.0",
42
+ "watchdog>=4.0.0",
43
+ "prompt_toolkit>=3.0.0",
44
+ ]
45
+
46
+ [project.optional-dependencies]
47
+ lsp = ["pygls>=1.3.0,<2.0"]
48
+ docs = [
49
+ "mkdocs-material>=9.5",
50
+ ]
51
+ dev = [
52
+ "pytest>=8.0.0",
53
+ "pytest-cov>=5.0.0",
54
+ "pytest-xdist>=3.0.0",
55
+ "hypothesis>=6.0.0",
56
+ "black>=24.0.0",
57
+ "ruff>=0.4.0",
58
+ "mypy>=1.0.0",
59
+ "pygls>=1.3.0,<2.0",
60
+ ]
61
+
62
+ [project.scripts]
63
+ infra = "infra.cli.main:app"
64
+
65
+ [project.urls]
66
+ Homepage = "https://github.com/TuviDev/infra-lang"
67
+ Repository = "https://github.com/TuviDev/infra-lang"
68
+ Documentation = "https://github.com/TuviDev/infra-lang#readme"
69
+ "Bug Tracker" = "https://github.com/TuviDev/infra-lang/issues"
70
+ Changelog = "https://github.com/TuviDev/infra-lang/blob/main/CHANGELOG.md"
71
+
72
+ [tool.hatch.build.targets.wheel]
73
+ packages = ["src/infra"]
74
+
75
+ [tool.hatch.build]
76
+ include = [
77
+ "src/infra/**/*.py",
78
+ "src/infra/**/*.lark",
79
+ "src/infra/**/*.infra",
80
+ ]
81
+
82
+ [tool.pytest.ini_options]
83
+ testpaths = ["tests"]
84
+ addopts = "-n auto --dist=loadfile"
85
+ markers = [
86
+ "unit: isolated, fast, no I/O",
87
+ "integration: multiple modules together",
88
+ "e2e: full user flow with subprocess",
89
+ "slow: takes > 2 seconds",
90
+ "behavioral: business behavior documentation",
91
+ "contracts: public API contract tests",
92
+ "live_e2e: real Docker/kind/kubectl E2E (skipped when tools missing)",
93
+ ]
94
+
95
+ [tool.ruff]
96
+ line-length = 88
97
+ target-version = "py311"
98
+
99
+ [tool.ruff.lint]
100
+ select = ["E", "F", "W", "I", "N"]
101
+
102
+ [tool.mypy]
103
+ python_version = "3.11"
104
+ ignore_missing_imports = true
105
+
106
+ [tool.coverage.run]
107
+ source = ["src/infra"]
108
+ omit = ["*/tests/*", "*/__main__.py"]
109
+
110
+ [tool.coverage.report]
111
+ fail_under = 88
112
+ show_missing = true
113
+
114
+ [tool.mutmut]
115
+ # Mutation testing. NOTE: the project uses a src/ layout; mutmut's coverage
116
+ # mapping needs a flat package copy to associate tests with mutants. See
117
+ # docs/testing_quality.md for the exact working procedure (run from a flat
118
+ # copy with `source_paths = ["infra"]`).
119
+ source_paths = ["src/infra"]
120
+ pytest_add_cli_args = ["-q", "-p", "no:cacheprovider", "-o", "addopts=", "-k", "not live_e2e"]
121
+ pytest_add_cli_args_test_selection = ["tests/test_security_checker.py", "tests/test_security_advanced.py"]