Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed Feb 28, 2024
1 parent 44d7942 commit 4d9a77a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 30 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ install-scripts: install.sh
metalint:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin
go install ./...
go test -i ./...
$$(go env GOPATH)/bin/golangci-lint run -c ./.golangci.yml ./...

.PHONY: doc docs release manpage godownloader install-scripts
18 changes: 9 additions & 9 deletions tsuru/auth/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ func oauthLogin(ctx *cmd.Context, loginInfo *authTypes.SchemeInfo) error {
finish <- true
}()
var page string
token, err := convertOAuthToken(r.URL.Query().Get("code"), redirectURL)
if err != nil {
writeHTMLError(w, err)
token, handlerErr := convertOAuthToken(r.URL.Query().Get("code"), redirectURL)
if handlerErr != nil {
writeHTMLError(w, handlerErr)
return
}
err = config.WriteTokenV1(token)
if err != nil {
writeHTMLError(w, err)
handlerErr = config.WriteTokenV1(token)
if handlerErr != nil {
writeHTMLError(w, handlerErr)
return
}
err = config.RemoveTokenV2()
if err != nil {
writeHTMLError(w, err)
handlerErr = config.RemoveTokenV2()
if handlerErr != nil {
writeHTMLError(w, handlerErr)
return
}
page = fmt.Sprintf(callbackPage, successMarkup)
Expand Down
18 changes: 9 additions & 9 deletions tsuru/auth/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,34 @@ func oidcLogin(ctx *cmd.Context, loginInfo *authTypes.SchemeInfo) error {
finish <- true
}()

t, err := oauth2Config.Exchange(stdContext.Background(), r.URL.Query().Get("code"), oauth2.VerifierOption(pkceVerifier))
t, handlerErr := oauth2Config.Exchange(stdContext.Background(), r.URL.Query().Get("code"), oauth2.VerifierOption(pkceVerifier))

w.Header().Add("Content-Type", "text/html")

if err != nil {
writeHTMLError(w, err)
if handlerErr != nil {
writeHTMLError(w, handlerErr)
return
}

fmt.Fprintln(ctx.Stderr, "Successfully logged in via OIDC!")
fmt.Fprintf(ctx.Stderr, "The OIDC token will expiry in %s\n", time.Since(t.Expiry)*-1)

err = config.WriteTokenV2(config.TokenV2{
handlerErr = config.WriteTokenV2(config.TokenV2{
Scheme: "oidc",
OAuth2Token: t,
OAuth2Config: &oauth2Config,
})

if err != nil {
writeHTMLError(w, err)
if handlerErr != nil {
writeHTMLError(w, handlerErr)
return
}

// legacy token
err = config.WriteTokenV1(t.AccessToken)
handlerErr = config.WriteTokenV1(t.AccessToken)

if err != nil {
writeHTMLError(w, err)
if handlerErr != nil {
writeHTMLError(w, handlerErr)
return
}

Expand Down
10 changes: 0 additions & 10 deletions tsuru/http/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@ func Test(t *testing.T) { check.TestingT(t) }

var globalManager *cmd.Manager

type recordingExiter int

func (e *recordingExiter) Exit(code int) {
*e = recordingExiter(code)
}

func (e recordingExiter) value() int {
return int(e)
}

func targetInit() {
f, _ := config.Filesystem().Create(config.JoinWithUserDir(".tsuru", "target"))
f.Write([]byte("http://localhost"))
Expand Down
1 change: 0 additions & 1 deletion tsuru/http/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

var (
_ http.RoundTripper = &TerminalRoundTripper{}
zero = 0
defaultRoundTripper = http.DefaultTransport
)

Expand Down

0 comments on commit 4d9a77a

Please sign in to comment.