From b0969d3ae72765c62a53145c16d65df0cd8dcc6d Mon Sep 17 00:00:00 2001 From: Bruno Michel <bmichel@menfin.info> Date: Wed, 23 Mar 2022 11:55:05 +0100 Subject: [PATCH] Recommend go 1.18 (#3335) --- .github/workflows/assets.yml | 2 +- .github/workflows/ci.yml | 2 +- .github/workflows/cli.yml | 2 +- .github/workflows/integration.yml | 2 +- .github/workflows/release.yml | 2 +- docs/docker.md | 2 +- go.mod | 1 + pkg/registry/registry.go | 10 +--------- scripts/Dockerfile | 2 +- web/bitwarden/ciphers.go | 10 ++++++---- worker/exec/konnector.go | 5 ++++- 11 files changed, 19 insertions(+), 21 deletions(-) diff --git a/.github/workflows/assets.yml b/.github/workflows/assets.yml index 7b88e95fd..f4c4d5559 100644 --- a/.github/workflows/assets.yml +++ b/.github/workflows/assets.yml @@ -14,7 +14,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: '1.17.x' + go-version: '1.18.x' - name: Install run: | echo "$(go env GOPATH)/bin" >> $GITHUB_PATH diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8efe0be8..3f6682b6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: matrix: include: # Recommended version - - go-version: 1.17.x + - go-version: 1.18.x couchdb-version: 2.3.1 lint: true # More exotic version diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml index 8c560fa67..f330c5596 100644 --- a/.github/workflows/cli.yml +++ b/.github/workflows/cli.yml @@ -14,7 +14,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: '1.17.x' + go-version: '1.18.x' - name: Install run: | echo "$(go env GOPATH)/bin" >> $GITHUB_PATH diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 17516bea2..66a233cf4 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -38,7 +38,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: '1.17.x' + go-version: '1.18.x' - name: Install Ruby uses: actions/setup-ruby@v1 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index deb4aade5..3bc656701 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Check code uses: actions/checkout@v3 - name: Build the binaries diff --git a/docs/docker.md b/docs/docker.md index 0fa7c0205..6633f227f 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -36,7 +36,7 @@ docker run -it --rm --name cozy-stack \ --workdir /app \ -v $(pwd):/app \ -v $(pwd):/go/bin \ - golang:1.17 \ + golang:1.18 \ go get -v github.com/cozy/cozy-stack ``` diff --git a/go.mod b/go.mod index dd91bb624..f0611403b 100644 --- a/go.mod +++ b/go.mod @@ -51,6 +51,7 @@ require ( golang.org/x/net v0.0.0-20220225172249-27dd8689420f golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a golang.org/x/sync v0.0.0-20210220032951-036812b2e83c + golang.org/x/text v0.3.7 gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect ) diff --git a/pkg/registry/registry.go b/pkg/registry/registry.go index ba00d1d5c..d94508dc4 100644 --- a/pkg/registry/registry.go +++ b/pkg/registry/registry.go @@ -6,7 +6,6 @@ import ( "fmt" "io" "io/ioutil" - "net" "net/http" "net/url" "path" @@ -492,14 +491,7 @@ func fetch(client *http.Client, registry, ref *url.URL, cache CacheControl) (res start := time.Now() resp, err = client.Do(req) if err != nil { - // Try again for temporary errors - start = time.Now() - if ne, ok := err.(net.Error); ok && ne.Temporary() { - resp, err = client.Do(req) - } - if err != nil { - return - } + return } elapsed := time.Since(start) defer func() { diff --git a/scripts/Dockerfile b/scripts/Dockerfile index 41aef5dd9..98ef53620 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -4,7 +4,7 @@ # Multi-stage image: this step builds cozy-stack (and mailhog) -FROM golang:1.17 as build +FROM golang:1.18 as build WORKDIR /app # MailHog diff --git a/web/bitwarden/ciphers.go b/web/bitwarden/ciphers.go index a2c8a9a4b..5d9a648de 100644 --- a/web/bitwarden/ciphers.go +++ b/web/bitwarden/ciphers.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "net/http" - "strings" "time" "github.com/cozy/cozy-stack/model/bitwarden" @@ -135,11 +134,14 @@ type cipherResponse struct { func titleizeKeys(data bitwarden.MapData) map[string]interface{} { res := make(map[string]interface{}) for k, v := range data { - key := strings.Title(k) if k == "ssn" { - key = "SSN" + k = "SSN" } - res[key] = v + key := []byte(k[:]) + if 'a' <= key[0] && key[0] <= 'z' { + key[0] -= 'a' - 'A' + } + res[string(key)] = v } return res } diff --git a/worker/exec/konnector.go b/worker/exec/konnector.go index a9074c286..0cf1acf9b 100644 --- a/worker/exec/konnector.go +++ b/worker/exec/konnector.go @@ -27,6 +27,8 @@ import ( "github.com/cozy/cozy-stack/pkg/realtime" "github.com/cozy/cozy-stack/pkg/registry" "github.com/spf13/afero" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) const ( @@ -381,7 +383,8 @@ func computeFolderPath(inst *instance.Instance, slug string, acc *account.Accoun "_", "%", "_", ".", "_", "'", "_", "\"", "_", ":", "_", "*", "_", "?", "_", "<", "_", ">", "_", "{", "_", "}", "_") accountName := r.Replace(acc.Name) - return fmt.Sprintf("/%s/%s/%s", admin, strings.Title(slug), accountName) + title := cases.Title(language.Make(inst.Locale)).String(slug) + return fmt.Sprintf("/%s/%s/%s", admin, title, accountName) } // ensurePermissions checks that the konnector has the permissions to write -- GitLab