-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added logging for req/resp deferred actions
- Loading branch information
1 parent
3a4fbc8
commit a58e305
Showing
11 changed files
with
1,120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
tfprotov5/internal/tf5serverlogging/client_capabilities.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package tf5serverlogging | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-go/internal/logging" | ||
"github.com/hashicorp/terraform-plugin-go/tfprotov5" | ||
) | ||
|
||
// ConfigureProviderClientCapabilities generates a TRACE "Announced client capabilities" log. | ||
func ConfigureProviderClientCapabilities(ctx context.Context, capabilities *tfprotov5.ConfigureProviderClientCapabilities) { | ||
responseFields := map[string]interface{}{ | ||
logging.KeyClientCapabilityDeferralAllowed: false, | ||
} | ||
|
||
if capabilities != nil { | ||
responseFields[logging.KeyClientCapabilityDeferralAllowed] = capabilities.DeferralAllowed | ||
} | ||
|
||
logging.ProtocolTrace(ctx, "Announced client capabilities", responseFields) | ||
} | ||
|
||
// ReadDataSourceClientCapabilities generates a TRACE "Announced client capabilities" log. | ||
func ReadDataSourceClientCapabilities(ctx context.Context, capabilities *tfprotov5.ReadDataSourceClientCapabilities) { | ||
responseFields := map[string]interface{}{ | ||
logging.KeyClientCapabilityDeferralAllowed: false, | ||
} | ||
|
||
if capabilities != nil { | ||
responseFields[logging.KeyClientCapabilityDeferralAllowed] = capabilities.DeferralAllowed | ||
} | ||
|
||
logging.ProtocolTrace(ctx, "Announced client capabilities", responseFields) | ||
} | ||
|
||
// ReadResourceClientCapabilities generates a TRACE "Announced client capabilities" log. | ||
func ReadResourceClientCapabilities(ctx context.Context, capabilities *tfprotov5.ReadResourceClientCapabilities) { | ||
responseFields := map[string]interface{}{ | ||
logging.KeyClientCapabilityDeferralAllowed: false, | ||
} | ||
|
||
if capabilities != nil { | ||
responseFields[logging.KeyClientCapabilityDeferralAllowed] = capabilities.DeferralAllowed | ||
} | ||
|
||
logging.ProtocolTrace(ctx, "Announced client capabilities", responseFields) | ||
} | ||
|
||
// PlanResourceChangeClientCapabilities generates a TRACE "Announced client capabilities" log. | ||
func PlanResourceChangeClientCapabilities(ctx context.Context, capabilities *tfprotov5.PlanResourceChangeClientCapabilities) { | ||
responseFields := map[string]interface{}{ | ||
logging.KeyClientCapabilityDeferralAllowed: false, | ||
} | ||
|
||
if capabilities != nil { | ||
responseFields[logging.KeyClientCapabilityDeferralAllowed] = capabilities.DeferralAllowed | ||
} | ||
|
||
logging.ProtocolTrace(ctx, "Announced client capabilities", responseFields) | ||
} | ||
|
||
// ImportResourceStateClientCapabilities generates a TRACE "Announced client capabilities" log. | ||
func ImportResourceStateClientCapabilities(ctx context.Context, capabilities *tfprotov5.ImportResourceStateClientCapabilities) { | ||
responseFields := map[string]interface{}{ | ||
logging.KeyClientCapabilityDeferralAllowed: false, | ||
} | ||
|
||
if capabilities != nil { | ||
responseFields[logging.KeyClientCapabilityDeferralAllowed] = capabilities.DeferralAllowed | ||
} | ||
|
||
logging.ProtocolTrace(ctx, "Announced client capabilities", responseFields) | ||
} |
Oops, something went wrong.