Skip to content

Commit 2e3e7fc

Browse files
authored
Remove unused code from internal/logging (#492)
* Add META.d * Remove unused code from internal/logging * Update .copywrite.hcl * lint
1 parent ae29586 commit 2e3e7fc

File tree

7 files changed

+13
-224
lines changed

7 files changed

+13
-224
lines changed

.copywrite.hcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ project {
55
copyright_year = 2014
66

77
header_ignore = [
8+
# internal catalog metadata (prose)
9+
"META.d/**/*.yaml",
10+
811
# changie tooling configuration and CHANGELOG entries (prose)
912
".changes/unreleased/**",
1013
".changie.yaml",

META.d/_summary.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
schema: 1.1
3+
4+
partition: tf-ecosystem
5+
6+
summary:
7+
owner: team-tf-core-plugins
8+
description: |
9+
Module for testing Terraform providers
10+
visibility: public

internal/logging/context.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,6 @@ import (
1111
testing "github.com/mitchellh/go-testing-interface"
1212
)
1313

14-
// InitContext creates SDK logger contexts when the provider is running in
15-
// "production" (not under acceptance testing). The incoming context will
16-
// already have the root SDK logger and root provider logger setup from
17-
// terraform-plugin-go tf5server RPC handlers.
18-
func InitContext(ctx context.Context) context.Context {
19-
ctx = tfsdklog.NewSubsystem(ctx, SubsystemHelperSchema,
20-
// All calls are through the HelperSchema* helper functions
21-
tfsdklog.WithAdditionalLocationOffset(1),
22-
tfsdklog.WithLevelFromEnv(EnvTfLogSdkHelperSchema),
23-
// Propagate tf_req_id, tf_rpc, etc. fields
24-
tfsdklog.WithRootFields(),
25-
)
26-
27-
return ctx
28-
}
29-
3014
// InitTestContext registers the terraform-plugin-log/tfsdklog test sink,
3115
// configures the standard library log package, and creates SDK logger
3216
// contexts. The incoming context is expected to be devoid of logging setup.

internal/logging/context_test.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,6 @@ import (
1515
"github.com/hashicorp/terraform-plugin-testing/internal/logging"
1616
)
1717

18-
func TestInitContext(t *testing.T) {
19-
t.Parallel()
20-
21-
var output bytes.Buffer
22-
23-
ctx := tfsdklogtest.RootLogger(context.Background(), &output)
24-
25-
// Simulate root logger fields that would have been associated by
26-
// terraform-plugin-go prior to the InitContext() call.
27-
ctx = tfsdklog.SetField(ctx, "tf_rpc", "GetProviderSchema")
28-
ctx = tfsdklog.SetField(ctx, "tf_req_id", "123-testing-123")
29-
30-
ctx = logging.InitContext(ctx)
31-
32-
logging.HelperSchemaTrace(ctx, "test message")
33-
34-
entries, err := tfsdklogtest.MultilineJSONDecode(&output)
35-
36-
if err != nil {
37-
t.Fatalf("unable to read multiple line JSON: %s", err)
38-
}
39-
40-
expectedEntries := []map[string]interface{}{
41-
{
42-
"@level": "trace",
43-
"@message": "test message",
44-
"@module": "sdk.helper_schema",
45-
"tf_rpc": "GetProviderSchema",
46-
"tf_req_id": "123-testing-123",
47-
},
48-
}
49-
50-
if diff := cmp.Diff(entries, expectedEntries); diff != "" {
51-
t.Errorf("unexpected difference: %s", diff)
52-
}
53-
}
54-
5518
func TestTestNameContext(t *testing.T) {
5619
t.Parallel()
5720

internal/logging/environment_variables.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,4 @@ const (
1919
// level of SDK helper/resource loggers. Infers root SDK logging level, if
2020
// unset.
2121
EnvTfLogSdkHelperResource = "TF_LOG_SDK_HELPER_RESOURCE"
22-
23-
// EnvTfLogSdkHelperSchema is an environment variable that sets the logging
24-
// level of SDK helper/schema loggers. Infers root SDK logging level, if
25-
// unset.
26-
EnvTfLogSdkHelperSchema = "TF_LOG_SDK_HELPER_SCHEMA"
2722
)

internal/logging/helper_schema.go

Lines changed: 0 additions & 35 deletions
This file was deleted.

internal/logging/helper_schema_test.go

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)