Skip to content

Commit

Permalink
Enable debug mode on LDAP connection if TF_LOG is set to DEBUG or higher
Browse files Browse the repository at this point in the history
  • Loading branch information
pdecat committed Dec 16, 2022
1 parent 327e2c0 commit e2d48a8
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 e2d48a8

Please sign in to comment.