From e2d48a82c6394432530179b1d603987cb05540e1 Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Fri, 16 Dec 2022 11:35:51 +0100 Subject: [PATCH] Enable debug mode on LDAP connection if TF_LOG is set to DEBUG or higher --- ldap/provider.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ldap/provider.go b/ldap/provider.go index da673b0..41b74ea 100644 --- a/ldap/provider.go +++ b/ldap/provider.go @@ -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" ) @@ -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), @@ -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 }