diff --git a/go.mod b/go.mod index 7b48016b8..16dffea53 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/hashicorp/terraform-plugin-framework-timetypes v0.5.0 github.com/hashicorp/terraform-plugin-framework-validators v0.18.0 github.com/hashicorp/terraform-plugin-go v0.29.0 - github.com/hashicorp/terraform-plugin-log v0.9.0 + github.com/hashicorp/terraform-plugin-log v0.10.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1 github.com/hashicorp/terraform-plugin-testing v1.13.3 github.com/infobloxopen/bloxone-go-client v0.3.1-0.20251017222358-0f3a37e3cc41 diff --git a/go.sum b/go.sum index 7a7539781..d9f8fa98f 100644 --- a/go.sum +++ b/go.sum @@ -116,8 +116,8 @@ github.com/hashicorp/terraform-plugin-framework-validators v0.18.0 h1:OQnlOt98ua github.com/hashicorp/terraform-plugin-framework-validators v0.18.0/go.mod h1:lZvZvagw5hsJwuY7mAY6KUz45/U6fiDR0CzQAwWD0CA= github.com/hashicorp/terraform-plugin-go v0.29.0 h1:1nXKl/nSpaYIUBU1IG/EsDOX0vv+9JxAltQyDMpq5mU= github.com/hashicorp/terraform-plugin-go v0.29.0/go.mod h1:vYZbIyvxyy0FWSmDHChCqKvI40cFTDGSb3D8D70i9GM= -github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= -github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= +github.com/hashicorp/terraform-plugin-log v0.10.0 h1:eu2kW6/QBVdN4P3Ju2WiB2W3ObjkAsyfBsL3Wh1fj3g= +github.com/hashicorp/terraform-plugin-log v0.10.0/go.mod h1:/9RR5Cv2aAbrqcTSdNmY1NRHP4E3ekrXRGjqORpXyB0= github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1 h1:mlAq/OrMlg04IuJT7NpefI1wwtdpWudnEmjuQs04t/4= github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1/go.mod h1:GQhpKVvvuwzD79e8/NZ+xzj+ZpWovdPAe8nfV/skwNU= github.com/hashicorp/terraform-plugin-testing v1.13.3 h1:QLi/khB8Z0a5L54AfPrHukFpnwsGL8cwwswj4RZduCo= diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/internal/fieldutils/field_maps.go b/vendor/github.com/hashicorp/terraform-plugin-log/internal/fieldutils/field_maps.go index ac78d6da7..0bdcd47d6 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/internal/fieldutils/field_maps.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/internal/fieldutils/field_maps.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package fieldutils // MergeFieldMaps takes a slice of field maps, diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/internal/hclogutils/args.go b/vendor/github.com/hashicorp/terraform-plugin-log/internal/hclogutils/args.go index 44c81ab8e..43ac23bf3 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/internal/hclogutils/args.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/internal/hclogutils/args.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package hclogutils import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/internal/hclogutils/logger_options.go b/vendor/github.com/hashicorp/terraform-plugin-log/internal/hclogutils/logger_options.go index a0ec34e20..69dad9eb7 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/internal/hclogutils/logger_options.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/internal/hclogutils/logger_options.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package hclogutils import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/filtering.go b/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/filtering.go index c7b9c450a..c1eceb1d8 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/filtering.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/filtering.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package logging import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/log.go b/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/log.go index 4aa80bb98..6ad6c1d2d 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/log.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/log.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package logging import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/options.go b/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/options.go index 583dc2cbf..42a79d9c7 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/options.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/options.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package logging import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/provider.go b/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/provider.go index c8f45a86c..7353cc6c0 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/provider.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/provider.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package logging import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/sdk.go b/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/sdk.go index 217c83ed7..db84026b2 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/sdk.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/sdk.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package logging import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/sink.go b/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/sink.go index b56ce8bfe..b1e42de0e 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/sink.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/internal/logging/sink.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package logging import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/tflog/doc.go b/vendor/github.com/hashicorp/terraform-plugin-log/tflog/doc.go index 97ca21884..a168965de 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/tflog/doc.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/tflog/doc.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Package tflog provides helper functions for writing log output and creating // loggers for Terraform plugins. // diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/tflog/options.go b/vendor/github.com/hashicorp/terraform-plugin-log/tflog/options.go index 750177812..953786a06 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/tflog/options.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/tflog/options.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package tflog import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/tflog/provider.go b/vendor/github.com/hashicorp/terraform-plugin-log/tflog/provider.go index c1a1572ce..b5a083588 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/tflog/provider.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/tflog/provider.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package tflog import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/tflog/subsystem.go b/vendor/github.com/hashicorp/terraform-plugin-log/tflog/subsystem.go index 1f66e757a..2d22ef1bb 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/tflog/subsystem.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/tflog/subsystem.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package tflog import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/doc.go b/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/doc.go index 2ed6f6fc8..13eb4c636 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/doc.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/doc.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Package tfsdklog provides helper functions for logging from SDKs and // frameworks for building Terraform plugins. // diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/levels.go b/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/levels.go index ed475a137..71bce01be 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/levels.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/levels.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package tfsdklog import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/options.go b/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/options.go index b1ba8e51e..09cedb1ca 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/options.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/options.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package tfsdklog import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/sdk.go b/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/sdk.go index 4ffb2cc2f..9c7d4c24d 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/sdk.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/sdk.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package tfsdklog import ( diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/sink.go b/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/sink.go index 6326901f1..e4b3e6c93 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/sink.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/sink.go @@ -1,9 +1,13 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package tfsdklog import ( "context" "fmt" "io" + "log" "os" "strings" "sync" @@ -66,8 +70,49 @@ var invalidLogLevelMessage sync.Once // // RegisterTestSink must be called prior to any loggers being setup or // instantiated. +// +// Deprecated: RegisterTestSink will be removed in a future release in order to +// drop the dependency on github.com/mitchellh/go-testing-interface, which is +// no longer maintained. Use ContextWithTestLogging instead of +// RegisterTestSink. func RegisterTestSink(ctx context.Context, t testing.T) context.Context { - logger, loggerOptions := newSink(t) + logger, loggerOptions := newTestSink(t.Name()) + + ctx = logging.SetSink(ctx, logger) + ctx = logging.SetSinkOptions(ctx, loggerOptions) + + return ctx +} + +// ContextWithStandardLogging sets up a logging sink for use with test sweepers and +// other cases where plugin logs don't get routed through Terraform and the +// built-in Go `log` package is also used. +// +// ContextWithStandardLogging should only ever be called by test sweepers, providers +// should never call it. +// +// ContextWithStandardLogging must be called prior to any loggers being setup or +// instantiated. +func ContextWithStandardLogging(ctx context.Context, testName string) context.Context { + logger, loggerOptions := newStdlogSink() + + ctx = logging.SetSink(ctx, logger) + ctx = logging.SetSinkOptions(ctx, loggerOptions) + + return ctx +} + +// ContextWithTestLogging sets up a logging sink, for use with test frameworks +// and other cases where plugin logs don't get routed through Terraform. This +// applies the same filtering and file output behaviors that Terraform does. +// +// ContextWithTestLogging should only ever be called by test frameworks, +// providers should never call it. +// +// ContextWithTestLogging must be called prior to any loggers being setup or +// instantiated. +func ContextWithTestLogging(ctx context.Context, testName string) context.Context { + logger, loggerOptions := newTestSink(testName) ctx = logging.SetSink(ctx, logger) ctx = logging.SetSinkOptions(ctx, loggerOptions) @@ -75,7 +120,7 @@ func RegisterTestSink(ctx context.Context, t testing.T) context.Context { return ctx } -func newSink(t testing.T) (hclog.Logger, *hclog.LoggerOptions) { +func newTestSink(testName string) (hclog.Logger, *hclog.LoggerOptions) { logOutput := io.Writer(os.Stderr) var json bool var logLevel hclog.Level @@ -99,7 +144,7 @@ func newSink(t testing.T) (hclog.Logger, *hclog.LoggerOptions) { // if TF_LOG_PATH_MASK is set, use a test-name specific logging file, // instead if logPathMask := os.Getenv(envLogPathMask); logPathMask != "" { - testName := strings.Replace(t.Name(), "/", "__", -1) + testName := strings.Replace(testName, "/", "__", -1) logFile = fmt.Sprintf(logPathMask, testName) } @@ -150,3 +195,12 @@ func isValidLogLevel(level string) bool { return false } + +func newStdlogSink() (hclog.Logger, *hclog.LoggerOptions) { + loggerOptions := &hclog.LoggerOptions{ + IndependentLevels: true, + JSONFormat: false, + } + + return hclog.FromStandardLogger(log.Default(), loggerOptions), loggerOptions +} diff --git a/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/subsystem.go b/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/subsystem.go index 0aeb5463c..bfed8aca7 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/subsystem.go +++ b/vendor/github.com/hashicorp/terraform-plugin-log/tfsdklog/subsystem.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package tfsdklog import ( diff --git a/vendor/modules.txt b/vendor/modules.txt index 9a96610e0..13bb32a07 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -262,8 +262,8 @@ github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6 github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/toproto github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server github.com/hashicorp/terraform-plugin-go/tftypes -# github.com/hashicorp/terraform-plugin-log v0.9.0 -## explicit; go 1.19 +# github.com/hashicorp/terraform-plugin-log v0.10.0 +## explicit; go 1.24.0 github.com/hashicorp/terraform-plugin-log/internal/fieldutils github.com/hashicorp/terraform-plugin-log/internal/hclogutils github.com/hashicorp/terraform-plugin-log/internal/logging