Skip to content

Commit eb3f882

Browse files
docs: Update repository resource examples (#133)
Add examples for the `github_repository` resource splitting up using a template and standard usage. This also removes all of the optional arguments from the example to align with official provider documentation standards.
1 parent 2a3c9ae commit eb3f882

File tree

7 files changed

+76
-47
lines changed

7 files changed

+76
-47
lines changed

docs/resources/repository.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,39 @@ This resource allows you to create and manage repositories within your GitHub or
1111

1212
## Example Usage
1313

14+
### Standard
15+
16+
```terraform
17+
resource "github_repository" "example" {
18+
name = "terraform-aws-module"
19+
}
20+
```
21+
22+
### Create from a Template
23+
24+
Use a template to create a repository.
25+
26+
```terraform
27+
resource "github_repository" "example" {
28+
name = "terraform-aws-module"
29+
30+
template_repository = "terraform-module-template"
31+
}
32+
```
33+
34+
### Create from a Template and Specify Owner
35+
36+
Demonstrates creating a repository from a template owned by a different user or organization than the one configured in the provider.
37+
1438
```terraform
1539
resource "github_repository" "example" {
16-
name = "terraform-aws-module"
17-
description = "A Terraform module to manage AWS infrastructure."
18-
19-
homepage = "https://github.com"
20-
private = true
21-
has_issues = true
22-
has_projects = true
23-
has_wiki = true
24-
has_discussions = true
25-
auto_init = true
26-
gitignore_template = "Terraform"
27-
license_template = "mpl-2.0"
28-
allow_squash_merge = true
29-
allow_merge_commit = true
30-
allow_rebase_merge = false
31-
allow_auto_merge = true
32-
delete_branch_on_merge = true
33-
squash_merge_commit_title = "PR_TITLE"
34-
squash_merge_commit_message = "COMMIT_MESSAGES"
35-
merge_commit_title = "PR_TITLE"
36-
merge_commit_message = "PR_BODY"
37-
is_template = true
40+
name = "terraform-aws-module"
3841
3942
template_repository = "terraform-module-template"
4043
template_owner = "craigsloggett-lab"
4144
}
4245
```
46+
4347
<!-- schema generated by tfplugindocs -->
4448
## Schema
4549

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
11
resource "github_repository" "example" {
2-
name = "terraform-aws-module"
3-
description = "A Terraform module to manage AWS infrastructure."
4-
5-
homepage = "https://github.com"
6-
private = true
7-
has_issues = true
8-
has_projects = true
9-
has_wiki = true
10-
has_discussions = true
11-
auto_init = true
12-
gitignore_template = "Terraform"
13-
license_template = "mpl-2.0"
14-
allow_squash_merge = true
15-
allow_merge_commit = true
16-
allow_rebase_merge = false
17-
allow_auto_merge = true
18-
delete_branch_on_merge = true
19-
squash_merge_commit_title = "PR_TITLE"
20-
squash_merge_commit_message = "COMMIT_MESSAGES"
21-
merge_commit_title = "PR_TITLE"
22-
merge_commit_message = "PR_BODY"
23-
is_template = true
24-
25-
template_repository = "terraform-module-template"
26-
template_owner = "craigsloggett-lab"
2+
name = "terraform-aws-module"
273
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
resource "github_repository" "example" {
2+
name = "terraform-aws-module"
3+
4+
template_repository = "terraform-module-template"
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resource "github_repository" "example" {
2+
name = "terraform-aws-module"
3+
4+
template_repository = "terraform-module-template"
5+
template_owner = "craigsloggett-lab"
6+
}

internal/provider/repository_resource_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ func testAccRepositoryResourceTemplateOwnerDefaultConfig(name string) string {
475475
resource "github_repository" "test" {
476476
name = %[1]q
477477
template_repository = "terraform-module-template"
478+
template_owner = "craigsloggett-lab"
478479
479480
private = false
480481
has_issues = true

templates/resources.md.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ description: |-
1414

1515
{{codefile "terraform" .ExampleFile}}
1616
{{- end }}
17+
1718
{{ .SchemaMarkdown | trimspace }}
1819

1920
{{ if .HasImport -}}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
page_title: "{{.Name}} {{.Type}} - {{.RenderedProviderName}}"
3+
subcategory: ""
4+
description: |-
5+
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
6+
---
7+
8+
# {{.Name}} ({{.Type}})
9+
10+
{{ .Description | trimspace }}
11+
12+
## Example Usage
13+
14+
### Standard
15+
16+
{{ tffile "examples/resources/github_repository/resource.tf" }}
17+
18+
### Create from a Template
19+
20+
Use a template to create a repository.
21+
22+
{{ tffile "examples/resources/github_repository/resource_from_template.tf" }}
23+
24+
### Create from a Template and Specify Owner
25+
26+
Demonstrates creating a repository from a template owned by a different user or organization than the one configured in the provider.
27+
28+
{{ tffile "examples/resources/github_repository/resource_from_template_owner.tf" }}
29+
30+
{{ .SchemaMarkdown | trimspace }}
31+
32+
{{ if .HasImport -}}
33+
## Import
34+
35+
{{codefile "shell" .ImportFile}}
36+
{{- end }}

0 commit comments

Comments
 (0)