Skip to content

Commit

Permalink
fix: enable equinix-sdk-go debugging when PACKNGO_DEBUG env var is set (
Browse files Browse the repository at this point in the history
#551)

The old packngo SDK had built-in support for enabling debug logging if
the `PACKNGO_DEBUG` environment variable was set to any value. The
generated equinix-sdk-go SDK requires explicitly enabling debug logging
in consumer code, so when we switched from `packngo` to `equinix-sdk-go`
we lost support for the `PACKNGO_DEBUG` environment variable. This
updates CPEM to enable debug logging for `equinix-sdk-go` if the old
`PACKNGO_DEBUG` environment variable is set.

Fixes #517
  • Loading branch information
k8s-ci-robot authored May 29, 2024
2 parents 1da0fb9 + bc0aabc commit 2b3dd62
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions metal/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package metal
import (
"fmt"
"io"
"os"

metal "github.com/equinix/equinix-sdk-go/services/metalv1"
cloudprovider "k8s.io/cloud-provider"
Expand Down Expand Up @@ -61,6 +62,7 @@ func init() {
configuration := metal.NewConfiguration()
configuration.AddDefaultHeader("X-Auth-Token", metalConfig.AuthToken)
configuration.UserAgent = fmt.Sprintf("cloud-provider-equinix-metal/%s %s", version.Get(), configuration.UserAgent)
configuration.Debug = checkDebugEnabled()
client := metal.NewAPIClient(configuration)
cloud, err := newCloud(metalConfig, client)
if err != nil {
Expand Down Expand Up @@ -152,3 +154,8 @@ func (c *cloud) HasClusterID() bool {
klog.V(5).Info("called HasClusterID")
return true
}

func checkDebugEnabled() bool {
_, legacyVarIsSet := os.LookupEnv("PACKNGO_DEBUG")
return legacyVarIsSet
}

0 comments on commit 2b3dd62

Please sign in to comment.