Skip to content

Commit

Permalink
fix golang-ci lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
yoennb committed Dec 10, 2024
1 parent f16fdeb commit 320591d
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions bastion/resource_encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ func resourceEncryption() *schema.Resource {
}

func resourceEncryptionVersionCheck(version string) error {
fmt.Printf("Debug: Checking API version: %s\n", version)
if slices.Contains(defaultVersionsValid(), version) {
return nil
}

return fmt.Errorf("resource wallix-bastion_encryption is not available with API version %s", version)
}

Expand All @@ -64,7 +64,10 @@ func resourceEncryptionCreate(
d.SetId("encryption")

// Set persistent attributes
d.Set("new_passphrase", d.Get("new_passphrase").(string))
err = d.Set("new_passphrase", d.Get("new_passphrase").(string))
if err != nil {
return diag.FromErr(err)
}

return resourceEncryptionRead(ctx, d, m)
}
Expand All @@ -84,10 +87,14 @@ func resourceEncryptionRead(
if !exists {
// Clear the resource ID if it no longer exists
d.SetId("")

return nil
}
d.SetId("encryption")
d.Set("new_passphrase", d.Get("new_passphrase").(string))
err = d.Set("new_passphrase", d.Get("new_passphrase").(string))
if err != nil {
return diag.FromErr(err)
}

return nil
}
Expand All @@ -109,7 +116,10 @@ func resourceEncryptionUpdate(
return diag.FromErr(err)
}
if d.HasChange("new_passphrase") {
d.Set("new_passphrase", d.Get("new_passphrase"))
err := d.Set("new_passphrase", d.Get("new_passphrase"))
if err != nil {
return diag.FromErr(err)
}
}
}

Expand All @@ -130,6 +140,7 @@ func addEncryption(
if code != http.StatusOK && code != http.StatusNoContent {
return fmt.Errorf("API didn't return OK or NoContent: %d with body:\n%s", code, body)
}

return nil
}

Expand All @@ -149,10 +160,11 @@ func updateEncryption(
}

func resourceEncryptionDelete(
ctx context.Context, d *schema.ResourceData, m interface{},
_ context.Context, d *schema.ResourceData, m interface{},

Check failure on line 163 in bastion/resource_encryption.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unused-parameter: parameter 'm' seems to be unused, consider removing or renaming it as _ (revive)
) diag.Diagnostics {
// Since the API does not support deletion, we simply remove the resource from the Terraform state
d.SetId("")

return nil
}

Expand Down Expand Up @@ -195,7 +207,6 @@ func verifyEncryption(
}

func prepareEncryptionJSON(d *schema.ResourceData, update bool) jsonEncryption {

var jsonData jsonEncryption

if update {
Expand All @@ -207,9 +218,10 @@ func prepareEncryptionJSON(d *schema.ResourceData, update bool) jsonEncryption {
}

func resourceEncryptionImport(
d *schema.ResourceData, m interface{},
d *schema.ResourceData, _ interface{},
) ([]*schema.ResourceData, error) {
// For import, assume the static ID
d.SetId("encryption")

return []*schema.ResourceData{d}, nil
}

0 comments on commit 320591d

Please sign in to comment.