From 9d316017df9a719a1c18527a4296412f3eb21ce2 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Fri, 12 Apr 2024 09:10:50 -0700 Subject: [PATCH] Fix variable name typo Improve type checking for applyTelemetry --- CHANGELOG.md | 7 +++++++ util/sdk/sdk.go | 7 +++++-- util/util.go | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87d0b7c..53b159c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 1.24.0 (Apr 12, 2024) + +IMPROVEMENTS: + +* Fix typo in provider metadata type name +* Improve error checking on applyTelemetry() + ## 1.23.0 (Apr 11, 2024) IMPROVEMENTS: diff --git a/util/sdk/sdk.go b/util/sdk/sdk.go index e58cd6b..c67ebcf 100644 --- a/util/sdk/sdk.go +++ b/util/sdk/sdk.go @@ -182,8 +182,11 @@ func applyTelemetry(productId, resource, verb string, f func(context.Context, *s } return func(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { // best effort. Go routine it - featureUsage := fmt.Sprintf("Resource/%s/%s", resource, verb) - go util.SendUsage(ctx, meta.(util.ProvderMetadata).Client, productId, featureUsage) + if m, ok := meta.(util.ProviderMetadata); ok { + featureUsage := fmt.Sprintf("Resource/%s/%s", resource, verb) + go util.SendUsage(ctx, m.Client, productId, featureUsage) + } + return f(ctx, data, meta) } } diff --git a/util/util.go b/util/util.go index beb543c..3bc2223 100644 --- a/util/util.go +++ b/util/util.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" ) -type ProvderMetadata struct { +type ProviderMetadata struct { Client *resty.Client ProductId string ArtifactoryVersion string