Skip to content

Commit

Permalink
Merge pull request #146 from replicatedhq/remove-invalid-tests
Browse files Browse the repository at this point in the history
Remove unused code
  • Loading branch information
marccampbell committed Mar 6, 2020
2 parents 4fca3ff + 6c212e2 commit 26d8211
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 123 deletions.
14 changes: 10 additions & 4 deletions cmd/preflight/cli/run.go
Expand Up @@ -16,9 +16,11 @@ import (
"github.com/pkg/errors"
analyzerunner "github.com/replicatedhq/troubleshoot/pkg/analyze"
troubleshootv1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1"
troubleshootclientsetscheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme"
"github.com/replicatedhq/troubleshoot/pkg/collect"
"github.com/spf13/viper"
spin "github.com/tj/go-spin"
"k8s.io/client-go/kubernetes/scheme"
)

func runPreflights(v *viper.Viper, arg string) error {
Expand Down Expand Up @@ -57,11 +59,15 @@ func runPreflights(v *viper.Viper, arg string) error {
preflightContent = string(body)
}

preflight := troubleshootv1beta1.Preflight{}
if err := json.Unmarshal([]byte(preflightContent), &preflight); err != nil {
return errors.Wrapf(err, "failed to parse %s as a preflight", arg)
troubleshootclientsetscheme.AddToScheme(scheme.Scheme)
decode := scheme.Codecs.UniversalDeserializer().Decode
obj, _, err := decode([]byte(preflightContent), nil, nil)
if err != nil {
return errors.Wrapf(err, "failed to parse %s", arg)
}

preflight := obj.(*troubleshootv1beta1.Preflight)

s := spin.New()
finishedCh := make(chan bool, 1)
progressChan := make(chan interface{}, 0) // non-zero buffer will result in missed messages
Expand Down Expand Up @@ -92,7 +98,7 @@ func runPreflights(v *viper.Viper, arg string) error {
close(finishedCh)
}()

allCollectedData, err := runCollectors(v, preflight, progressChan)
allCollectedData, err := runCollectors(v, *preflight, progressChan)
if err != nil {
return err
}
Expand Down
19 changes: 12 additions & 7 deletions cmd/troubleshoot/cli/run.go
Expand Up @@ -19,11 +19,12 @@ import (
"github.com/mattn/go-isatty"
"github.com/mholt/archiver"
"github.com/pkg/errors"
"github.com/spf13/viper"
spin "github.com/tj/go-spin"

troubleshootv1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1"
"github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme"
troubleshootclientsetscheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme"
"github.com/replicatedhq/troubleshoot/pkg/collect"
"github.com/spf13/viper"
spin "github.com/tj/go-spin"
)

var (
Expand All @@ -47,11 +48,15 @@ func runTroubleshoot(v *viper.Viper, arg string) error {
return errors.Wrap(err, "failed to load collector spec")
}

collector := troubleshootv1beta1.Collector{}
if err := json.Unmarshal(collectorContent, &collector); err != nil {
return errors.Wrapf(err, "failed to parse %s collectors", arg)
troubleshootclientsetscheme.AddToScheme(scheme.Scheme)
decode := scheme.Codecs.UniversalDeserializer().Decode
obj, _, err := decode([]byte(collectorContent), nil, nil)
if err != nil {
return errors.Wrapf(err, "failed to parse %s", arg)
}

collector := obj.(*troubleshootv1beta1.Collector)

s := spin.New()
finishedCh := make(chan bool, 1)
progressChan := make(chan interface{}, 0) // non-zero buffer can result in missed messages
Expand Down Expand Up @@ -83,7 +88,7 @@ func runTroubleshoot(v *viper.Viper, arg string) error {
close(finishedCh)
}()

archivePath, err := runCollectors(v, collector, progressChan)
archivePath, err := runCollectors(v, *collector, progressChan)
if err != nil {
return errors.Wrap(err, "run collectors")
}
Expand Down
58 changes: 0 additions & 58 deletions pkg/apis/troubleshoot/v1beta1/analyzer_shared_test.go

This file was deleted.

11 changes: 0 additions & 11 deletions pkg/collect/collector.go
@@ -1,7 +1,6 @@
package collect

import (
"encoding/json"
"strconv"

"github.com/pkg/errors"
Expand Down Expand Up @@ -190,13 +189,3 @@ func (cs Collectors) CheckRBAC() error {
}
return nil
}

func ParseSpec(specContents string) (*troubleshootv1beta1.Collect, error) {
collect := troubleshootv1beta1.Collect{}

if err := json.Unmarshal([]byte(specContents), &collect); err != nil {
return nil, err
}

return &collect, nil
}
43 changes: 0 additions & 43 deletions pkg/collect/collector_test.go

This file was deleted.

0 comments on commit 26d8211

Please sign in to comment.