Skip to content

Commit 72671ea

Browse files
authored
Revert "fix: Add destroy-on-drift property to the GitHub Action Secret resour…" (#2841)
This reverts commit 8cda607.
1 parent 8cda607 commit 72671ea

7 files changed

+14
-534
lines changed

github/migrate_github_actions_secret.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

github/migrate_github_actions_secret_test.go

Lines changed: 0 additions & 69 deletions
This file was deleted.

github/resource_github_actions_organization_secret.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,10 @@ func resourceGithubActionsOrganizationSecretRead(d *schema.ResourceData, meta in
228228
if updatedAt, ok := d.GetOk("updated_at"); ok && destroyOnDrift && updatedAt != secret.UpdatedAt.String() {
229229
log.Printf("[INFO] The secret %s has been externally updated in GitHub", d.Id())
230230
d.SetId("")
231-
}
232-
233-
// Always update the timestamp to prevent repeated drift detection
234-
if err = d.Set("updated_at", secret.UpdatedAt.String()); err != nil {
235-
return err
231+
} else if !ok {
232+
if err = d.Set("updated_at", secret.UpdatedAt.String()); err != nil {
233+
return err
234+
}
236235
}
237236

238237
return nil

github/resource_github_actions_organization_secret_drift_test.go

Lines changed: 0 additions & 86 deletions
This file was deleted.

github/resource_github_actions_secret.go

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,11 @@ func resourceGithubActionsSecret() *schema.Resource {
1717
return &schema.Resource{
1818
Create: resourceGithubActionsSecretCreateOrUpdate,
1919
Read: resourceGithubActionsSecretRead,
20-
Update: resourceGithubActionsSecretCreateOrUpdate,
2120
Delete: resourceGithubActionsSecretDelete,
2221
Importer: &schema.ResourceImporter{
2322
State: resourceGithubActionsSecretImport,
2423
},
2524

26-
// Schema migration added to handle the addition of destroy_on_drift field
27-
// Resources created before this field was added need it populated with default value
28-
SchemaVersion: 1,
29-
MigrateState: resourceGithubActionsSecretMigrateState,
30-
3125
Schema: map[string]*schema.Schema{
3226
"repository": {
3327
Type: schema.TypeString,
@@ -68,12 +62,6 @@ func resourceGithubActionsSecret() *schema.Resource {
6862
Computed: true,
6963
Description: "Date of 'actions_secret' update.",
7064
},
71-
"destroy_on_drift": {
72-
Type: schema.TypeBool,
73-
Default: true,
74-
Optional: true,
75-
Description: "Boolean indicating whether to recreate the secret if it's modified outside of Terraform. When `true` (default), Terraform will delete and recreate the secret if it detects external changes. When `false`, Terraform will acknowledge external changes but not recreate the secret.",
76-
},
7765
},
7866
}
7967
}
@@ -167,15 +155,13 @@ func resourceGithubActionsSecretRead(d *schema.ResourceData, meta interface{}) e
167155
// The only solution to enforce consistency between is to mark the resource
168156
// as deleted (unset the ID) in order to fix potential drift by recreating
169157
// the resource.
170-
destroyOnDrift := d.Get("destroy_on_drift").(bool)
171-
if updatedAt, ok := d.GetOk("updated_at"); ok && destroyOnDrift && updatedAt != secret.UpdatedAt.String() {
158+
if updatedAt, ok := d.GetOk("updated_at"); ok && updatedAt != secret.UpdatedAt.String() {
172159
log.Printf("[INFO] The secret %s has been externally updated in GitHub", d.Id())
173160
d.SetId("")
174-
}
175-
176-
// Always update the timestamp to prevent repeated drift detection
177-
if err = d.Set("updated_at", secret.UpdatedAt.String()); err != nil {
178-
return err
161+
} else if !ok {
162+
if err = d.Set("updated_at", secret.UpdatedAt.String()); err != nil {
163+
return err
164+
}
179165
}
180166

181167
return nil

0 commit comments

Comments
 (0)