fix: resolve failing unit tests and diff consistency in v1beta3
- Fix readLinesFromReader to return lines WITH newlines (like difflib.SplitLines)
- Update test expectations to match correct function behavior with newlines
- This ensures consistency between streaming and non-streaming diff paths
- Fix timeout test by changing from 10ms to 500ms to eliminate flaky failures
Fixes TestReadLinesFromReader and Test_loadSupportBundleSpecsFromURIs_TimeoutError
Resolves diff output inconsistency between code paths
* basic auto uploading support bundles
* added upload command
* added default vendor endpoint
* added auth system from replicated cli
* fixed case sensitivity issue in YAML parsing
* support bundle uploads for end customers
* app slug flag and detection without licenseID
* v1beta3 spec can be read by preflight
* added test files for ease of testing
* updated v1beta3 guide doc and added tests
* fixed not removing tmp files from v1beta3 processing
* created v1beta2 to v1beta3 converter
* Auto-collectors: foundational discovery, image metadata, CLI integration; reset PRD markers
* Address PR review feedback
- Implement missing namespace exclude patterns functionality
- Fix image facts collector to use empty Data field instead of static string
- Correct APIVersion to use troubleshoot.sh/v1beta2 consistently
* Fix bug bot issues: API parsing, EOF error, and API group corrections
- Fix RBAC API parsing errors in rbac_checker.go (getAPIGroup/getAPIVersion functions)
- Fix FakeReader EOF error to use standard io.EOF instead of custom error
- Fix incorrect API group from troubleshoot.sh to troubleshoot.replicated.com in run.go
These changes address the issues identified by the bug bot and ensure proper
interface compliance and consistent API group usage.
* Fix multiple bug bot issues
- Fix RBAC API parsing errors in rbac_checker.go (getAPIGroup/getAPIVersion functions)
- Fix FakeReader EOF error to use standard io.EOF instead of custom error
- Fix incorrect API group from troubleshoot.sh to troubleshoot.replicated.com in run.go
- Fix image facts collector Data field to contain structured JSON instead of static strings
These changes address all issues identified by the bug bot and ensure proper
interface compliance, consistent API usage, and meaningful data fields.
* Update auto_discovery.go
* Fix TODO comments in Auto-collector section
Fixed 3 of 4 TODOs as requested in PR review:
1. pkg/collect/images/registry_client.go (line 46):
- Implement custom CA certificate loading
- Add x509 import and certificate parsing logic
- Enables image collection from private registries with custom CAs
2. cmd/troubleshoot/cli/diff.go (line 209):
- Implement bundle file count functionality
- Add tar/gzip imports and getFileCountFromBundle() function
- Properly counts files in support bundle archives (.gz/.tgz)
3. cmd/troubleshoot/cli/run.go (line 338):
- Replace TODO with clarifying comment about RemoteCollectors usage
- Confirmed RemoteCollectors are still actively used in preflights
The 4th TODO (diff.go line 196) is left as-is since it's explicitly marked
as Phase 4 future work (Support Bundle Differencing implementation).
Addresses PR review feedback about unimplemented TODO comments.
---------
Co-authored-by: Benjamin Yang <benjaminyang@Benjamins-MacBook-Pro.local>
In interactive mode, do not prompt users to save support
bundle analysis results. Users end up providing this file
instead of the support bundle archive. The analysis results
are contained in the support bundle archive already
Signed-off-by: Evans Mungai <evans@replicated.com>
* fix(support-bundle): default in-cluster collectors in host support bundle
Ensure cluster-resources and cluster-info collectors are present only
when a support bundle spec contains in-cluster collectors.
* Various improvements
* Improve error messages
* Util function appending elements to a nil slice that allows adding
specs to an empty slice of collectors/analysers/redactors
* Fix failing test
* gracefully handle unreachable URIs in loadSupportBundleSpecsFromURIs
* let caller decide how to handle the error
* fix klog import
* Add a test to ensure failing to load uri does not error
---------
Co-authored-by: Evans Mungai <evans@replicated.com>
If troubleshoot is used as a dependency in go.mod, the version
information of the release would be missing at runtime. This is
because the version string is injected to binaries at build time
using linker flags (LD) passed to the compiler (check Makefile)
* Add dry-run flag
* No traces on dry run
* More refactoring
* More updates to support bundle binary
* More refactoring changes
* Different approach of loading specs from URIs
* Self review
* More changes after review and testing
* fix how we parse oci image uri
* Remove unnecessary comment
* Add missing file
* Fix failing tests
* Better error check for no collectors
* Add default collectors when parsing support bundle specs
* Add missed test fixture
* Download specs with correct headers
* Fix typo
* chore: make specs an internal package
* Some minor improvements
* Use LoadClusterSpecs in support bundle implementation
* Remove change accidentally committed
* Use LoadFromCLIArgs in preflight CLI implementation
* Update comment
* Fix edge case where the label selector is an empty string
* Fix failing test
* feat: add loader APIs to load specs from a list of yaml docs
The change introduces a loader package that will contain loader
public APIs. The aim of these APIs will be to, given any source of
troubleshoot specs, the loaders will fetch the specs and parse out
all troubleshoot objects that can be extracted.
* Some refactoring
* Some more changes
* More changes caught when testing vendor portal
* Add tests and rename Troubleshoot kinds struct
* Additional test
* Handle ConfigMap and Secrets with multiple specs in them
* Fix failing test
* Revert multidoc split implementation
* Fix merge conflict
* Change LoadFromXXX functions to a single LoadSpecs function
* fix: Discover specs from namespaces user is allowed
If a user has limited access to read secrets and config maps
from certain namespaces in a cluster, we'd need to gracefully
fail when forbidden errors are caught. We'll log them and continue
searching for specs in other namespaces.
Currently, there's no debug logs whatsoever when running a command like
troubleshoot --debug --interactive=false
Tackle this by printing similar log statements as presented in
interactive mode to the debug logger. Refactor the code a bit so there's
no need for a dedicated finished channel and to exit the goroutines
properly.
Co-authored-by: Evans Mungai <evans@replicated.com>