Skip to content

Commit 038819c

Browse files
committed
✨ clusterctl: dump metadata.yaml when -v=10
Adds verbose logging of metadata.yaml content for GitHub-hosted providers when clusterctl is run with -v=10. This enhances troubleshooting of release metadata without overwhelming the logs.
1 parent 1f629e1 commit 038819c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

cmd/clusterctl/client/repository/repository_github.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"path"
2727
"path/filepath"
2828
"strings"
29+
"sync"
2930
"time"
3031

3132
"github.com/blang/semver/v4"
@@ -59,6 +60,9 @@ var (
5960
cacheFiles = map[string][]byte{}
6061
retryableOperationInterval = 10 * time.Second
6162
retryableOperationTimeout = 1 * time.Minute
63+
64+
// dumpedMetadata tracks which metadata files have already been dumped to avoid duplicates
65+
dumpedMetadata = sync.Map{}
6266
)
6367

6468
// gitHubRepository provides support for providers hosted on GitHub.
@@ -494,6 +498,31 @@ func (g *gitHubRepository) downloadFilesFromRelease(ctx context.Context, release
494498
return nil, retryError
495499
}
496500

501+
// If this is a metadata.yaml file and verbose logging is enabled (-v=10), dump the content to logs
502+
if filepath.Base(fileName) == "metadata.yaml" {
503+
log := logf.Log
504+
// Check if verbose logging is enabled by creating a V(10) logger and checking if it's enabled
505+
verboseLog := log.V(10)
506+
if verboseLog.Enabled() {
507+
log.Info("Dumping metadata.yaml via downloadFilesFromRelease", "provider", g.providerConfig.Name(), "fileName", fileName)
508+
509+
// Create a unique key for this provider/version combination
510+
version := ""
511+
if release.TagName != nil {
512+
version = *release.TagName
513+
}
514+
dumpKey := fmt.Sprintf("%s/%s/%s", g.providerConfig.Name(), g.providerConfig.Type(), version)
515+
516+
// Only dump if we haven't already dumped this metadata file
517+
if _, alreadyDumped := dumpedMetadata.LoadOrStore(dumpKey, true); !alreadyDumped {
518+
providerID := fmt.Sprintf("%s/%s", g.providerConfig.Name(), version)
519+
verboseLog.Info("metadata.yaml content",
520+
"providerID", providerID,
521+
"content", string(content))
522+
}
523+
}
524+
}
525+
497526
return content, nil
498527
}
499528

0 commit comments

Comments
 (0)