Skip to content

Commit

Permalink
fix: cert update (#619)
Browse files Browse the repository at this point in the history
fix: cert update
  • Loading branch information
domenicsim1 authored Apr 11, 2024
1 parent 1e47a13 commit 210c3ed
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion octopusdeploy/resource_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,24 @@ func resourceCertificateRead(ctx context.Context, d *schema.ResourceData, m inte
func resourceCertificateUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Printf("[INFO] updating certificate (%s)", d.Id())

certificate := expandCertificate(d)
client := m.(*client.Client)
certificate := expandCertificate(d)
certificateData := d.Get("certificate_data").(string)
password := d.Get("password").(string)
if d.HasChanges("certificate_data", "password") {
newCert := &certificates.ReplacementCertificate{
CertificateData: certificateData,
Password: password,
}
replaceCertificate, err := client.Certificates.Replace(certificate.ID, newCert)
if err != nil {
return diag.FromErr(err)
}

if err := setCertificate(ctx, d, replaceCertificate); err != nil {
return diag.FromErr(err)
}
}
updatedCertificate, err := certificates.Update(client, certificate)
if err != nil {
return diag.FromErr(err)
Expand Down

0 comments on commit 210c3ed

Please sign in to comment.