Skip to content

Commit 15a467b

Browse files
committed
added linting and formatting
1 parent a081c1e commit 15a467b

18 files changed

Lines changed: 881 additions & 1055 deletions

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Fixes #(issue number)
2020
- [ ] I have added tests that prove my fix/feature works
2121
- [ ] I have updated documentation as needed
2222
- [ ] All new and existing tests pass (`make test`)
23-
- [ ] I have run the linter (`make lint`)
23+
- [ ] I have run the linter (`make format`)
2424

2525
## Testing
2626

.github/workflows/lint.yml

Lines changed: 6 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -12,106 +12,21 @@ permissions:
1212
jobs:
1313
format:
1414
name: Format
15-
runs-on: ubuntu-slim
15+
runs-on: ubuntu-latest
1616
timeout-minutes: 10
1717
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v4
18+
- uses: actions/checkout@v4
2019

21-
- name: Setup Go
22-
uses: actions/setup-go@v5
20+
- uses: actions/setup-go@v5
2321
with:
2422
go-version-file: 'go.mod'
2523
cache: true
2624

27-
- name: Setup Terraform
28-
uses: hashicorp/setup-terraform@v3
25+
- uses: hashicorp/setup-terraform@v3
2926
with:
3027
terraform_wrapper: false
3128

32-
- name: Run formatters
33-
run: make fmt-all
34-
35-
- name: Check for formatting changes
36-
run: |
37-
if ! git diff --exit-code; then
38-
echo ""
39-
echo "Files are not formatted correctly. Run 'make fmt-all' and commit the changes."
40-
echo ""
41-
git diff --stat
42-
exit 1
43-
fi
44-
45-
lint:
46-
name: Lint
47-
runs-on: ubuntu-slim
48-
timeout-minutes: 10
49-
steps:
50-
- name: Checkout
51-
uses: actions/checkout@v4
52-
53-
- name: Setup Go
54-
uses: actions/setup-go@v5
55-
with:
56-
go-version-file: 'go.mod'
57-
cache: true
58-
59-
- name: Run golangci-lint
60-
uses: golangci/golangci-lint-action@v6
61-
with:
62-
version: v2.0.2
63-
args: --timeout=5m
64-
65-
mod-tidy:
66-
name: Go Mod Tidy
67-
runs-on: ubuntu-slim
68-
timeout-minutes: 10
69-
steps:
70-
- name: Checkout
71-
uses: actions/checkout@v4
72-
73-
- name: Setup Go
74-
uses: actions/setup-go@v5
75-
with:
76-
go-version-file: 'go.mod'
77-
cache: true
78-
79-
- name: Run go mod tidy
80-
run: go mod tidy
81-
82-
- name: Check for changes
83-
run: |
84-
if ! git diff --exit-code go.mod go.sum; then
85-
echo ""
86-
echo "go.mod or go.sum is out of date. Run 'go mod tidy' and commit the changes."
87-
exit 1
88-
fi
89-
90-
docs:
91-
name: Documentation
92-
runs-on: ubuntu-slim
93-
timeout-minutes: 10
94-
steps:
95-
- name: Checkout
96-
uses: actions/checkout@v4
97-
98-
- name: Setup Go
99-
uses: actions/setup-go@v5
100-
with:
101-
go-version-file: 'go.mod'
102-
cache: true
103-
104-
- name: Install tfplugindocs
105-
run: go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest
106-
107-
- name: Generate docs
108-
run: tfplugindocs generate
29+
- run: make format
10930

11031
- name: Check for changes
111-
run: |
112-
if ! git diff --exit-code docs/; then
113-
echo ""
114-
echo "Documentation is out of date. Run 'make docs' and commit the changes."
115-
git diff --stat docs/
116-
exit 1
117-
fi
32+
run: git diff HEAD --exit-code --color

Makefile

Lines changed: 8 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -55,81 +55,21 @@ clean: ## Remove build artifacts
5555
# CODE QUALITY
5656
# ==============================================================================
5757

