Skip to content

Commit 6b9e94a

Browse files
committed
Address review comments
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
1 parent 0a739c7 commit 6b9e94a

4 files changed

Lines changed: 39 additions & 5 deletions

File tree

docs/resources/branch_default.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: |-
88

99
Configures the default branch for a GitHub repository.
1010

11-
~> **Note:** This resource is incompatible with the `default_branch` option of the `github_repository` resource. Using both will result in plans always showing a diff.
11+
~> This resource is incompatible with the `default_branch` option of the [`github_repository`](repository) resource. Using both will result in plans always showing a diff.
1212

1313
## Example Usage
1414

@@ -68,7 +68,18 @@ resource "github_branch_default" "default" {
6868

6969
## Import
7070

71-
GitHub Branch Defaults can be imported using the repository name with the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), for example:
71+
Import is supported using the following syntax:
72+
73+
In Terraform v1.5.0 and later, the [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used with the `id` attribute, for example:
74+
75+
```terraform
76+
import {
77+
to = github_branch_default.default
78+
id = "example"
79+
}
80+
```
81+
82+
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
7283

7384
```shell
7485
terraform import github_branch_default.branch_default my-repo
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import {
2+
to = github_branch_default.default
3+
id = "example"
4+
}

github/resource_github_branch_default.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ func resourceGithubBranchDefaultRead(ctx context.Context, d *schema.ResourceData
180180
}
181181

182182
func resourceGithubBranchDefaultUpdate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
183-
ctx = tflog.SetField(ctx, "resource_id", d.Id())
184183
meta, _ := m.(*Owner)
185184
client := meta.v3client
186185
owner := meta.name

templates/resources/branch_default.md.tmpl

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: |-
88

99
{{ .Description | trimspace }}
1010

11-
~> **Note:** This resource is incompatible with the `default_branch` option of the `github_repository` resource. Using both will result in plans always showing a diff.
11+
~> This resource is incompatible with the `default_branch` option of the [`github_repository`](repository) resource. Using both will result in plans always showing a diff.
1212

1313
{{ if .HasExamples -}}
1414
## Example Usage
@@ -20,9 +20,29 @@ description: |-
2020
{{- end }}
2121

2222
{{ .SchemaMarkdown | trimspace }}
23+
{{- if or .HasImport .HasImportIDConfig .HasImportIdentityConfig }}
2324

2425
## Import
2526

26-
GitHub Branch Defaults can be imported using the repository name with the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), for example:
27+
Import is supported using the following syntax:
28+
{{- end }}
29+
{{- if .HasImportIdentityConfig }}
30+
31+
In Terraform v1.12.0 and later, the [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used with the `identity` attribute, for example:
32+
33+
{{tffile .ImportIdentityConfigFile }}
34+
35+
{{ .IdentitySchemaMarkdown | trimspace }}
36+
{{- end }}
37+
{{- if .HasImportIDConfig }}
38+
39+
In Terraform v1.5.0 and later, the [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used with the `id` attribute, for example:
40+
41+
{{tffile .ImportIDConfigFile }}
42+
{{- end }}
43+
{{- if .HasImport }}
44+
45+
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
2746

2847
{{codefile "shell" .ImportFile }}
48+
{{- end }}

0 commit comments

Comments
 (0)