Skip to content

Commit

Permalink
Merge pull request #79 from pdecat/enable_debug
Browse files Browse the repository at this point in the history
Enable debug mode on LDAP connection if `TF_LOG` is set to `DEBUG` or higher
  • Loading branch information
pablo-ruth authored Dec 16, 2022
2 parents 327e2c0 + e2d48a8 commit 5ec45fc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ldap/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ldap

import (
"github.com/Ouest-France/goldap"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -62,7 +63,6 @@ func Provider() *schema.Provider {
}

func providerConfigure(d *schema.ResourceData) (interface{}, error) {

client := &goldap.Client{
Host: d.Get("host").(string),
Port: d.Get("port").(int),
Expand All @@ -78,5 +78,9 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
return nil, err
}

if logging.IsDebugOrHigher() {
client.Conn.Debug.Enable(true)
}

return client, nil
}

0 comments on commit 5ec45fc

Please sign in to comment.