Skip to content

Commit 6e7b07c

Browse files
committed
cleanup lint
1 parent 0f17602 commit 6e7b07c

6 files changed

Lines changed: 23 additions & 26 deletions

File tree

cli/pkg/kubectl/base/options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ import (
2323
"path/filepath"
2424
"strings"
2525

26-
"github.com/kube-bind/kube-bind/cli/pkg/config"
2726
"github.com/spf13/cobra"
2827
"k8s.io/cli-runtime/pkg/genericclioptions"
2928
"k8s.io/client-go/tools/clientcmd"
29+
30+
"github.com/kube-bind/kube-bind/cli/pkg/config"
3031
)
3132

3233
// Options contains options common to most CLI plugins.

cli/pkg/kubectl/bind-login/plugin/login.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (o *LoginOptions) Run(ctx context.Context, authURLCh chan<- string) error {
144144

145145
// Get provider information
146146
fmt.Fprintf(o.Streams.ErrOut, "Connecting to kube-bind server %s...\n", o.Options.Server)
147-
provider, err := o.getProvider()
147+
provider, err := o.getProvider(ctx)
148148
if err != nil {
149149
return fmt.Errorf("failed to get provider information: %w", err)
150150
}
@@ -238,7 +238,7 @@ func (o *LoginOptions) Run(ctx context.Context, authURLCh chan<- string) error {
238238
return nil
239239
}
240240

241-
func (o *LoginOptions) getProvider() (*kubebindv1alpha2.BindingProvider, error) {
241+
func (o *LoginOptions) getProvider(ctx context.Context) (*kubebindv1alpha2.BindingProvider, error) {
242242
url, err := url.Parse(o.Options.Server)
243243
if err != nil {
244244
return nil, fmt.Errorf("failed to parse server URL: %w", err)
@@ -248,9 +248,14 @@ func (o *LoginOptions) getProvider() (*kubebindv1alpha2.BindingProvider, error)
248248
url.Path = "/api/exports"
249249
}
250250

251-
resp, err := o.loginClient.Get(url.String())
251+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url.String(), nil)
252252
if err != nil {
253-
return nil, err
253+
return nil, fmt.Errorf("failed to create request: %w", err)
254+
}
255+
256+
resp, err := o.loginClient.Do(req)
257+
if err != nil {
258+
return nil, fmt.Errorf("failed to send request: %w", err)
254259
}
255260
defer resp.Body.Close()
256261

cli/pkg/kubectl/bind/plugin/bind.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -379,20 +379,6 @@ func (b *BindOptions) startCallbackServer(resultCh chan<- *BindResult, errCh cha
379379
return server, port, nil
380380
}
381381

382-
// getBaseURLFromExportURL removes /api/exports path from the URL
383-
func getBaseURLFromExportURL(exportURL string) string {
384-
parsedURL, err := url.Parse(exportURL)
385-
if err != nil {
386-
return exportURL
387-
}
388-
389-
// Remove /api/exports from the path
390-
parsedURL.Path = strings.TrimSuffix(parsedURL.Path, "/api/exports")
391-
parsedURL.Path = strings.TrimSuffix(parsedURL.Path, "/")
392-
393-
return parsedURL.String()
394-
}
395-
396382
// generateRandomString generates a random string of the specified length
397383
func generateRandomString(length int) (string, error) {
398384
bytes := make([]byte, length)

contrib/kcp/test/e2e/binding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"testing"
66
"time"
77

8-
"github.com/kube-bind/kube-bind/test/e2e/framework"
98
"github.com/stretchr/testify/require"
109
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1110
"k8s.io/apimachinery/pkg/util/wait"
@@ -14,6 +13,7 @@ import (
1413

1514
bindapiservice "github.com/kube-bind/kube-bind/cli/pkg/kubectl/bind-apiservice/plugin"
1615
kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2"
16+
"github.com/kube-bind/kube-bind/test/e2e/framework"
1717
)
1818

1919
func performBinding(

contrib/kcp/test/e2e/kcp_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ import (
4444
// We need to refactor config machienery to allow multiple servers to be used in parallel tests
4545

4646
func TestKCPClusterScope(t *testing.T) {
47-
// t.Parallel()
47+
// t.Parallel()
4848
testKcpIntegration(t, "cc", kubebindv1alpha2.ClusterScope)
4949
}
5050

5151
func TestKCPNamespacedScope(t *testing.T) {
52-
//t.Parallel()
52+
// t.Parallel()
5353
testKcpIntegration(t, "nc", kubebindv1alpha2.NamespacedScope)
5454
}
5555

@@ -68,7 +68,6 @@ func testKcpIntegration(t *testing.T, name string, scope kubebindv1alpha2.Inform
6868
// consumer
6969
t.Log("Create consumer workspace")
7070
consumerWsName := fmt.Sprintf("%s-consumer-%s", name, suffix)
71-
//consumerWsPath := logicalcluster.NewPath("root").Join(consumerWsName)
7271
consumerCfg, consumerKubeconfigPath := framework.NewWorkspace(t, framework.ClientConfig(t), framework.WithStaticName(consumerWsName))
7372

7473
t.Log("Start konnector for consumer workspace")

test/e2e/framework/bind.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,24 @@ import (
2525
"k8s.io/cli-runtime/pkg/genericclioptions"
2626

2727
"github.com/kube-bind/kube-bind/cli/pkg/client"
28+
"github.com/kube-bind/kube-bind/cli/pkg/config"
2829
loginplugin "github.com/kube-bind/kube-bind/cli/pkg/kubectl/bind-login/plugin"
2930
)
3031

3132
func GetKubeBindRestClient(t *testing.T, configFile string) client.Client {
3233
t.Helper()
3334

34-
c, err := client.NewClient(configFile)
35+
c, err := config.LoadConfigFromFile(configFile)
3536
require.NoError(t, err)
3637

37-
c.WithInsecure()
38+
server, _, err := c.GetCurrentServer()
39+
require.NoError(t, err)
40+
require.NotNil(t, server, "no current server configured in %s", configFile)
41+
42+
client, err := client.NewClient(*server, client.WithInsecure(true))
43+
require.NoError(t, err)
3844

39-
return c
45+
return client
4046
}
4147

4248
func Login(t *testing.T, iostreams genericclioptions.IOStreams, authURLCh chan<- string, configFile, serverURL, clusterID string) {

0 commit comments

Comments
 (0)