Skip to content

Commit

Permalink
Update to GO 1.19 (#220)
Browse files Browse the repository at this point in the history
* Make linter happy
* Use go 1.19
  • Loading branch information
jastBytes authored Aug 16, 2022
1 parent 4c64ee0 commit 1043551
Show file tree
Hide file tree
Showing 21 changed files with 52 additions and 54 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/golang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ name: Golang CI

on:
push:
branches: [ main, develop ]
branches: [main, develop]
pull_request:
branches: [ main, develop ]
branches: [main, develop]

env:
GO_MODULE: github.com/finleap-connect/monoskope
GO_VERSION: 1.18.x
GO_VERSION: 1.19.x
GINKGO_VERSION: v1.16.5
GO_CI_LINT_VERSION: v1.46.1
GO_CI_LINT_VERSION: v1.48.0

jobs:
lint:
Expand Down
2 changes: 1 addition & 1 deletion build/package/go.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.18-buster AS builder
FROM golang:1.19-buster AS builder

ARG VERSION
ARG GO_MODULE
Expand Down
4 changes: 2 additions & 2 deletions cmd/eventstore/decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package main

import (
"fmt"
"io/ioutil"
"os"
"syscall"

"github.com/finleap-connect/monoskope/pkg/util"
Expand All @@ -31,7 +31,7 @@ var decryptCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
filename := args[0]
ciphertext, err := ioutil.ReadFile(filename)
ciphertext, err := os.ReadFile(filename)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/gateway/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package main
import (
"context"
"fmt"
"io/ioutil"
"os"
"path"
"strings"
Expand Down Expand Up @@ -159,7 +158,7 @@ var serverCmd = &cobra.Command{

// Look for config
if len(k8sTokenLifetime) == 0 {
data, err := ioutil.ReadFile(k8sTokenLifetimeConfigPath)
data, err := os.ReadFile(k8sTokenLifetimeConfigPath)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ PROTOC ?= $(LOCALBIN)/protoc
## Tool Versions
GOMOCK_VERSION ?= v1.5.0
GINKGO_VERSION ?= v1.16.5
GOLANGCILINT_VERSION ?= v1.46.1
GOLANGCILINT_VERSION ?= v1.48.0
PROTOC_VERSION ?= 3.17.0
PROTOC_GEN_GO_VERSION ?= v1.26.0
PROTOC_GEN_GO_GRPC_VERSION ?= v1.1.0
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/finleap-connect/monoskope

go 1.18
go 1.19

require (
github.com/PuerkitoBio/goquery v1.8.0
Expand Down
3 changes: 1 addition & 2 deletions internal/eventstore/backup/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -49,7 +48,7 @@ type S3Config struct {

// NewS3ConfigFromFile creates a new S3 config from a given yaml file
func NewS3ConfigFromFile(path string) (*S3Config, error) {
data, err := ioutil.ReadFile(path)
data, err := os.ReadFile(path)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/eventstore/backupmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package eventstore

import (
"context"
"io/ioutil"
"os"
"path"

"github.com/finleap-connect/monoskope/internal/eventstore/backup"
Expand Down Expand Up @@ -50,7 +50,7 @@ func NewBackupManager(store eventsourcing.EventStore, retention int) (*BackupMan

func (bm *BackupManager) configure() error {
// Get backup destination configuration
fileInfos, err := ioutil.ReadDir(BackupPath)
fileInfos, err := os.ReadDir(BackupPath)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/scimserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package scimserver

import (
"io/ioutil"
"io"
"net/http"

"github.com/elimity-com/scim"
Expand Down Expand Up @@ -53,7 +53,7 @@ func NewServer(config scim.ServiceProviderConfig, userHandler scim.ResourceHandl
func logDebug(log logger.Logger, r *http.Request) {
body := []byte("")
if r.Body != nil {
body, _ = ioutil.ReadAll(r.Body)
body, _ = io.ReadAll(r.Body)
}
log.V(logger.DebugLevel).Info("Handling request...", "Method", r.Method, "URI", r.RequestURI, "Body", string(body), "Header", r.Header)
}
11 changes: 5 additions & 6 deletions internal/scimserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"strings"
Expand Down Expand Up @@ -65,7 +64,7 @@ var _ = Describe("internal/scimserver/Server", func() {
testEnv.scimServer.ServeHTTP(rr, req)
Expect(rr.Code).To(Equal(http.StatusOK))

body, err := ioutil.ReadAll(rr.Body)
body, err := io.ReadAll(rr.Body)
Expect(err).To(Not(HaveOccurred()))
testEnv.Log.Info(string(body))
}
Expand All @@ -80,7 +79,7 @@ var _ = Describe("internal/scimserver/Server", func() {
testEnv.scimServer.ServeHTTP(rr, req)
Expect(rr.Code).To(Equal(http.StatusCreated))

body, err := ioutil.ReadAll(rr.Body)
body, err := io.ReadAll(rr.Body)
Expect(err).To(Not(HaveOccurred()))
Expect(body).To(MatchRegexp(`^{"displayName":"Some User","id":"[0-9a-z\-]+","meta":{"resourceType":"User","location":"Users/[0-9a-z\-]+"},"schemas":\["urn:ietf:params:scim:schemas:core:2.0:User"\],"userName":"[email protected]"}$`))
testEnv.Log.Info(string(body))
Expand All @@ -105,7 +104,7 @@ var _ = Describe("internal/scimserver/Server", func() {
}, backoff.NewExponentialBackOff())
Expect(err).To(Not(HaveOccurred()))

body, err := ioutil.ReadAll(rr.Body)
body, err := io.ReadAll(rr.Body)
Expect(err).To(Not(HaveOccurred()))
testEnv.Log.Info(string(body))
}
Expand Down Expand Up @@ -157,7 +156,7 @@ var _ = Describe("internal/scimserver/Server", func() {
testEnv.scimServer.ServeHTTP(rr, req)
Expect(rr.Code).To(Equal(http.StatusOK))

body, err := ioutil.ReadAll(rr.Body)
body, err := io.ReadAll(rr.Body)
Expect(err).To(Not(HaveOccurred()))
testEnv.Log.Info(string(body))
}
Expand All @@ -168,7 +167,7 @@ var _ = Describe("internal/scimserver/Server", func() {
testEnv.scimServer.ServeHTTP(rr, req)
Expect(rr.Code).To(Equal(http.StatusOK))

body, err := ioutil.ReadAll(rr.Body)
body, err := io.ReadAll(rr.Body)
Expect(err).To(Not(HaveOccurred()))
testEnv.Log.Info(string(body))
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/eventsourcing/aggregate_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func NewAggregateRegistry() AggregateRegistry {
// used to create concrete aggregate types.
//
// An example would be:
// RegisterAggregate(func() Aggregate { return &MyAggregate{} })
//
// RegisterAggregate(func() Aggregate { return &MyAggregate{} })
func (r *aggregateRegistry) RegisterAggregate(factory func() Aggregate) {
aggregate := factory()
if aggregate == nil {
Expand Down
3 changes: 2 additions & 1 deletion pkg/eventsourcing/command_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ func (r *commandRegistry) GetRegisteredCommandTypes() []CommandType {
// used to create concrete command types.
//
// An example would be:
// RegisterCommand(func() Command { return &MyCommand{} })
//
// RegisterCommand(func() Command { return &MyCommand{} })
func (r *commandRegistry) RegisterCommand(factory func(uuid.UUID) Command) {
cmd := factory(uuid.Nil)
if cmd == nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/eventsourcing/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ type metadataKeyType struct {
}

/*
MetadataManager is an interface for a storage of metadata.
It can be used to easily store any metadata in the context of a call.
MetadataManager is an interface for a storage of metadata.
It can be used to easily store any metadata in the context of a call.
*/
type MetadataManager interface {
// GetContext returns a new context enriched with the metadata of this manager.
Expand Down
6 changes: 3 additions & 3 deletions pkg/jwt/key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ package jwt

import (
"crypto/rsa"
"io/ioutil"
"os"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

var _ = Describe("jwt/key", func() {
It("can load private key from file", func() {
bytes, err := ioutil.ReadFile(testEnv.privateKeyFile)
bytes, err := os.ReadFile(testEnv.privateKeyFile)
Expect(err).ToNot(HaveOccurred())
Expect(bytes).ToNot(BeNil())

Expand All @@ -34,7 +34,7 @@ var _ = Describe("jwt/key", func() {
Expect(privKey.Key).To(Equal(testEnv.privateKey))
})
It("can load public key from file", func() {
bytes, err := ioutil.ReadFile(testEnv.publicKeyFile)
bytes, err := os.ReadFile(testEnv.publicKeyFile)
Expect(err).ToNot(HaveOccurred())
Expect(bytes).ToNot(BeNil())

Expand Down
4 changes: 2 additions & 2 deletions pkg/jwt/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package jwt

import (
"io/ioutil"
"os"

"gopkg.in/square/go-jose.v2"
"gopkg.in/square/go-jose.v2/jwt"
Expand Down Expand Up @@ -46,7 +46,7 @@ func NewSigner(privateKeyFilename string) JWTSigner {
// createSigner loads the private key and a returns a new jose.Signer
func (signer *jwtSigner) createSigner() (jose.Signer, error) {
// Read private key from file
privKeyBytes, err := ioutil.ReadFile(signer.privateKeyFileName)
privKeyBytes, err := os.ReadFile(signer.privateKeyFileName)
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/jwt/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"crypto/rsa"
"crypto/x509"
"io/fs"
"io/ioutil"
"os"

"github.com/finleap-connect/monoskope/internal/test"
)
Expand All @@ -38,14 +38,14 @@ func NewTestEnv(testEnv *test.TestEnv) (*TestEnv, error) {
TestEnv: testEnv,
}

privKeyFile, err := ioutil.TempFile("", "private.key")
privKeyFile, err := os.CreateTemp("", "private.key")
if err != nil {
return env, err
}
defer privKeyFile.Close()
env.privateKeyFile = privKeyFile.Name()

pubKeyFile, err := ioutil.TempFile("", "public.key")
pubKeyFile, err := os.CreateTemp("", "public.key")
if err != nil {
return nil, err
}
Expand All @@ -67,7 +67,7 @@ func (env *TestEnv) RotateCertificate() error {
}
env.privateKey = privKey

err = ioutil.WriteFile(env.privateKeyFile, x509.MarshalPKCS1PrivateKey(privKey), fs.ModeAppend)
err = os.WriteFile(env.privateKeyFile, x509.MarshalPKCS1PrivateKey(privKey), fs.ModeAppend)
if err != nil {
return err
}
Expand All @@ -77,7 +77,7 @@ func (env *TestEnv) RotateCertificate() error {
return err
}

err = ioutil.WriteFile(env.publicKeyFile, pubKeyPem, fs.ModeAppend)
err = os.WriteFile(env.publicKeyFile, pubKeyPem, fs.ModeAppend)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/jwt/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package jwt

import (
"errors"
"io/ioutil"
"os"
"sync"

"github.com/finleap-connect/monoskope/pkg/logger"
Expand Down Expand Up @@ -96,7 +96,7 @@ func (v *jwtVerifier) rotatePublicKey(filename string) error {
v.mutex.Lock()
defer v.mutex.Unlock()

pubKeyBytes, err := ioutil.ReadFile(filename)
pubKeyBytes, err := os.ReadFile(filename)
if err != nil {
return err
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/tls/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
"crypto/x509/pkix"
"encoding/pem"
"io/fs"
"io/ioutil"
"math/big"
"net"
"os"
"time"

"github.com/finleap-connect/monoskope/internal/test"
Expand Down Expand Up @@ -94,14 +94,14 @@ func (t *TestEnv) CreateCACertificate() error {
return err
}

caCertFile, err := ioutil.TempFile("", "ca.crt")
caCertFile, err := os.CreateTemp("", "ca.crt")
if err != nil {
return err
}
defer caCertFile.Close()
t.caCertFile = caCertFile.Name()

err = ioutil.WriteFile(t.caCertFile, caPEM.Bytes(), fs.ModeAppend)
err = os.WriteFile(t.caCertFile, caPEM.Bytes(), fs.ModeAppend)
if err != nil {
return err
}
Expand Down Expand Up @@ -151,14 +151,14 @@ func (t *TestEnv) CreateCertificate() error {
return err
}

certFile, err := ioutil.TempFile("", "cert.crt")
certFile, err := os.CreateTemp("", "cert.crt")
if err != nil {
return err
}
defer certFile.Close()
t.certFile = certFile.Name()

err = ioutil.WriteFile(t.certFile, certPEM.Bytes(), fs.ModeAppend)
err = os.WriteFile(t.certFile, certPEM.Bytes(), fs.ModeAppend)
if err != nil {
return err
}
Expand All @@ -172,14 +172,14 @@ func (t *TestEnv) CreateCertificate() error {
return err
}

certKeyFile, err := ioutil.TempFile("", "cert.key")
certKeyFile, err := os.CreateTemp("", "cert.key")
if err != nil {
return err
}
defer certKeyFile.Close()
t.certKeyFile = certKeyFile.Name()

err = ioutil.WriteFile(t.certKeyFile, certPrivKeyPEM.Bytes(), fs.ModeAppend)
err = os.WriteFile(t.certKeyFile, certPrivKeyPEM.Bytes(), fs.ModeAppend)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 1043551

Please sign in to comment.