Skip to content

Commit 37e4a02

Browse files
committed
fixup! fix: Refactor repository custom property
1 parent e54f259 commit 37e4a02

3 files changed

Lines changed: 23 additions & 9 deletions

github/resource_github_repository_custom_property.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,6 @@ func resourceGithubRepositoryCustomPropertyRead(ctx context.Context, d *schema.R
186186
return diag.FromErr(err)
187187
}
188188

189-
id, err := buildID(owner, repoName, propertyName)
190-
if err != nil {
191-
return diag.FromErr(err)
192-
}
193-
d.SetId(id)
194-
195189
if err := d.Set("property_value", propertyValue); err != nil {
196190
return diag.FromErr(err)
197191
}

github/resource_github_repository_custom_property_migration.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package github
33
import (
44
"context"
55
"fmt"
6-
"log"
76

87
"github.com/google/go-github/v88/github"
8+
"github.com/hashicorp/terraform-plugin-log/tflog"
99
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1010
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
1111
)
@@ -53,7 +53,7 @@ func resourceGithubRepositoryCustomPropertyStateUpgradeV0(ctx context.Context, r
5353
client := meta.v3client
5454
owner := meta.name
5555

56-
log.Printf("[DEBUG] GitHub Repository Custom Property Attributes before migration: %#v", rawState)
56+
tflog.Debug(ctx, "GitHub Repository Custom Property Attributes before migration: %#v", rawState)
5757

5858
repoName, ok := rawState["repository"].(string)
5959
if !ok {
@@ -68,7 +68,7 @@ func resourceGithubRepositoryCustomPropertyStateUpgradeV0(ctx context.Context, r
6868
repoID := int(repo.GetID())
6969
rawState["repository_id"] = repoID
7070

71-
log.Printf("[DEBUG] GitHub Repository Custom Property Attributes after migration: %#v", rawState)
71+
tflog.Debug(ctx, "GitHub Repository Custom Property Attributes after migration: %#v", rawState)
7272

7373
return rawState, nil
7474
}

github/resource_github_repository_custom_property_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ resource "github_repository_custom_property" "test" {
5050
PreCheck: func() { skipUnlessHasOrgs(t) },
5151
ProviderFactories: providerFactories,
5252
Steps: []resource.TestStep{
53+
{
54+
Config: fmt.Sprintf(config, `[]`),
55+
ExpectError: regexp.MustCompile(`Not enough list items`),
56+
PlanOnly: true,
57+
},
5358
{
5459
Config: fmt.Sprintf(config, fmt.Sprintf(`["%s"]`, option1)),
5560
ConfigStateChecks: []statecheck.StateCheck{
@@ -112,6 +117,11 @@ resource "github_repository_custom_property" "test" {
112117
PreCheck: func() { skipUnlessHasOrgs(t) },
113118
ProviderFactories: providerFactories,
114119
Steps: []resource.TestStep{
120+
{
121+
Config: fmt.Sprintf(config, `[]`),
122+
ExpectError: regexp.MustCompile(`Not enough list items`),
123+
PlanOnly: true,
124+
},
115125
{
116126
Config: fmt.Sprintf(config, fmt.Sprintf(`["%s", "%s"]`, option1, option2)),
117127
ConfigStateChecks: []statecheck.StateCheck{
@@ -170,6 +180,11 @@ resource "github_repository_custom_property" "test" {
170180
PreCheck: func() { skipUnlessHasOrgs(t) },
171181
ProviderFactories: providerFactories,
172182
Steps: []resource.TestStep{
183+
{
184+
Config: fmt.Sprintf(config, `[]`),
185+
ExpectError: regexp.MustCompile(`Not enough list items`),
186+
PlanOnly: true,
187+
},
173188
{
174189
Config: fmt.Sprintf(config, `["true"]`),
175190
ConfigStateChecks: []statecheck.StateCheck{
@@ -228,6 +243,11 @@ resource "github_repository_custom_property" "test" {
228243
PreCheck: func() { skipUnlessHasOrgs(t) },
229244
ProviderFactories: providerFactories,
230245
Steps: []resource.TestStep{
246+
{
247+
Config: fmt.Sprintf(config, `[]`),
248+
ExpectError: regexp.MustCompile(`Not enough list items`),
249+
PlanOnly: true,
250+
},
231251
{
232252
Config: fmt.Sprintf(config, `["https://example.com"]`),
233253
ConfigStateChecks: []statecheck.StateCheck{

0 commit comments

Comments
 (0)