Skip to content

Commit 7e3eda8

Browse files
charislamgithub-schema-botsweatybridge
authored
docs: save json schema and add script to regenerate it (#29)
* docs: add schema.json * chore: add make script to generate schema.json * docs: update json schema auto-generation to use local version * ci: add auto-generation of json schema file * test: test github generate schema action * ci: regenerate json schema file * fix: small cleanup * Apply suggestions from code review --------- Co-authored-by: github-schema-bot <[email protected]> Co-authored-by: Han Qiao <[email protected]> Co-authored-by: Han Qiao <[email protected]>
1 parent fcd799a commit 7e3eda8

File tree

3 files changed

+332
-0
lines changed

3 files changed

+332
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Regenerates JSON schema whenever a PR is merged to main
2+
name: Generate JSON
3+
4+
on:
5+
pull_request:
6+
paths-ignore:
7+
- 'README.md'
8+
9+
# Needs write permissions to write the schema to the repo
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
schema:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-go@v5
19+
with:
20+
go-version-file: 'go.mod'
21+
cache: true
22+
- run: go mod download
23+
- run: make generate-json
24+
- run: |
25+
git config --global user.name 'github-schema-bot'
26+
git config --global user.email '[email protected]'
27+
if [[ `git status --porcelain` ]]; then
28+
echo "[bot] Schema changes detected, committing."
29+
git add docs/schema.json
30+
git commit -m "ci: regenerate json schema file"
31+
git push
32+
else
33+
echo "[bot] No schema changes detected, nothing to commit."
34+
fi

GNUmakefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,51 @@
11
default: testacc
22

3+
define MAINTF
4+
terraform {
5+
required_providers {
6+
supabase = {
7+
source = "supabase/supabase"
8+
version = "~> 1.0"
9+
}
10+
}
11+
}
12+
endef
13+
14+
define TERRAFORMRC
15+
provider_installation {
16+
dev_overrides {
17+
"supabase/supabase" = "$$PWD"
18+
}
19+
}
20+
endef
21+
22+
export MAINTF
23+
export TERRAFORMRC
24+
325
# Run acceptance tests
426
.PHONY: testacc
527
testacc:
628
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m
29+
30+
# Generate schema.json for documentation
31+
.PHONY: generate-json
32+
generate-json:
33+
@echo "Generating docs/schema.json"
34+
35+
@mkdir temp
36+
37+
@echo " - Generating temporary build"
38+
@go build -o ./temp
39+
40+
@echo " - Creating temporary terraform config and definition"
41+
@echo "$$TERRAFORMRC" > ./temp/local.tfrc.tpl
42+
@echo "$$MAINTF" > ./temp/main.tf
43+
@cd temp; envsubst '$${PWD}' < local.tfrc.tpl > local.tfrc
44+
45+
@echo " - Writing terraform schema to JSON"
46+
@cd temp; export TF_CLI_CONFIG_FILE="$$PWD/local.tfrc" && \
47+
terraform providers schema -json > schema.json && \
48+
jq . schema.json > ../docs/schema.json
49+
50+
@echo "Cleaning up"
51+
@rm -r temp

docs/schema.json

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
{
2+
"format_version": "1.0",
3+
"provider_schemas": {
4+
"registry.terraform.io/supabase/supabase": {
5+
"provider": {
6+
"version": 0,
7+
"block": {
8+
"attributes": {
9+
"access_token": {
10+
"type": "string",
11+
"description": "Supabase access token",
12+
"description_kind": "markdown",
13+
"optional": true,
14+
"sensitive": true
15+
},
16+
"endpoint": {
17+
"type": "string",
18+
"description": "Supabase API endpoint",
19+
"description_kind": "markdown",
20+
"optional": true
21+
}
22+
},
23+
"description_kind": "plain"
24+
}
25+
},
26+
"resource_schemas": {
27+
"supabase_branch": {
28+
"version": 0,
29+
"block": {
30+
"attributes": {
31+
"database": {
32+
"nested_type": {
33+
"attributes": {
34+
"host": {
35+
"type": "string",
36+
"description": "Host",
37+
"description_kind": "markdown",
38+
"computed": true
39+
},
40+
"id": {
41+
"type": "string",
42+
"description": "Branch project ref",
43+
"description_kind": "markdown",
44+
"computed": true
45+
},
46+
"jwt_secret": {
47+
"type": "string",
48+
"description": "JWT secret",
49+
"description_kind": "markdown",
50+
"computed": true,
51+
"sensitive": true
52+
},
53+
"password": {
54+
"type": "string",
55+
"description": "Password",
56+
"description_kind": "markdown",
57+
"computed": true,
58+
"sensitive": true
59+
},
60+
"port": {
61+
"type": "number",
62+
"description": "Port",
63+
"description_kind": "markdown",
64+
"computed": true
65+
},
66+
"status": {
67+
"type": "string",
68+
"description": "Status",
69+
"description_kind": "markdown",
70+
"computed": true
71+
},
72+
"user": {
73+
"type": "string",
74+
"description": "User",
75+
"description_kind": "markdown",
76+
"computed": true
77+
},
78+
"version": {
79+
"type": "string",
80+
"description": "Postgres version",
81+
"description_kind": "markdown",
82+
"computed": true
83+
}
84+
},
85+
"nesting_mode": "single"
86+
},
87+
"description": "Database connection details",
88+
"description_kind": "markdown",
89+
"computed": true
90+
},
91+
"git_branch": {
92+
"type": "string",
93+
"description": "Git branch",
94+
"description_kind": "markdown",
95+
"required": true
96+
},
97+
"id": {
98+
"type": "string",
99+
"description": "Branch identifier",
100+
"description_kind": "markdown",
101+
"computed": true
102+
},
103+
"parent_project_ref": {
104+
"type": "string",
105+
"description": "Parent project ref",
106+
"description_kind": "markdown",
107+
"required": true
108+
},
109+
"region": {
110+
"type": "string",
111+
"description": "Database region",
112+
"description_kind": "markdown",
113+
"optional": true
114+
}
115+
},
116+
"description": "Branch database resource",
117+
"description_kind": "markdown"
118+
}
119+
},
120+
"supabase_project": {
121+
"version": 0,
122+
"block": {
123+
"attributes": {
124+
"database_password": {
125+
"type": "string",
126+
"description": "Password for the project database",
127+
"description_kind": "markdown",
128+
"required": true,
129+
"sensitive": true
130+
},
131+
"id": {
132+
"type": "string",
133+
"description": "Project identifier",
134+
"description_kind": "markdown",
135+
"computed": true
136+
},
137+
"name": {
138+
"type": "string",
139+
"description": "Name of the project",
140+
"description_kind": "markdown",
141+
"required": true
142+
},
143+
"organization_id": {
144+
"type": "string",
145+
"description": "Reference to the organization",
146+
"description_kind": "markdown",
147+
"required": true
148+
},
149+
"region": {
150+
"type": "string",
151+
"description": "Region where the project is located",
152+
"description_kind": "markdown",
153+
"required": true
154+
}
155+
},
156+
"description": "Project resource",
157+
"description_kind": "markdown"
158+
}
159+
},
160+
"supabase_settings": {
161+
"version": 0,
162+
"block": {
163+
"attributes": {
164+
"api": {
165+
"type": "string",
166+
"description": "API settings as [serialised JSON](https://api.supabase.com/api/v1#/services/updatePostgRESTConfig)",
167+
"description_kind": "markdown",
168+
"optional": true
169+
},
170+
"auth": {
171+
"type": "string",
172+
"description": "Auth settings as [serialised JSON](https://api.supabase.com/api/v1#/projects%20config/updateV1AuthConfig)",
173+
"description_kind": "markdown",
174+
"optional": true
175+
},
176+
"id": {
177+
"type": "string",
178+
"description": "Project identifier",
179+
"description_kind": "markdown",
180+
"computed": true
181+
},
182+
"pooler": {
183+
"type": "string",
184+
"description": "Pooler settings as serialised JSON",
185+
"description_kind": "markdown",
186+
"optional": true
187+
},
188+
"project_ref": {
189+
"type": "string",
190+
"description": "Project reference ID",
191+
"description_kind": "markdown",
192+
"required": true
193+
},
194+
"storage": {
195+
"type": "string",
196+
"description": "Storage settings as serialised JSON",
197+
"description_kind": "markdown",
198+
"optional": true
199+
}
200+
},
201+
"description": "Settings resource",
202+
"description_kind": "markdown"
203+
}
204+
}
205+
},
206+
"data_source_schemas": {
207+
"supabase_branch": {
208+
"version": 0,
209+
"block": {
210+
"attributes": {
211+
"branches": {
212+
"nested_type": {
213+
"attributes": {
214+
"git_branch": {
215+
"type": "string",
216+
"description": "Git branch",
217+
"description_kind": "markdown",
218+
"computed": true
219+
},
220+
"id": {
221+
"type": "string",
222+
"description": "Branch identifier",
223+
"description_kind": "markdown",
224+
"computed": true
225+
},
226+
"project_ref": {
227+
"type": "string",
228+
"description": "Branch project ref",
229+
"description_kind": "markdown",
230+
"computed": true
231+
}
232+
},
233+
"nesting_mode": "set"
234+
},
235+
"description": "Branch databases",
236+
"description_kind": "markdown",
237+
"computed": true
238+
},
239+
"parent_project_ref": {
240+
"type": "string",
241+
"description": "Parent project ref",
242+
"description_kind": "markdown",
243+
"required": true
244+
}
245+
},
246+
"description": "Branch data source",
247+
"description_kind": "markdown"
248+
}
249+
}
250+
}
251+
}
252+
}
253+
}

0 commit comments

Comments
 (0)