Skip to content

Commit 6e5c186

Browse files
(chore): remove unused utils method (#2104)
1 parent b25356d commit 6e5c186

File tree

1 file changed

+0
-46
lines changed

1 file changed

+0
-46
lines changed

test/utils/utils.go

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
package utils
22

33
import (
4-
"context"
5-
"fmt"
6-
"io"
7-
"net/url"
84
"os/exec"
9-
"strings"
105
"testing"
11-
12-
"k8s.io/client-go/kubernetes"
13-
14-
ocv1 "github.com/operator-framework/operator-controller/api/v1"
156
)
167

178
// FindK8sClient returns the first available Kubernetes CLI client from the system,
@@ -30,40 +21,3 @@ func FindK8sClient(t *testing.T) string {
3021
t.Fatal("k8s client not found")
3122
return ""
3223
}
33-
34-
func ReadTestCatalogServerContents(ctx context.Context, catalog *ocv1.ClusterCatalog, kubeClient kubernetes.Interface) ([]byte, error) {
35-
if catalog == nil {
36-
return nil, fmt.Errorf("cannot read nil catalog")
37-
}
38-
if catalog.Status.URLs == nil {
39-
return nil, fmt.Errorf("catalog %q has no catalog urls", catalog.Name)
40-
}
41-
url, err := url.Parse(catalog.Status.URLs.Base)
42-
if err != nil {
43-
return nil, fmt.Errorf("error parsing clustercatalog url %q: %v", catalog.Status.URLs.Base, err)
44-
}
45-
// url is expected to be in the format of
46-
// http://{service_name}.{namespace}.svc/catalogs/{catalog_name}/
47-
// so to get the namespace and name of the service we grab only
48-
// the hostname and split it on the '.' character
49-
ns := strings.Split(url.Hostname(), ".")[1]
50-
name := strings.Split(url.Hostname(), ".")[0]
51-
port := url.Port()
52-
// the ProxyGet() call below needs an explicit port value, so if
53-
// value from url.Port() is empty, we assume port 443.
54-
if port == "" {
55-
if url.Scheme == "https" {
56-
port = "443"
57-
} else {
58-
port = "80"
59-
}
60-
}
61-
resp := kubeClient.CoreV1().Services(ns).ProxyGet(url.Scheme, name, port, url.JoinPath("api", "v1", "all").Path, map[string]string{})
62-
rc, err := resp.Stream(ctx)
63-
if err != nil {
64-
return nil, err
65-
}
66-
defer rc.Close()
67-
68-
return io.ReadAll(rc)
69-
}

0 commit comments

Comments
 (0)