Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contrib: upgrade to go 1.20 #1454

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ~1.18
go-version: ~1.20
- name: Golang Cache
uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/convert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ~1.18
go-version: ~1.20
- name: Golang Cache
uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.20
- name: Setup pytest
run: |
sudo apt-get update
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.18'
go-version: '1.20'
- name: cache go mod
uses: actions/cache@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ~1.18
go-version: ~1.20
- name: Golang Cache
uses: actions/cache@v3
with:
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ~1.18
go-version: ~1.20
- name: Golang Cache
uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dind_cache_mount := $(if $(DIND_CACHE_DIR),-v $(DIND_CACHE_DIR):/var/lib/docker,
define build_golang
echo "Building target $@ by invoking: $(2)"
if [ $(DOCKER) = "true" ]; then \
docker run --rm -v ${go_path}:/go -v ${current_dir}:/nydus-rs --workdir /nydus-rs/$(1) golang:1.18 $(2) ;\
docker run --rm -v ${go_path}:/go -v ${current_dir}:/nydus-rs --workdir /nydus-rs/$(1) golang:1.20 $(2) ;\
else \
$(2) -C $(1); \
fi
Expand Down
2 changes: 1 addition & 1 deletion contrib/ctr-remote/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/dragonflyoss/image-service/contrib/ctr-remote

go 1.18
go 1.20

require (
github.com/containerd/containerd v1.7.0
Expand Down
2 changes: 1 addition & 1 deletion contrib/nydus-overlayfs/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/dragonflyoss/image-service/contrib/nydus-overlayfs

go 1.18
go 1.20

require (
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 2 additions & 2 deletions contrib/nydus-test/misc/containerize/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ RUN wget https://github.com/opencontainers/runc/releases/download/v1.1.2/runc.am
RUN chmod +x /usr/bin/*; chmod +x /usr/bin/runc

# Install golang
RUN wget https://go.dev/dl/go1.18.1.linux-amd64.tar.gz -O /home/go1.18.1.linux-amd64.tar.gz
RUN tar -C /usr/local -xzf /home/go1.18.1.linux-amd64.tar.gz
RUN wget https://go.dev/dl/go1.20.10.linux-amd64.tar.gz -O /home/go1.20.10.linux-amd64.tar.gz
RUN tar -C /usr/local -xzf /home/go1.20.10.linux-amd64.tar.gz
ENV PATH $PATH:/usr/local/go/bin
RUN mkdir /root/go
RUN rm -rf /home/*
Expand Down
3 changes: 1 addition & 2 deletions contrib/nydusify/cmd/nydusify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package main

import (
"encoding/json"
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -50,7 +49,7 @@ func TestParseBackendConfig(t *testing.T) {
}`
require.True(t, json.Valid([]byte(configJSON)))

file, err := ioutil.TempFile("", "nydusify-backend-config-test.json")
file, err := os.CreateTemp("", "nydusify-backend-config-test.json")
require.NoError(t, err)
defer os.RemoveAll(file.Name())

Expand Down
2 changes: 1 addition & 1 deletion contrib/nydusify/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/dragonflyoss/image-service/contrib/nydusify

go 1.18
go 1.20

require (
github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible
Expand Down
2 changes: 1 addition & 1 deletion smoke/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/dragonflyoss/image-service/smoke

go 1.18
go 1.20

require (
github.com/containerd/containerd v1.7.0
Expand Down
4 changes: 2 additions & 2 deletions smoke/tests/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package tests
import (
"context"
"fmt"
"io/ioutil"
"io"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -231,7 +231,7 @@ func (a *APIV1TestSuite) visit(path string) error {
}
defer f.Close()

ioutil.ReadAll(f)
io.ReadAll(f)

return nil
}
Expand Down
3 changes: 1 addition & 2 deletions smoke/tests/blobcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"io"
"io/fs"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -47,7 +46,7 @@ func (a *BlobCacheTestSuite) prepareTestEnv(t *testing.T) (*tool.Context, string
rootfsReader := rootFs.ToOCITar(t)

ociBlobDigester := digest.Canonical.Digester()
ociBlob, err := ioutil.TempFile(ctx.Env.BlobDir, "oci-blob-")
ociBlob, err := os.CreateTemp(ctx.Env.BlobDir, "oci-blob-")
require.NoError(t, err)

_, err = io.Copy(io.MultiWriter(ociBlobDigester.Hash(), ociBlob), rootfsReader)
Expand Down
3 changes: 1 addition & 2 deletions smoke/tests/tool/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package tool

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -86,7 +85,7 @@ func (ctx *Context) PrepareWorkDir(t *testing.T) {
if tempDir == "" {
tempDir = os.TempDir()
}
workDir, err := ioutil.TempDir(tempDir, "nydus-smoke-")
workDir, err := os.MkdirTemp(tempDir, "nydus-smoke-")
require.NoError(t, err)

blobDir := filepath.Join(workDir, "blobs")
Expand Down
9 changes: 4 additions & 5 deletions smoke/tests/tool/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"context"
"crypto/rand"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -121,7 +120,7 @@ func (l *Layer) Pack(t *testing.T, packOption converter.PackOption, blobDir stri
l.recordFileTree(t)

// Pack OCI tar to nydus native blob
blob, err := ioutil.TempFile(blobDir, "blob-")
blob, err := os.CreateTemp(blobDir, "blob-")
require.NoError(t, err)
defer blob.Close()
blobDigester := digest.Canonical.Digester()
Expand Down Expand Up @@ -160,7 +159,7 @@ func (l *Layer) PackRef(t *testing.T, ctx Context, blobDir string, compress bool
}

// Pack OCI blob to nydus zran blob
rafsBlob, err := ioutil.TempFile(blobDir, "rafs-blob-")
rafsBlob, err := os.CreateTemp(blobDir, "rafs-blob-")
require.NoError(t, err)
defer rafsBlob.Close()
rafsBlobDigester := digest.Canonical.Digester()
Expand All @@ -172,7 +171,7 @@ func (l *Layer) PackRef(t *testing.T, ctx Context, blobDir string, compress bool
require.NoError(t, err)

ociBlobDigester := digest.Canonical.Digester()
ociBlob, err := ioutil.TempFile(blobDir, "oci-blob-")
ociBlob, err := os.CreateTemp(blobDir, "oci-blob-")
require.NoError(t, err)

_, err = io.Copy(io.MultiWriter(twc, ociBlobDigester.Hash(), ociBlob), ociBlobReader)
Expand Down Expand Up @@ -250,7 +249,7 @@ func MergeLayers(t *testing.T, ctx Context, mergeOption converter.MergeOption, l
layers[idx].ReaderAt = ra
}

bootstrap, err := ioutil.TempFile(ctx.Env.WorkDir, "bootstrap-")
bootstrap, err := os.CreateTemp(ctx.Env.WorkDir, "bootstrap-")
require.NoError(t, err)
defer bootstrap.Close()
actualDigests, err := converter.Merge(context.Background(), layers, bootstrap, mergeOption)
Expand Down
3 changes: 1 addition & 2 deletions smoke/tests/tool/nydusd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"os"
Expand Down Expand Up @@ -246,7 +245,7 @@ func (nydusd *Nydusd) MountByAPI(config NydusdConfig) error {
return err
}
defer f.Close()
rafsConfig, err := ioutil.ReadAll(f)
rafsConfig, err := io.ReadAll(f)
if err != nil {
return err
}
Expand Down