diff --git a/builtin/providers/opc/config.go b/builtin/providers/opc/config.go index 5c473e591..b25167fe9 100644 --- a/builtin/providers/opc/config.go +++ b/builtin/providers/opc/config.go @@ -2,11 +2,14 @@ package opc import ( "fmt" - "net/http" + "log" "net/url" + "strings" + "github.com/fsouza/go-dockerclient/external/github.com/hashicorp/go-cleanhttp" "github.com/hashicorp/go-oracle-terraform/compute" "github.com/hashicorp/go-oracle-terraform/opc" + "github.com/hashicorp/terraform/helper/logging" ) type Config struct { @@ -33,9 +36,26 @@ func (c *Config) Client() (*compute.Client, error) { Username: &c.User, Password: &c.Password, APIEndpoint: u, - HTTPClient: http.DefaultClient, + HTTPClient: cleanhttp.DefaultClient(), + } + + if logging.IsDebugOrHigher() { + config.LogLevel = opc.LogDebug + config.Logger = opcLogger{} } // TODO: http client wrapping / log level return compute.NewComputeClient(&config) } + +type opcLogger struct{} + +func (l opcLogger) Log(args ...interface{}) { + tokens := make([]string, 0, len(args)) + for _, arg := range args { + if token, ok := arg.(string); ok { + tokens = append(tokens, token) + } + } + log.Printf("[DEBUG] [go-oracle-terraform]: %s", strings.Join(tokens, " ")) +} diff --git a/builtin/providers/opc/provider.go b/builtin/providers/opc/provider.go index 579d5ac7b..ddde50d5a 100644 --- a/builtin/providers/opc/provider.go +++ b/builtin/providers/opc/provider.go @@ -36,6 +36,7 @@ func Provider() terraform.ResourceProvider { Description: "The HTTP endpoint for OPC API operations.", }, + // TODO Actually implement this "max_retry_timeout": { Type: schema.TypeInt, Optional: true, diff --git a/builtin/providers/opc/resource_instance_test.go b/builtin/providers/opc/resource_instance_test.go index 3c4e0ffe6..2cc61eb39 100644 --- a/builtin/providers/opc/resource_instance_test.go +++ b/builtin/providers/opc/resource_instance_test.go @@ -188,7 +188,7 @@ resource "opc_compute_instance" "test" { image_list = "/oracle/public/oel_6.7_apaas_16.4.5_1610211300" instance_attributes = <