Skip to content

Commit

Permalink
Merge pull request #2441 from dexidp/go118
Browse files Browse the repository at this point in the history
feat: upgrade Go to 1.18
  • Loading branch information
sagikazarmark authored May 25, 2022
2 parents 3df9cf2 + a02f2e8 commit 70e6cc2
Show file tree
Hide file tree
Showing 21 changed files with 39 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: 1.18

- name: Checkout code
uses: actions/checkout@v3
Expand Down
4 changes: 3 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ linters:
- structcheck
- stylecheck
- tparallel
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace

# Disable temporarily until everything works with Go 1.18
# - typecheck

# TODO: fix linter errors before enabling
# - exhaustivestruct
# - gochecknoglobals
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG BASE_IMAGE=alpine

FROM golang:1.17.8-alpine3.14 AS builder
FROM golang:1.18.0-alpine3.15 AS builder

WORKDIR /usr/local/src/dex

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ proto-internal:
@protoc --go_out=paths=source_relative:. server/internal/*.proto

# Dependency versions
GOLANGCI_VERSION = 1.42.0
GOLANGCI_VERSION = 1.46.0
GOTESTSUM_VERSION ?= 1.7.0
PROTOC_VERSION = 3.15.6
PROTOC_GEN_GO_VERSION = 1.26.0
Expand Down
3 changes: 2 additions & 1 deletion connector/keystone/keystone.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ func (p *conn) Login(ctx context.Context, scopes connector.Scopes, username, pas
func (p *conn) Prompt() string { return "username" }

func (p *conn) Refresh(
ctx context.Context, scopes connector.Scopes, identity connector.Identity) (connector.Identity, error) {
ctx context.Context, scopes connector.Scopes, identity connector.Identity,
) (connector.Identity, error) {
token, err := p.getAdminToken(ctx)
if err != nil {
return identity, fmt.Errorf("keystone: failed to obtain admin token: %v", err)
Expand Down
9 changes: 4 additions & 5 deletions connector/keystone/keystone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
Expand Down Expand Up @@ -454,22 +453,22 @@ func setupVariables(t *testing.T) {
keystoneAdminPassEnv := "DEX_KEYSTONE_ADMIN_PASS"
keystoneURL = os.Getenv(keystoneURLEnv)
if keystoneURL == "" {
t.Skip(fmt.Sprintf("variable %q not set, skipping keystone connector tests\n", keystoneURLEnv))
t.Skipf("variable %q not set, skipping keystone connector tests\n", keystoneURLEnv)
return
}
keystoneAdminURL = os.Getenv(keystoneAdminURLEnv)
if keystoneAdminURL == "" {
t.Skip(fmt.Sprintf("variable %q not set, skipping keystone connector tests\n", keystoneAdminURLEnv))
t.Skipf("variable %q not set, skipping keystone connector tests\n", keystoneAdminURLEnv)
return
}
adminUser = os.Getenv(keystoneAdminUserEnv)
if adminUser == "" {
t.Skip(fmt.Sprintf("variable %q not set, skipping keystone connector tests\n", keystoneAdminUserEnv))
t.Skipf("variable %q not set, skipping keystone connector tests\n", keystoneAdminUserEnv)
return
}
adminPass = os.Getenv(keystoneAdminPassEnv)
if adminPass == "" {
t.Skip(fmt.Sprintf("variable %q not set, skipping keystone connector tests\n", keystoneAdminPassEnv))
t.Skipf("variable %q not set, skipping keystone connector tests\n", keystoneAdminPassEnv)
return
}
authTokenURL = keystoneURL + "/v3/auth/tokens/"
Expand Down
3 changes: 2 additions & 1 deletion connector/ldap/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ func (c *Config) OpenConnector(logger log.Logger) (interface {
connector.Connector
connector.PasswordConnector
connector.RefreshConnector
}, error) {
}, error,
) {
return c.openConnector(logger)
}

Expand Down
12 changes: 8 additions & 4 deletions connector/openshift/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ func (c *Config) Open(id string, logger log.Logger) (conn connector.Connector, e
// OpenWithHTTPClient returns a connector which can be used to login users through an upstream
// OpenShift OAuth2 provider. It provides the ability to inject a http.Client.
func (c *Config) OpenWithHTTPClient(id string, logger log.Logger,
httpClient *http.Client) (conn connector.Connector, err error) {
httpClient *http.Client,
) (conn connector.Connector, err error) {
ctx, cancel := context.WithCancel(context.Background())

wellKnownURL := strings.TrimSuffix(c.Issuer, "/") + wellKnownURLPath
Expand Down Expand Up @@ -156,7 +157,8 @@ func (e *oauth2Error) Error() string {

// HandleCallback parses the request and returns the user's identity
func (c *openshiftConnector) HandleCallback(s connector.Scopes,
r *http.Request) (identity connector.Identity, err error) {
r *http.Request,
) (identity connector.Identity, err error) {
q := r.URL.Query()
if errType := q.Get("error"); errType != "" {
return identity, &oauth2Error{errType, q.Get("error_description")}
Expand All @@ -176,7 +178,8 @@ func (c *openshiftConnector) HandleCallback(s connector.Scopes,
}

func (c *openshiftConnector) Refresh(ctx context.Context, s connector.Scopes,
oldID connector.Identity) (connector.Identity, error) {
oldID connector.Identity,
) (connector.Identity, error) {
var token oauth2.Token
err := json.Unmarshal(oldID.ConnectorData, &token)
if err != nil {
Expand All @@ -189,7 +192,8 @@ func (c *openshiftConnector) Refresh(ctx context.Context, s connector.Scopes,
}

func (c *openshiftConnector) identity(ctx context.Context, s connector.Scopes,
token *oauth2.Token) (identity connector.Identity, err error) {
token *oauth2.Token,
) (identity connector.Identity, err error) {
client := c.oauth2Config.Client(ctx, token)
user, err := c.user(ctx, client)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
buildDeps = with pkgs; [ git go_1_17 gnumake ];
buildDeps = with pkgs; [ git go_1_18 gnumake ];
devDeps = with pkgs;
buildDeps ++ [
golangci-lint
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/dexidp/dex

go 1.17
go 1.18

require (
entgo.io/ent v0.10.1
Expand Down
1 change: 0 additions & 1 deletion storage/conformance/jwks.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type keyPair struct {

// keys are generated beforehand so we don't have to generate RSA keys for every test.
var jsonWebKeys = []keyPair{

{
Public: mustLoadJWK(`{
"use": "sig",
Expand Down
5 changes: 1 addition & 4 deletions storage/ent/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import (

entSQL "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/schema"
"github.com/go-sql-driver/mysql"

// Register postgres driver.
_ "github.com/lib/pq"
"github.com/go-sql-driver/mysql" // Register mysql driver.

"github.com/dexidp/dex/pkg/log"
"github.com/dexidp/dex/storage"
Expand Down
4 changes: 1 addition & 3 deletions storage/ent/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import (

entSQL "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/schema"

// Register postgres driver.
_ "github.com/lib/pq"
_ "github.com/lib/pq" // Register postgres driver.

"github.com/dexidp/dex/pkg/log"
"github.com/dexidp/dex/storage"
Expand Down
4 changes: 1 addition & 3 deletions storage/ent/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import (

"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/schema"

// Register sqlite driver.
_ "github.com/mattn/go-sqlite3"
_ "github.com/mattn/go-sqlite3" // Register sqlite driver.

"github.com/dexidp/dex/pkg/log"
"github.com/dexidp/dex/storage"
Expand Down
2 changes: 1 addition & 1 deletion storage/kubernetes/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const kubeconfigPathVariableName = "DEX_KUBERNETES_CONFIG_PATH"

func TestStorage(t *testing.T) {
if os.Getenv(kubeconfigPathVariableName) == "" {
t.Skip(fmt.Sprintf("variable %q not set, skipping kubernetes storage tests\n", kubeconfigPathVariableName))
t.Skipf("variable %q not set, skipping kubernetes storage tests\n", kubeconfigPathVariableName)
}

suite.Run(t, new(StorageTestSuite))
Expand Down
1 change: 1 addition & 0 deletions storage/sql/crud_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build cgo
// +build cgo

package sql
Expand Down
1 change: 1 addition & 0 deletions storage/sql/migrate_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build cgo
// +build cgo

package sql
Expand Down
1 change: 1 addition & 0 deletions storage/sql/postgres_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.11
// +build go1.11

package sql
Expand Down
1 change: 1 addition & 0 deletions storage/sql/sqlite.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build cgo
// +build cgo

package sql
Expand Down
1 change: 1 addition & 0 deletions storage/sql/sqlite_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build cgo
// +build cgo

package sql
Expand Down

0 comments on commit 70e6cc2

Please sign in to comment.