58-
.PHONY: fmt
59-
fmt: ## Format Go code
58+
.PHONY: format
59+
format: ## Format all code (Go, Terraform, modules, docs, lint fixes)
6060
go fmt ./...
6161
gofmt -s -w .
62-
63-
.PHONY: fmt-check
64-
fmt-check: ## Check Go code formatting (fails if not formatted)
65-
@if [ -n "$$(gofmt -l .)" ]; then \
66-
echo "The following files are not formatted correctly:"; \
67-
gofmt -l .; \
68-
echo ""; \
69-
echo "Run 'make fmt' to fix."; \
70-
exit 1; \
71-
fi
72-
73-
.PHONY: fmt-tf
74-
fmt-tf: ## Format Terraform example files
7562
terraform fmt -recursive examples/
76-
77-
.PHONY: fmt-tf-check
78-
fmt-tf-check: ## Check Terraform formatting (fails if not formatted)
79-
@if ! terraform fmt -check -recursive examples/; then \
80-
echo ""; \
81-
echo "Terraform files in examples/ are not formatted correctly."; \
82-
echo "Run 'make fmt-tf' to fix."; \
83-
exit 1; \
84-
fi
85-
86-
.PHONY: fmt-all
87-
fmt-all: fmt fmt-tf ## Format all code (Go and Terraform)
63+
go mod tidy
64+
@command -v tfplugindocs >/dev/null 2>&1 || { echo "Installing tfplugindocs..."; go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest; }
65+
tfplugindocs generate --provider-name ory
66+
@command -v golangci-lint >/dev/null 2>&1 || { echo "Installing golangci-lint..."; go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; }
67+
golangci-lint run --fix ./... || true
8868

8969
.PHONY: lint
90-
lint: ## Run Go linter
70+
lint: ## Run Go linter (without fixes)
9171
golangci-lint run ./...
9272

93-
.PHONY: lint-tf
94-
lint-tf: fmt-tf-check ## Check Terraform formatting (alias for fmt-tf-check)
95-
96-
.PHONY: vet
97-
vet: ## Run go vet
98-
go vet ./...
99-
100-
.PHONY: generate
101-
generate: ## Generate documentation and code
102-
go generate ./...
103-
104-
.PHONY: docs
105-
docs: ## Generate Terraform documentation
106-
@command -v tfplugindocs >/dev/null 2>&1 || { echo "Installing tfplugindocs..."; go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest; }
107-
tfplugindocs generate
108-
109-
.PHONY: docs-check
110-
docs-check: docs ## Check if documentation is up to date
111-
@if ! git diff --exit-code docs/; then \
112-
echo "Documentation is out of date. Run 'make docs' and commit the changes."; \
113-
exit 1; \
114-
fi
115-
116-
.PHONY: mod-tidy
117-
mod-tidy: ## Tidy go modules
118-
go mod tidy
119-
120-
.PHONY: mod-check
121-
mod-check: mod-tidy ## Check if go.mod/go.sum are up to date
122-
@if ! git diff --exit-code go.mod go.sum; then \
123-
echo "go.mod or go.sum is out of date. Run 'go mod tidy' and commit the changes."; \
124-
exit 1; \
125-
fi
126-
127-
.PHONY: check
128-
check: fmt-all vet lint ## Format and run all code quality checks
129-
130-
.PHONY: ci
131-
ci: fmt-check fmt-tf-check lint mod-check docs-check ## Run all CI checks (matches GitHub Actions, fails on issues)
132-
13373
# ==============================================================================
13474
# TESTING
13575
# ==============================================================================

docs/data-sources/project.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
---
2-
page_title: "ory_project Data Source - Ory"
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "ory_project Data Source - ory"
34
subcategory: ""
45
description: |-
56
Fetches information about an Ory project.
67
---
78

89
# ory_project (Data Source)
910

10-
Fetches information about an Ory project. Use this data source to read project details without managing the project lifecycle.
11+
Fetches information about an Ory project.
1112

1213
## Example Usage
1314

14-
### Read Current Project
15-
1615
```terraform
17-
# Read the project configured in the provider
16+
# Read the current project (from provider config)
1817
data "ory_project" "current" {}
1918
2019
output "project_name" {
@@ -24,25 +23,27 @@ output "project_name" {
2423
output "project_slug" {
2524
value = data.ory_project.current.slug
2625
}
27-
```
2826
29-
### Read Specific Project
27+
output "project_state" {
28+
value = data.ory_project.current.state
29+
}
3030
31-
```terraform
31+
# Read a specific project by ID
3232
data "ory_project" "other" {
3333
id = "other-project-uuid"
3434
}
3535
```
3636

37+
<!-- schema generated by tfplugindocs -->
3738
## Schema
3839

3940
### Optional
4041

41-
- `id` (String) - Project ID to look up. If not specified, uses the provider's project_id.
42+
- `id` (String) Project ID to look up. If not specified, uses the provider's project_id.
4243

4344
### Read-Only
4445

45-
- `name` (String) - The project name.
46-
- `slug` (String) - The project slug.
47-
- `state` (String) - The project state.
48-
- `workspace_id` (String) - The workspace ID the project belongs to.
46+
- `name` (String) The project name.
47+
- `slug` (String) The project slug.
48+
- `state` (String) The project state.
49+
- `workspace_id` (String) The workspace ID the project belongs to.

0 commit comments

Comments
 (0)