Skip to content

Commit 760bea9

Browse files
authored
Merge pull request #84 from ory/docs/update_docs
docs: contributing and readme update
2 parents 41de1af + da16aef commit 760bea9

File tree

3 files changed

+56
-36
lines changed

3 files changed

+56
-36
lines changed

.githooks/pre-commit

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if [ -n "$(gofmt -l .)" ]; then
1111
echo "Error: The following files are not formatted:"
1212
gofmt -l .
1313
echo ""
14-
echo "Run 'make fmt' to fix formatting."
14+
echo "Run 'make format' to fix formatting."
1515
exit 1
1616
fi
1717

@@ -21,12 +21,17 @@ go vet ./...
2121

2222
# Lint
2323
echo "Running golangci-lint..."
24-
if command -v golangci-lint &> /dev/null; then
24+
if [ -x ".bin/golangci-lint" ]; then
25+
.bin/golangci-lint run
26+
elif command -v golangci-lint &> /dev/null; then
2527
golangci-lint run
26-
elif [ -x "$(go env GOPATH)/bin/golangci-lint" ]; then
27-
"$(go env GOPATH)/bin/golangci-lint" run
2828
else
29-
echo "Warning: golangci-lint not found, skipping. Install with: make tools"
29+
GOPATH_BIN="$(go env GOPATH 2>/dev/null)/bin/golangci-lint"
30+
if [ -n "$GOPATH_BIN" ] && [ -x "$GOPATH_BIN" ]; then
31+
"$GOPATH_BIN" run
32+
else
33+
echo "Warning: golangci-lint not found, skipping. Install with: make deps"
34+
fi
3035
fi
3136

3237
# Build check

CONTRIBUTING.md

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Thank you for your interest in contributing to the Ory Terraform Provider!
66

77
### Prerequisites
88

