Skip to content

Commit 4310cdc

Browse files
Merge pull request #66 from sttts/sttts-remove-cluster-roundtripper
🌱 remove unused ClusterRoundTripper
2 parents 0097020 + 2d54e60 commit 4310cdc

File tree

2 files changed

+0
-37
lines changed

2 files changed

+0
-37
lines changed

pkg/client/cluster_config.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,11 @@ limitations under the License.
1717
package client
1818

1919
import (
20-
"net/http"
21-
2220
"github.com/kcp-dev/logicalcluster/v3"
2321

2422
"k8s.io/client-go/rest"
2523
)
2624

27-
// SetMultiClusterRoundTripper wraps an existing config's roundtripper
28-
// with a custom cluster aware roundtripper.
29-
//
30-
// Note: it is the caller responsibility to make a copy of the rest config
31-
func SetMultiClusterRoundTripper(cfg *rest.Config) *rest.Config {
32-
cfg.Wrap(func(rt http.RoundTripper) http.RoundTripper {
33-
return NewClusterRoundTripper(rt)
34-
})
35-
36-
return cfg
37-
}
38-
3925
// SetCluster modifies the config host path to include the
4026
// cluster endpoint.
4127
//

pkg/client/round_tripper.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,12 @@ package client
1818

1919
import (
2020
"fmt"
21-
"net/http"
2221
"regexp"
2322
"strings"
2423

2524
"github.com/kcp-dev/logicalcluster/v3"
2625
)
2726

28-
// ClusterRoundTripper is a cluster aware wrapper around http.RoundTripper
29-
type ClusterRoundTripper struct {
30-
delegate http.RoundTripper
31-
}
32-
33-
// NewClusterRoundTripper creates a new cluster aware round tripper
34-
func NewClusterRoundTripper(delegate http.RoundTripper) *ClusterRoundTripper {
35-
return &ClusterRoundTripper{
36-
delegate: delegate,
37-
}
38-
}
39-
40-
func (c *ClusterRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
41-
cluster, ok := logicalcluster.ClusterFromContext(req.Context())
42-
if ok {
43-
req = req.Clone(req.Context())
44-
req.URL.Path = generatePath(req.URL.Path, cluster.Path())
45-
req.URL.RawPath = generatePath(req.URL.RawPath, cluster.Path())
46-
}
47-
return c.delegate.RoundTrip(req)
48-
}
49-
5027
// apiRegex matches any string that has /api/ or /apis/ in it.
5128
var apiRegex = regexp.MustCompile(`(/api/|/apis/)`)
5229

0 commit comments

Comments
 (0)