diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index cb2a55d77..b6b41990d 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -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: diff --git a/build/package/go.Dockerfile b/build/package/go.Dockerfile index 3acc4444d..4d6d91a82 100644 --- a/build/package/go.Dockerfile +++ b/build/package/go.Dockerfile @@ -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 diff --git a/cmd/eventstore/decrypt.go b/cmd/eventstore/decrypt.go index 00e20a9cb..fd9a4cbd6 100644 --- a/cmd/eventstore/decrypt.go +++ b/cmd/eventstore/decrypt.go @@ -16,7 +16,7 @@ package main import ( "fmt" - "io/ioutil" + "os" "syscall" "github.com/finleap-connect/monoskope/pkg/util" @@ -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 } diff --git a/cmd/gateway/server.go b/cmd/gateway/server.go index 6eb866325..1d9e31d57 100644 --- a/cmd/gateway/server.go +++ b/cmd/gateway/server.go @@ -17,7 +17,6 @@ package main import ( "context" "fmt" - "io/ioutil" "os" "path" "strings" @@ -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 } diff --git a/go.mk b/go.mk index 4554d2de3..e107dd537 100644 --- a/go.mk +++ b/go.mk @@ -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 diff --git a/go.mod b/go.mod index 2470c9511..3f03d1784 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/finleap-connect/monoskope -go 1.18 +go 1.19 require ( github.com/PuerkitoBio/goquery v1.8.0 diff --git a/internal/eventstore/backup/s3/s3.go b/internal/eventstore/backup/s3/s3.go index 48a4e6cbe..3edd902e3 100644 --- a/internal/eventstore/backup/s3/s3.go +++ b/internal/eventstore/backup/s3/s3.go @@ -20,7 +20,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "os" "path/filepath" "sort" @@ -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 } diff --git a/internal/eventstore/backupmanager.go b/internal/eventstore/backupmanager.go index a5d09f438..0a3005b7d 100644 --- a/internal/eventstore/backupmanager.go +++ b/internal/eventstore/backupmanager.go @@ -16,7 +16,7 @@ package eventstore import ( "context" - "io/ioutil" + "os" "path" "github.com/finleap-connect/monoskope/internal/eventstore/backup" @@ -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 } diff --git a/internal/scimserver/server.go b/internal/scimserver/server.go index 85d0ee169..d90aa83e8 100644 --- a/internal/scimserver/server.go +++ b/internal/scimserver/server.go @@ -15,7 +15,7 @@ package scimserver import ( - "io/ioutil" + "io" "net/http" "github.com/elimity-com/scim" @@ -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) } diff --git a/internal/scimserver/server_test.go b/internal/scimserver/server_test.go index fb5fbf593..beff3b72a 100644 --- a/internal/scimserver/server_test.go +++ b/internal/scimserver/server_test.go @@ -18,7 +18,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/http/httptest" "strings" @@ -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)) } @@ -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":"some.user@monoskope.io"}$`)) testEnv.Log.Info(string(body)) @@ -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)) } @@ -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)) } @@ -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)) } diff --git a/pkg/eventsourcing/aggregate_registry.go b/pkg/eventsourcing/aggregate_registry.go index 5f3ec0ee5..bf6024f36 100644 --- a/pkg/eventsourcing/aggregate_registry.go +++ b/pkg/eventsourcing/aggregate_registry.go @@ -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 { diff --git a/pkg/eventsourcing/command_registry.go b/pkg/eventsourcing/command_registry.go index 65bce3be5..fbecc46b2 100644 --- a/pkg/eventsourcing/command_registry.go +++ b/pkg/eventsourcing/command_registry.go @@ -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 { diff --git a/pkg/eventsourcing/metadata.go b/pkg/eventsourcing/metadata.go index 3eb59a67c..c631d5dbb 100644 --- a/pkg/eventsourcing/metadata.go +++ b/pkg/eventsourcing/metadata.go @@ -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. diff --git a/pkg/jwt/key_test.go b/pkg/jwt/key_test.go index 20645e215..c371e442f 100644 --- a/pkg/jwt/key_test.go +++ b/pkg/jwt/key_test.go @@ -16,7 +16,7 @@ package jwt import ( "crypto/rsa" - "io/ioutil" + "os" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -24,7 +24,7 @@ import ( 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()) @@ -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()) diff --git a/pkg/jwt/signer.go b/pkg/jwt/signer.go index a0c54d426..148326921 100644 --- a/pkg/jwt/signer.go +++ b/pkg/jwt/signer.go @@ -15,7 +15,7 @@ package jwt import ( - "io/ioutil" + "os" "gopkg.in/square/go-jose.v2" "gopkg.in/square/go-jose.v2/jwt" @@ -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 } diff --git a/pkg/jwt/testenv.go b/pkg/jwt/testenv.go index e98f3cb25..e577fcf23 100644 --- a/pkg/jwt/testenv.go +++ b/pkg/jwt/testenv.go @@ -19,7 +19,7 @@ import ( "crypto/rsa" "crypto/x509" "io/fs" - "io/ioutil" + "os" "github.com/finleap-connect/monoskope/internal/test" ) @@ -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 } @@ -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 } @@ -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 } diff --git a/pkg/jwt/verifier.go b/pkg/jwt/verifier.go index 40c9dcac0..903c94d18 100644 --- a/pkg/jwt/verifier.go +++ b/pkg/jwt/verifier.go @@ -16,7 +16,7 @@ package jwt import ( "errors" - "io/ioutil" + "os" "sync" "github.com/finleap-connect/monoskope/pkg/logger" @@ -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 } diff --git a/pkg/tls/testenv.go b/pkg/tls/testenv.go index fa6ecfb25..bbcd94144 100644 --- a/pkg/tls/testenv.go +++ b/pkg/tls/testenv.go @@ -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" @@ -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 } @@ -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 } @@ -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 } diff --git a/pkg/tls/tls_config.go b/pkg/tls/tls_config.go index dc0b7341d..85c405864 100644 --- a/pkg/tls/tls_config.go +++ b/pkg/tls/tls_config.go @@ -17,7 +17,7 @@ package tls import ( "crypto/tls" "crypto/x509" - "io/ioutil" + "os" "path/filepath" "sync" @@ -188,7 +188,7 @@ func (t *TLSConfigLoader) load() error { // Load server CA if t.serverCACertificateFile != "" { - certs, err := ioutil.ReadFile(t.serverCACertificateFile) + certs, err := os.ReadFile(t.serverCACertificateFile) if err != nil { return err } @@ -203,7 +203,7 @@ func (t *TLSConfigLoader) load() error { // Load client CA if t.clientCACertificateFile != "" { - certs, err := ioutil.ReadFile(t.clientCACertificateFile) + certs, err := os.ReadFile(t.clientCACertificateFile) if err != nil { return err } diff --git a/pkg/tls/tls_config_test.go b/pkg/tls/tls_config_test.go index 5b362ca79..d86e6d445 100644 --- a/pkg/tls/tls_config_test.go +++ b/pkg/tls/tls_config_test.go @@ -17,7 +17,7 @@ package tls import ( "crypto/tls" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "strings" @@ -69,7 +69,7 @@ var _ = Describe("pkg/tls/tls_config", func() { Expect(err).ToNot(HaveOccurred()) // verify the response - respBodyBytes, err := ioutil.ReadAll(resp.Body) + respBodyBytes, err := io.ReadAll(resp.Body) Expect(err).ToNot(HaveOccurred()) body := strings.TrimSpace(string(respBodyBytes[:])) diff --git a/pkg/util/license_test.go b/pkg/util/license_test.go index 783bb27e7..b99505934 100644 --- a/pkg/util/license_test.go +++ b/pkg/util/license_test.go @@ -17,7 +17,6 @@ package util import ( "bytes" "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -47,7 +46,7 @@ var _ = Describe("License", func() { if filepath.Ext(path) != ".go" { return nil } - content, err := ioutil.ReadFile(path) + content, err := os.ReadFile(path) if err != nil { return nil }