9-
- [Go](https://golang.org/doc/install) >= 1.21
9+
- [Go](https://golang.org/doc/install) (see version in `go.mod`)
1010
- [Terraform](https://www.terraform.io/downloads) >= 1.0
11-
- An [Ory Network](https://console.ory.sh/) account for testing
11+
- An [Ory Network](https://console.ory.sh/) account for acceptance testing
1212

1313
### Building
1414

@@ -17,14 +17,16 @@ Thank you for your interest in contributing to the Ory Terraform Provider!
1717
git clone https://github.com/ory/terraform-provider-ory.git
1818
cd terraform-provider-ory
1919

20-
# Install development tools and set up git hooks
21-
make tools
22-
make hooks
20+
# Install dependencies
21+
make deps
22+
23+
# Set up pre-commit hooks
24+
git config core.hooksPath .githooks
2325

2426
# Build
2527
make build
2628

27-
# Install locally
29+
# Install locally (to ~/.terraform.d/plugins/)
2830
make install
2931
```
3032

@@ -42,8 +44,8 @@ The provider has two types of tests:
4244
Unit tests can be run without any credentials:
4345

4446
```bash
45-
make test # Run all unit tests
46-
make test-short # Run unit tests in short mode
47+
make test # Run all unit tests with coverage
48+
make test-short # Run unit tests in short mode (CI runs these with coverage enabled)
4749
```
4850

4951
### Acceptance Tests
@@ -58,20 +60,26 @@ Acceptance tests run against a **pre-created Ory project**. The project must be
5860
cp .env.example .env
5961
```
6062

61-
The `.env` file is gitignored and automatically loaded by `make` targets. At minimum you need:
63+
The `.env` file is gitignored and automatically loaded by `make` targets.
64+
65+
**Required** (validated by `make env-check`):
6266

6367
```bash
64-
# Workspace credentials
6568
ORY_WORKSPACE_API_KEY=ory_wak_...
6669
ORY_WORKSPACE_ID=...
70+
```
71+
72+
**Recommended** (needed by most resource tests):
6773

68-
# Pre-created test project
74+
```bash
6975
ORY_PROJECT_ID=...
7076
ORY_PROJECT_SLUG=...
7177
ORY_PROJECT_API_KEY=ory_pat_...
7278
ORY_PROJECT_ENVIRONMENT=prod
7379
```
7480

81+
When set, tests use this persistent project instead of creating ephemeral ones. The project must have keto namespaces and dynamic client registration configured. See `.env.example` for the full list of variables.
82+
7583
#### Running Acceptance Tests
7684

7785
```bash
@@ -94,6 +102,8 @@ Some tests require specific Ory plan features. Enable them with environment vari
94102
| `ORY_PROJECT_TESTS_ENABLED=true` | Run project creation/deletion tests |
95103
| `ORY_EVENT_STREAM_TESTS_ENABLED=true` | Run event stream tests (requires Enterprise plan + AWS setup below) |
96104

105+
> **Note:** CI enables **all** feature flags, including `ORY_PROJECT_TESTS_ENABLED`, on pull requests. Locally, `make test-acc-all` enables all flags **except** `ORY_PROJECT_TESTS_ENABLED` by default (project creation/deletion tests are excluded because they are slow and potentially destructive). To run those locally, set `ORY_PROJECT_TESTS_ENABLED=true` explicitly.
106+
97107
#### Event Stream Tests
98108

99109
Event stream tests have additional requirements beyond a feature flag because they interact with real AWS infrastructure:
@@ -208,7 +218,7 @@ To use a locally built provider, create a `~/.terraformrc` file:
208218
```hcl
209219
provider_installation {
210220
dev_overrides {
211-
"ory/terraform-provider-ory" = "/path/to/terraform-provider-ory"
221+
"ory/ory" = "/path/to/terraform-provider-ory"
212222
}
213223
direct {}
214224
}
@@ -267,14 +277,14 @@ After editing templates, run `make format` to regenerate docs.
267277

268278
### Pre-Commit Checklist
269279

270-
Run these checks locally before committing. They mirror what CI runs on every push.
280+
Run these checks locally before committing. They mirror what CI runs on every pull request.
271281

272282
#### Required
273283

274284
```bash
275285
make build # Verify the provider compiles
276286
make format # Format code, tidy modules, regenerate docs, fix lint issues
277-
make test # Run unit tests (no API calls needed)
287+
make test-short # Run unit tests in short mode (matches CI)
278288
```
279289

280290
`make format` runs several tools in sequence:
@@ -287,7 +297,8 @@ make test # Run unit tests (no API calls needed)
287297
#### Recommended
288298

289299
```bash
290-
make sec # Run all security scans (govulncheck + gosec + gitleaks)
300+
make sec # Run security scans (govulncheck + gosec + gitleaks)
301+
make sec-trivy # Run trivy vulnerability scan (requires build first)
291302
make licenses # Check dependency licenses
292303
```
293304

@@ -298,16 +309,18 @@ You can also run security scans individually:
298309
| `make sec-vuln` | govulncheck | Known Go vulnerabilities |
299310
| `make sec-gosec` | gosec | Go security patterns (injection, file traversal, etc.) |
300311
| `make sec-gitleaks` | gitleaks | Hardcoded secrets and credentials |
301-
| `make sec-trivy` | trivy | Vulnerability, secret, and misconfig scanning |
312+
| `make sec-trivy` | trivy | Vulnerability, secret, and misconfig scanning (not included in `make sec`) |
313+
314+
> **Note:** `make sec-trivy` is **not** included in `make sec` — it must be run separately and requires a prior `make build`.
302315
303316
#### Quick Reference
304317

305318
```bash
306319
# Minimum before committing:
307-
make build && make format && make test
320+
make build && make format && make test-short
308321

309322
# Full CI-equivalent check:
310-
make build && make format && make test && make sec && make licenses
323+
make build && make format && make test-short && make sec && make sec-trivy && make licenses
311324
```
312325

313326
### Code Style
@@ -332,7 +345,7 @@ docs: add algorithm guidance to JWK docs
332345
1. Fork the repository
333346
2. Create a feature branch from `main`
334347
3. Make your changes
335-
4. Run checks: `make build && make format && make test`
348+
4. Run checks: `make build && make format && make test-short`
336349
5. Submit a pull request using the PR template
337350

338351
Please include:

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ A Terraform provider for managing [Ory Network](https://www.ory.sh/) resources u
4444
## Requirements
4545

4646
- [Terraform](https://www.terraform.io/downloads) >= 1.0
47-
- [Go](https://golang.org/doc/install) >= 1.21 (for building from source)
47+
- [Go](https://golang.org/doc/install) (see version in `go.mod`; for building from source)
4848
- An [Ory Network](https://console.ory.sh/) account
4949

5050
## Installation
@@ -302,22 +302,24 @@ Acceptance tests run against a **pre-created Ory project**. Copy `.env.example`
302302
cp .env.example .env
303303
```
304304

305-
At minimum you need:
305+
The `.env` file is gitignored and automatically loaded by `make` targets.
306+
307+
**Required** (validated by `make env-check`):
306308

307309
```bash
308-
# Workspace credentials
309310
ORY_WORKSPACE_API_KEY=ory_wak_...
310311
ORY_WORKSPACE_ID=...
312+
```
313+
314+
**Recommended** (needed by most resource tests):
311315

312-
# Pre-created test project
316+
```bash
313317
ORY_PROJECT_ID=...
314318
ORY_PROJECT_SLUG=...
315319
ORY_PROJECT_API_KEY=ory_pat_...
316320
ORY_PROJECT_ENVIRONMENT=prod
317321
```
318322

319-
The `.env` file is gitignored and automatically loaded by `make` targets.
320-
321323
```bash
322324
make test-acc # Standard acceptance tests
323325
make test-acc-verbose # With debug logging
@@ -433,26 +435,26 @@ templates/
433435

434436
### Pre-Commit Checklist
435437

436-
Run these checks locally before committing. They mirror what CI runs on every push.
438+
Run these checks locally before committing. They mirror what CI runs on every pull request.
437439

438440
```bash
439441
# Minimum before committing:
440-
make build && make format && make test
442+
make build && make format && make test-short
441443

442444
# Full CI-equivalent check:
443-
make build && make format && make test && make sec && make licenses
445+
make build && make format && make test-short && make sec && make sec-trivy && make licenses
444446
```
445447

446448
`make format` runs several tools in sequence: `go fmt`, `gofmt -s`, `terraform fmt`, `go mod tidy`, `tfplugindocs generate`, and `golangci-lint --fix`.
447449

448450
### Security Scanning
449451

450452
```bash
451-
make sec # Run all security scans
453+
make sec # Run security scans (govulncheck + gosec + gitleaks)
452454
make sec-vuln # govulncheck — known Go vulnerabilities
453455
make sec-gosec # gosec — Go security patterns
454456
make sec-gitleaks # gitleaks — hardcoded secrets
455-
make sec-trivy # trivy — vulnerability and misconfig scanning
457+
make sec-trivy # trivy — vulnerability and misconfig scanning (not included in `make sec`)
456458
```
457459

458460
## Contributing
@@ -461,7 +463,7 @@ Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed g
461463

462464
1. Fork the repository
463465
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
464-
3. Run checks: `make build && make format && make test`
466+
3. Run checks: `make build && make format && make test-short`
465467
4. Commit using [Conventional Commits](https://www.conventionalcommits.org/) format
466468
5. Open a Pull Request
467469

0 commit comments

Comments
 (0)