Skip to content

Commit e85e91e

Browse files
authored
chore: remove unused code (#1013)
Remove code snippets that are not used across the codebase.
1 parent 752dacd commit e85e91e

File tree

11 files changed

+0
-187
lines changed

11 files changed

+0
-187
lines changed

cmd/troubleshoot/cli/run.go

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/json"
66
"fmt"
77
"net/http"
8-
"net/url"
98
"os"
109
"os/signal"
1110
"path/filepath"
@@ -14,7 +13,6 @@ import (
1413

1514
cursor "github.com/ahmetalpbalkan/go-cursor"
1615
"github.com/fatih/color"
17-
"github.com/manifoldco/promptui"
1816
"github.com/mattn/go-isatty"
1917
"github.com/pkg/errors"
2018
analyzer "github.com/replicatedhq/troubleshoot/pkg/analyze"
@@ -340,14 +338,6 @@ the %s Admin Console to begin analysis.`
340338
return nil
341339
}
342340

343-
func getExpectedContentType(uploadURL string) string {
344-
parsedURL, err := url.Parse(uploadURL)
345-
if err != nil {
346-
return ""
347-
}
348-
return parsedURL.Query().Get("Content-Type")
349-
}
350-
351341
func parseTimeFlags(v *viper.Viper) (*time.Time, error) {
352342
var (
353343
sinceTime time.Time
@@ -373,29 +363,6 @@ func parseTimeFlags(v *viper.Viper) (*time.Time, error) {
373363
return &sinceTime, nil
374364
}
375365

376-
func shouldRetryRequest(err error) bool {
377-
if strings.Contains(err.Error(), "x509") && canTryInsecure() {
378-
httputil.AddTransport(&http.Transport{
379-
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
380-
})
381-
return true
382-
}
383-
return false
384-
}
385-
386-
func canTryInsecure() bool {
387-
if !isatty.IsTerminal(os.Stdout.Fd()) {
388-
return false
389-
}
390-
prompt := promptui.Prompt{
391-
Label: "Connection appears to be insecure. Would you like to attempt to create a support bundle anyway?",
392-
IsConfirm: true,
393-
}
394-
395-
_, err := prompt.Run()
396-
return err == nil
397-
}
398-
399366
type analysisOutput struct {
400367
Analysis []*analyzer.AnalyzeResult
401368
ArchivePath string

cmd/troubleshoot/cli/util.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

cmd/troubleshoot/cli/version.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,8 @@ package cli
33
import (
44
"fmt"
55

6-
"io/ioutil"
7-
"path/filepath"
8-
9-
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
10-
"github.com/replicatedhq/troubleshoot/pkg/constants"
116
"github.com/replicatedhq/troubleshoot/pkg/version"
127
"github.com/spf13/cobra"
13-
"gopkg.in/yaml.v2"
148
)
159

1610
func VersionCmd() *cobra.Command {
@@ -26,25 +20,3 @@ func VersionCmd() *cobra.Command {
2620
}
2721
return cmd
2822
}
29-
30-
func writeVersionFile(path string) error {
31-
version := troubleshootv1beta2.SupportBundleVersion{
32-
ApiVersion: "troubleshoot.sh/v1beta2",
33-
Kind: "SupportBundle",
34-
Spec: troubleshootv1beta2.SupportBundleVersionSpec{
35-
VersionNumber: version.Version(),
36-
},
37-
}
38-
b, err := yaml.Marshal(version)
39-
if err != nil {
40-
return err
41-
}
42-
43-
filename := filepath.Join(path, constants.VERSION_FILENAME)
44-
err = ioutil.WriteFile(filename, b, 0644)
45-
if err != nil {
46-
return err
47-
}
48-
49-
return nil
50-
}

pkg/collect/collector.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,6 @@ func GetCollector(collector *troubleshootv1beta2.Collect, bundlePath string, nam
104104
}
105105
}
106106

107-
func collectorTitleOrDefault(meta troubleshootv1beta2.CollectorMeta, defaultTitle string) string {
108-
if meta.CollectorName != "" {
109-
return meta.CollectorName
110-
}
111-
return defaultTitle
112-
}
113-
114107
func getCollectorName(c interface{}) string {
115108
var collector, name, selector string
116109

pkg/collect/configmap_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,10 @@ import (
99
"github.com/stretchr/testify/require"
1010
corev1 "k8s.io/api/core/v1"
1111
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12-
"k8s.io/client-go/kubernetes"
1312
testclient "k8s.io/client-go/kubernetes/fake"
1413
)
1514

1615
func TestConfigMap(t *testing.T) {
17-
type args struct {
18-
ctx context.Context
19-
client kubernetes.Interface
20-
}
2116
tests := []struct {
2217
name string
2318
configMapCollector *troubleshootv1beta2.ConfigMap

pkg/collect/copy.go

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"context"
77
"fmt"
88
"io"
9-
"io/ioutil"
109
"os"
1110
"path/filepath"
1211

@@ -186,53 +185,3 @@ func getCopyErrosFileName(copyCollector *troubleshootv1beta2.Copy) string {
186185
// TODO: random part
187186
return "errors.json"
188187
}
189-
190-
func extractTar(reader io.Reader) (map[string][]byte, error) {
191-
files := map[string][]byte{}
192-
193-
tr := tar.NewReader(reader)
194-
for {
195-
header, err := tr.Next()
196-
if err == io.EOF {
197-
break
198-
} else if err != nil {
199-
return files, errors.Wrap(err, "read header")
200-
}
201-
202-
switch header.Typeflag {
203-
case tar.TypeReg:
204-
data, err := ioutil.ReadAll(tr)
205-
if err != nil {
206-
return files, errors.Wrapf(err, "read file %s", header.Name)
207-
}
208-
files[header.Name] = data
209-
default:
210-
continue
211-
}
212-
}
213-
214-
return files, nil
215-
}
216-
217-
func saveFromTar(rootDir string, reader io.Reader) (CollectorResult, error) {
218-
result := NewResult()
219-
220-
tr := tar.NewReader(reader)
221-
for {
222-
header, err := tr.Next()
223-
if err == io.EOF {
224-
break
225-
} else if err != nil {
226-
return result, errors.Wrap(err, "read header")
227-
}
228-
229-
switch header.Typeflag {
230-
case tar.TypeReg:
231-
result.SaveResult(rootDir, header.Name, tr)
232-
default:
233-
continue
234-
}
235-
}
236-
237-
return result, nil
238-
}

pkg/collect/secret_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,10 @@ import (
1010
"github.com/stretchr/testify/require"
1111
corev1 "k8s.io/api/core/v1"
1212
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13-
"k8s.io/client-go/kubernetes"
1413
testclient "k8s.io/client-go/kubernetes/fake"
1514
)
1615

1716
func TestSecret(t *testing.T) {
18-
type args struct {
19-
ctx context.Context
20-
client kubernetes.Interface
21-
}
2217
tests := []struct {
2318
name string
2419
secretCollector *troubleshootv1beta2.Secret

pkg/debug/log.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ package debug
22

33
import (
44
"log"
5-
"os"
65

76
"github.com/spf13/viper"
87
)
98

10-
var logger = log.New(os.Stderr, "[debug]", log.Lshortfile)
11-
129
func Print(v ...interface{}) {
1310
if viper.GetBool("debug") {
1411
log.Print(v...)

pkg/oci/creds.go

Lines changed: 0 additions & 5 deletions
This file was deleted.

pkg/specs/configmaps_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,10 @@ import (
88
"github.com/stretchr/testify/require"
99
corev1 "k8s.io/api/core/v1"
1010
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11-
"k8s.io/client-go/kubernetes"
1211
testclient "k8s.io/client-go/kubernetes/fake"
1312
)
1413

1514
func Test_LoadFromConfigMapMatchingLabel(t *testing.T) {
16-
type args struct {
17-
ctx context.Context
18-
client kubernetes.Interface
19-
}
2015
tests := []struct {
2116
name string
2217
supportBundleConfigMaps []corev1.ConfigMap
@@ -376,10 +371,6 @@ spec:
376371
}
377372

378373
func TestUserProvidedNamespace_LoadFromConfigMapMatchingLabel(t *testing.T) {
379-
type args struct {
380-
ctx context.Context
381-
client kubernetes.Interface
382-
}
383374
tests := []struct {
384375
name string
385376
supportBundleConfigMaps []corev1.ConfigMap
@@ -472,10 +463,6 @@ spec:
472463
}
473464

474465
func TestRedactors_LoadFromConfigMapMatchingLabel(t *testing.T) {
475-
type args struct {
476-
ctx context.Context
477-
client kubernetes.Interface
478-
}
479466
tests := []struct {
480467
name string
481468
supportBundleConfigMaps []corev1.ConfigMap

0 commit comments

Comments
 (0)