Skip to content

Commit

Permalink
Remove Update logic from tfe_registry_gpg_key
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonc committed Dec 7, 2023
1 parent 95f9707 commit d73efc9
Showing 1 changed file with 5 additions and 34 deletions.
39 changes: 5 additions & 34 deletions internal/provider/resource_tfe_registry_gpg_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,40 +177,11 @@ func (r *resourceTFERegistryGPGKey) Read(ctx context.Context, req resource.ReadR
}

func (r *resourceTFERegistryGPGKey) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
var plan modelTFERegistryGPGKey
var state modelTFERegistryGPGKey

// Read Terraform plan data into the model
resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)

// Read Terraform prior state data into the model
resp.Diagnostics.Append(req.State.Get(ctx, &state)...)

if resp.Diagnostics.HasError() {
return
}

keyID := tfe.GPGKeyID{
RegistryName: "private",
Namespace: state.Organization.ValueString(), // The old namespace
KeyID: plan.ID.ValueString(),
}
options := tfe.GPGKeyUpdateOptions{
Type: "gpg-keys",
Namespace: plan.Organization.ValueString(), // The new namespace
}

tflog.Debug(ctx, "Updating private registry GPG key")
key, err := r.config.Client.GPGKeys.Update(ctx, keyID, options)
if err != nil {
resp.Diagnostics.AddError("Unable to update private registry GPG key", err.Error())
return
}

result := modelFromTFEVGPGKey(key)

// Save updated data into Terraform state
resp.Diagnostics.Append(resp.State.Set(ctx, &result)...)
// If the resource does not support modification and should always be recreated on
// configuration value updates, the Update logic can be left empty and ensure all
// configurable schema attributes implement the resource.RequiresReplace()
// attribute plan modifier.
resp.Diagnostics.AddError("Update not supported", "The update operation is not supported on this resource. This is a bug in the provider.")
}

func (r *resourceTFERegistryGPGKey) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
Expand Down

0 comments on commit d73efc9

Please sign in to comment.