Skip to content

Commit 5eb602b

Browse files
authored
Merge pull request #38 from virtualroot/feat/yaml-source-of-truth
Use tools.yaml as source of truth
2 parents bc93a3c + a948b97 commit 5eb602b

7 files changed

Lines changed: 308 additions & 228 deletions

File tree

CLAUDE.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
**CanI.TF** is a static website comparing features between OpenTofu and Terraform. It exposes both an HTML comparison table and a JSON API at `/tools.json`.
8+
9+
## Development Workflow
10+
11+
Adding or updating features requires two steps:
12+
13+
1. Edit `tools/tools.yaml` — this is the source of truth (feature-centric: each feature lists per-tool data under a `tools:` map)
14+
2. Run `go run main.go` to validate and regenerate `data/tools.json` and `static/tools.json`
15+
16+
To preview the site locally:
17+
```bash
18+
hugo server --buildDrafts --disableFastRender
19+
```
20+
21+
Hugo version is pinned via `.tool-versions` (hugo 0.135.0). Install with `asdf install`.
22+
23+
## Architecture
24+
25+
- **`tools/tools.yaml`** — YAML source of truth. Feature-centric: a top-level `tools:` map holds metadata per tool, and a top-level `features:` list holds each feature with per-tool data under a `tools:` map. Omitting a tool key means that tool doesn't support the feature.
26+
- **`main.go`** — reads `tools/tools.yaml`, defines the JSON schema, validates the data, and writes `data/tools.json` + `static/tools.json`.
27+
- **`data/tools.json`** — consumed by Hugo templates at build time.
28+
- **`static/tools.json`** — served directly as the public API.
29+
- **`layouts/`** — Hugo templates. `_default/baseof.html` is the shell; `index.html` renders the comparison table by iterating the tools data.
30+
31+
## Data Schema
32+
33+
Each tool entry has: `version`, `versionURL`, `license`, `licenseURL`, `registry`, and `features[]`. Each feature has `name`, `version`, and optional `url`. Feature names are matched by string equality across tools to build the comparison table — a feature present in one tool but not the other renders as `-`.
34+
35+
## Deployment
36+
37+
Pushing to `main` triggers `.github/workflows/hugo.yml`, which builds with Hugo and deploys to GitHub Pages automatically.

data/tools.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
},
1414
{
1515
"name": "State encryption",
16-
"url": "https://opentofu.org/docs/language/state/encryption/",
17-
"version": "1.7"
16+
"version": "1.7",
17+
"url": "https://opentofu.org/docs/language/state/encryption/"
1818
},
1919
{
2020
"name": "Removed block",
@@ -128,6 +128,16 @@
128128
"name": "Provider-defined functions",
129129
"version": "1.8"
130130
},
131+
{
132+
"name": "Loopable import blocks",
133+
"version": "1.7",
134+
"url": "https://developer.hashicorp.com/terraform/language/v1.7.x/import#import-multiple-instances-with-for_each"
135+
},
136+
{
137+
"name": "templatefile() and templatestring() recursion",
138+
"version": "1.9",
139+
"url": "https://developer.hashicorp.com/terraform/language/functions/templatestring"
140+
},
131141
{
132142
"name": "Provider mocking",
133143
"version": "1.7"
@@ -137,30 +147,20 @@
137147
"version": "1.7"
138148
},
139149
{
140-
"name": "templatefile() and templatestring() recursion",
141-
"version": "1.9",
142-
"url": "https://developer.hashicorp.com/terraform/language/functions/templatestring"
150+
"name": "S3 native state locking",
151+
"version": "1.10",
152+
"url": "https://developer.hashicorp.com/terraform/language/v1.10.x/upgrade-guides#s3-backend"
143153
},
144154
{
145155
"name": "Ephemeral values and resources",
146156
"version": "1.10",
147157
"url": "https://developer.hashicorp.com/terraform/language/resources/ephemeral"
148158
},
149-
{
150-
"name": "S3 native state locking",
151-
"version": "1.10",
152-
"url": "https://developer.hashicorp.com/terraform/language/v1.10.x/upgrade-guides#s3-backend"
153-
},
154159
{
155160
"name": "Write-only attributes",
156161
"version": "1.11",
157162
"url": "https://developer.hashicorp.com/terraform/language/resources/ephemeral/write-only"
158163
},
159-
{
160-
"name": "Loopable import blocks",
161-
"version": "1.7",
162-
"url": "https://developer.hashicorp.com/terraform/language/v1.7.x/import#import-multiple-instances-with-for_each"
163-
},
164164
{
165165
"name": "Import via identity attribute",
166166
"version": "1.12",

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ go 1.23.1
44

55
require github.com/qri-io/jsonschema v0.2.1
66

7-
require github.com/qri-io/jsonpointer v0.1.1 // indirect
7+
require (
8+
github.com/qri-io/jsonpointer v0.1.1 // indirect
9+
gopkg.in/yaml.v3 v3.0.1 // indirect
10+
)

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
88
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
99
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1010
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
11+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
12+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
13+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)