Skip to content

Commit

Permalink
fix: hook the EMLB client up to our debug env var (#479)
Browse files Browse the repository at this point in the history
This updates the Equinix Metal Load Balancer integration to enable HTTP
client debug logs when the `PACKNGO_DEBUG` environment variable is set.
In the future we may introduce other ways of enabling debug logs for the
provider, but this change enables users to debug the EMLB parts of the
provider using the same approach they use to debug the rest of the
provider.
  • Loading branch information
cprivitere authored Jan 4, 2024
2 parents 6f81a3a + a5e7c3b commit 04541de
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions metal/loadbalancers/emlb/infrastructure/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"
"os"
"reflect"

lbaas "github.com/equinix/cloud-provider-equinix-metal/internal/lbaas/v1"
Expand Down Expand Up @@ -34,6 +35,7 @@ type Manager struct {
func NewManager(metalAPIKey, projectID, metro string) *Manager {
manager := &Manager{}
emlbConfig := lbaas.NewConfiguration()
emlbConfig.Debug = checkDebugEnabled()

manager.client = lbaas.NewAPIClient(emlbConfig)
manager.tokenExchanger = &TokenExchanger{
Expand Down Expand Up @@ -245,3 +247,8 @@ func (m *Manager) createOrigin(ctx context.Context, poolID, poolName string, num
func getResourceName(loadBalancerName, resourceType string, number int32) string {
return fmt.Sprintf("%v-%v-%v", loadBalancerName, resourceType, number)
}

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

0 comments on commit 04541de

Please sign in to comment.