Skip to content

Commit

Permalink
Add nil check to support bundle printer that prints remotecfg & local…
Browse files Browse the repository at this point in the history
… sources
  • Loading branch information
dehaansa committed Jan 8, 2025
1 parent 0a3e6df commit 74b294a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
4 changes: 4 additions & 0 deletions internal/service/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,10 @@ func remoteCfgRedactedCachedConfig(host service.Host) ([]byte, error) {
}

func printFileRedacted(f *ast.File) ([]byte, error) {
if f == nil {
return []byte{}, nil
}

c := printer.Config{
RedactSecrets: true,
}
Expand Down
31 changes: 17 additions & 14 deletions internal/service/http/supportbundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,23 @@ func ServeSupportBundle(rw http.ResponseWriter, b *Bundle, logsBuf *bytes.Buffer
rw.Header().Set("Content-Disposition", "attachment; filename=\"alloy-support-bundle.zip\"")

zipStructure := map[string][]byte{
"alloy-metadata.yaml": b.meta,
"alloy-components.json": b.components,
"alloy-peers.json": b.peers,
"alloy-metrics-sample-start.txt": b.alloyMetricsStart,
"alloy-metrics-sample-end.txt": b.alloyMetricsEnd,
"alloy-runtime-flags.txt": b.runtimeFlags,
"alloy-environment.txt": b.environmentVariables,
"alloy-logs.txt": logsBuf.Bytes(),
"sources/remote-config/remote.alloy": b.remoteCfg,
"pprof/cpu.pprof": b.cpuBuf.Bytes(),
"pprof/heap.pprof": b.heapBuf.Bytes(),
"pprof/goroutine.pprof": b.goroutineBuf.Bytes(),
"pprof/mutex.pprof": b.mutexBuf.Bytes(),
"pprof/block.pprof": b.blockBuf.Bytes(),
"alloy-metadata.yaml": b.meta,
"alloy-components.json": b.components,
"alloy-peers.json": b.peers,
"alloy-metrics-sample-start.txt": b.alloyMetricsStart,
"alloy-metrics-sample-end.txt": b.alloyMetricsEnd,
"alloy-runtime-flags.txt": b.runtimeFlags,
"alloy-environment.txt": b.environmentVariables,
"alloy-logs.txt": logsBuf.Bytes(),
"pprof/cpu.pprof": b.cpuBuf.Bytes(),
"pprof/heap.pprof": b.heapBuf.Bytes(),
"pprof/goroutine.pprof": b.goroutineBuf.Bytes(),
"pprof/mutex.pprof": b.mutexBuf.Bytes(),
"pprof/block.pprof": b.blockBuf.Bytes(),
}

if len(b.remoteCfg) > 0 {
zipStructure["sources/remote-config/remote.alloy"] = b.remoteCfg
}

for p, s := range b.sources {
Expand Down

0 comments on commit 74b294a

Please sign in to comment.