Skip to content

Commit 937f3ce

Browse files
committed
fix: Correct secret drift implementation
Signed-off-by: Steve Hipwell <[email protected]>
1 parent 935246a commit 937f3ce

30 files changed

Lines changed: 3834 additions & 1412 deletions

github/acc_test.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,21 @@ type testAccConfig struct {
8080

8181
var testAccConf *testAccConfig
8282

83+
var testAccProviders map[string]*schema.Provider = map[string]*schema.Provider{
84+
"github": Provider(),
85+
}
86+
8387
// providerFactories are used to instantiate a provider during acceptance testing.
8488
// The factory function will be invoked for every Terraform CLI command executed
8589
// to create a provider server to which the CLI can reattach.
86-
var providerFactories = map[string]func() (*schema.Provider, error){
87-
//nolint:unparam
88-
"github": func() (*schema.Provider, error) {
89-
return Provider(), nil
90-
},
91-
}
90+
var (
91+
providerFactories = map[string]func() (*schema.Provider, error){
92+
//nolint:unparam
93+
"github": func() (*schema.Provider, error) {
94+
return Provider(), nil
95+
},
96+
}
97+
)
9298

9399
func TestMain(m *testing.M) {
94100
authMode := testMode(os.Getenv("GH_TEST_AUTH_MODE"))

github/data_source_github_actions_environment_secrets.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ func dataSourceGithubActionsEnvironmentSecretsRead(ctx context.Context, d *schem
107107
options.Page = resp.NextPage
108108
}
109109

110-
if id, err := buildID(repoName, escapeIDPart(envName)); err != nil {
110+
id, err := buildID(repoName, escapeIDPart(envName))
111+
if err != nil {
111112
return diag.FromErr(err)
112-
} else {
113-
d.SetId(id)
114113
}
114+
d.SetId(id)
115115

116116
if err := d.Set("secrets", all_secrets); err != nil {
117117
return diag.FromErr(err)

github/data_source_github_actions_environment_variables.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ func dataSourceGithubActionsEnvironmentVariablesRead(ctx context.Context, d *sch
107107
options.Page = resp.NextPage
108108
}
109109

110-
if id, err := buildID(repoName, escapeIDPart(envName)); err != nil {
110+
id, err := buildID(repoName, escapeIDPart(envName))
111+
if err != nil {
111112
return diag.FromErr(err)
112-
} else {
113-
d.SetId(id)
114113
}
114+
d.SetId(id)
115115

116116
if err := d.Set("variables", all_variables); err != nil {
117117
return diag.FromErr(err)

github/data_source_github_repository_environment_deployment_policies.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ func dataSourceGithubRepositoryEnvironmentDeploymentPoliciesRead(ctx context.Con
6565
results = append(results, policyMap)
6666
}
6767

68-
if id, err := buildID(repoName, escapeIDPart(envName)); err != nil {
68+
id, err := buildID(repoName, escapeIDPart(envName))
69+
if err != nil {
6970
return diag.FromErr(err)
70-
} else {
71-
d.SetId(id)
7271
}
72+
d.SetId(id)
7373

7474
if err = d.Set("policies", results); err != nil {
7575
return diag.FromErr(err)

github/provider_test.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,9 @@ import (
66
"testing"
77

88
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
9-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
109
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
1110
)
1211

13-
var (
14-
testAccProviders map[string]*schema.Provider
15-
testAccProviderFactories func(providers *[]*schema.Provider) map[string]func() (*schema.Provider, error)
16-
testAccProvider *schema.Provider
17-
)
18-
19-
func init() {
20-
testAccProvider = Provider()
21-
testAccProviders = map[string]*schema.Provider{
22-
"github": testAccProvider,
23-
}
24-
testAccProviderFactories = func(providers *[]*schema.Provider) map[string]func() (*schema.Provider, error) {
25-
return map[string]func() (*schema.Provider, error){
26-
//nolint:unparam
27-
"github": func() (*schema.Provider, error) {
28-
p := Provider()
29-
*providers = append(*providers, p)
30-
return p, nil
31-
},
32-
}
33-
}
34-
}
35-
3612
func TestProvider(t *testing.T) {
3713
t.Run("runs internal validation without error", func(t *testing.T) {
3814
if err := Provider().InternalValidate(); err != nil {

0 commit comments

Comments
 (0)