Skip to content

Commit 077ecd8

Browse files
committed
fix package rename
1 parent 4c8fb19 commit 077ecd8

5 files changed

Lines changed: 12 additions & 7 deletions

File tree

cmd/src/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/sourcegraph/sourcegraph/lib/errors"
1717

1818
"github.com/sourcegraph/src-cli/internal/api"
19-
"github.com/sourcegraph/src-cli/internal/oauthdevice"
19+
"github.com/sourcegraph/src-cli/internal/oauth"
2020
)
2121

2222
const usageText = `src is a tool that provides access to Sourcegraph instances.
@@ -136,7 +136,7 @@ func (c *config) apiClient(flags *api.Flags, out io.Writer) api.Client {
136136

137137
// Only use OAuth if we do not have SRC_ACCESS_TOKEN set
138138
if c.AccessToken == "" {
139-
if t, err := oauthdevice.LoadToken(context.Background(), c.Endpoint); err == nil {
139+
if t, err := oauth.LoadToken(context.Background(), c.Endpoint); err == nil {
140140
opts.OAuthToken = t
141141
} else {
142142
// TODO(burmudar): should return an error instead

internal/api/api.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/kballard/go-shellquote"
1919
"github.com/mattn/go-isatty"
2020

21-
"github.com/sourcegraph/src-cli/internal/oauthdevice"
21+
"github.com/sourcegraph/src-cli/internal/oauth"
2222
"github.com/sourcegraph/src-cli/internal/version"
2323
)
2424

@@ -87,7 +87,7 @@ type ClientOpts struct {
8787
ProxyURL *url.URL
8888
ProxyPath string
8989

90-
OAuthToken *oauthdevice.Token
90+
OAuthToken *oauth.Token
9191
}
9292

9393
func buildTransport(opts ClientOpts, flags *Flags) http.RoundTripper {
@@ -111,7 +111,7 @@ func buildTransport(opts ClientOpts, flags *Flags) http.RoundTripper {
111111
}
112112

113113
if opts.AccessToken == "" && opts.OAuthToken != nil {
114-
transport = &oauthdevice.Transport{
114+
transport = &oauth.Transport{
115115
Base: transport,
116116
Token: opts.OAuthToken,
117117
}

internal/oauth/flow.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ type ErrorResponse struct {
8080
}
8181

8282
type Client interface {
83+
ClientID() string
8384
Discover(ctx context.Context, endpoint string) (*OIDCConfiguration, error)
8485
Start(ctx context.Context, endpoint string, scopes []string) (*DeviceAuthResponse, error)
8586
Poll(ctx context.Context, endpoint, deviceCode string, interval time.Duration, expiresIn int) (*TokenResponse, error)
@@ -107,6 +108,10 @@ func NewClientWithHTTPClient(clientID string, c *http.Client) Client {
107108
}
108109
}
109110

111+
func (c *httpClient) ClientID() string {
112+
return c.clientID
113+
}
114+
110115
// Discover fetches the openid-configuration which contains all the routes a client should
111116
// use for authorization, device flows, tokens etc.
112117
//

internal/oauth/http_transport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package oauthdevice
1+
package oauth
22

33
import (
44
"context"

internal/oauth/http_transport_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package oauthdevice
1+
package oauth
22

33
import (
44
"context"

0 commit comments

Comments
 (0)