Skip to content

Commit

Permalink
fix custom redactors file selectors in support bundle subdirectory (#336
Browse files Browse the repository at this point in the history
)

* fix custom redactors file selectors in support bundle subdirectory
  • Loading branch information
sgalsaleh authored Mar 11, 2021
1 parent c1f9b39 commit afa0bc5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
4 changes: 1 addition & 3 deletions cmd/troubleshoot/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ func runCollectors(v *viper.Viper, collectors []*troubleshootv1beta2.Collect, ad
Collect: desiredCollector,
ClientConfig: config,
Namespace: v.GetString("namespace"),
PathPrefix: filepath.Base(bundlePath),
}
cleanedCollectors = append(cleanedCollectors, &collector)
}
Expand Down Expand Up @@ -500,8 +499,7 @@ func runCollectors(v *viper.Viper, collectors []*troubleshootv1beta2.Collect, ad
}

if result != nil {
// results already contain the bundle dir name in their paths
err = saveCollectorOutput(result, filepath.Dir(bundlePath), collector)
err = saveCollectorOutput(result, bundlePath, collector)
if err != nil {
progressChan <- fmt.Errorf("failed to parse collector spec %q: %v", collector.GetDisplayName(), err)
continue
Expand Down
11 changes: 0 additions & 11 deletions pkg/collect/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package collect

import (
"context"
"path/filepath"
"strconv"

"github.com/pkg/errors"
Expand All @@ -20,7 +19,6 @@ type Collector struct {
RBACErrors []error
ClientConfig *rest.Config
Namespace string
PathPrefix string
}

type Collectors []*Collector
Expand Down Expand Up @@ -209,15 +207,6 @@ func (c *Collector) RunCollectorSync(globalRedactors []*troubleshootv1beta2.Reda
return
}

if c.PathPrefix != "" {
// prefix file paths
prefixed := map[string][]byte{}
for k, v := range result {
prefixed[filepath.Join(c.PathPrefix, k)] = v
}
result = prefixed
}

if c.Redact {
result, err = redactMap(result, globalRedactors)
}
Expand Down

0 comments on commit afa0bc5

Please sign in to comment.