Skip to content

Commit

Permalink
*: bump dependencies & fix multiple cmd pipe proxy copy out
Browse files Browse the repository at this point in the history
  • Loading branch information
criyle committed Apr 13, 2023
1 parent a23ea1c commit dd8c6ec
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
Expand Down
4 changes: 1 addition & 3 deletions cmd/executorserver/grpc_executor/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ func (e *execServer) FileGet(c context.Context, f *pb.FileID) (*pb.FileContent,
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
if f, ok := r.(*os.File); ok {
defer f.Close()
}
defer r.Close()

content, err := io.ReadAll(r)
if err != nil {
Expand Down
5 changes: 1 addition & 4 deletions cmd/executorserver/rest_executor/file_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"io"
"mime"
"net/http"
"os"
"path"

"github.com/criyle/go-judge/envexec"
Expand Down Expand Up @@ -73,9 +72,7 @@ func (f *fileHandle) fileIDGet(c *gin.Context) {
c.AbortWithError(http.StatusInternalServerError, err)
return
}
if f, ok := r.(*os.File); ok {
defer f.Close()
}
defer r.Close()

content, err := io.ReadAll(r)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion cmd/executorserver/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"embed"
"io"
"runtime/debug"
"strings"
)

//go:embed version.*
Expand All @@ -27,5 +28,5 @@ func init() {
if err != nil {
return
}
Version = string(s)
Version = strings.TrimSpace(string(s))
}
4 changes: 1 addition & 3 deletions cmd/ffi/cinterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,7 @@ func FileGet(e *C.char, out **C.char) C.int {
if err != nil {
return -2
}
if f, ok := r.(*os.File); ok {
defer f.Close()
}
defer r.Close()

c, err := io.ReadAll(r)
if err != nil {
Expand Down
7 changes: 3 additions & 4 deletions envexec/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,14 @@ func NewFileOpened(f *os.File) File {
}

// FileToReader get a Reader from underlying file
// if the return value is *os.File, the file need to be closed
// by caller
func FileToReader(f File) (io.Reader, error) {
// the reader need to be closed by caller explicitly
func FileToReader(f File) (io.ReadCloser, error) {
switch f := f.(type) {
case *FileOpened:
return f.File, nil

case *FileReader:
return f.Reader, nil
return io.NopCloser(f.Reader), nil

case *FileInput:
file, err := os.Open(f.Path)
Expand Down
5 changes: 2 additions & 3 deletions envexec/file_copyin.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ func copyIn(m Environment, copyIn map[string]File) ([]FileError, error) {
if err != nil {
return fmt.Errorf("failed to copyIn %v", err)
}
if f, ok := hf.(*os.File); ok {
defer f.Close()
}
defer hf.Close()

// ensure path exists
if err := m.MkdirAll(filepath.Dir(n), 0777); err != nil {
t = ErrCopyInCreateDir
Expand Down
9 changes: 5 additions & 4 deletions envexec/file_prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,10 @@ func pipeProxy(p Pipe, out1 *os.File, in2 *os.File, buffer *os.File) *pipeCollec
}()

return &pipeCollector{
done: done,
buffer: buffer,
limit: p.Limit,
name: p.Name,
done: done,
buffer: buffer,
limit: p.Limit,
name: p.Name,
storage: true,
}
}
50 changes: 28 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,64 @@ go 1.20

require (
github.com/creack/pty v1.1.18
github.com/criyle/go-sandbox v0.9.14
github.com/criyle/go-sandbox v0.9.15
github.com/elastic/go-seccomp-bpf v1.3.0
github.com/elastic/go-ucfg v0.8.6
github.com/gin-contrib/zap v0.1.0
github.com/gin-gonic/gin v1.8.2
github.com/golang/protobuf v1.5.2
github.com/gin-gonic/gin v1.9.0
github.com/golang/protobuf v1.5.3
github.com/gorilla/websocket v1.5.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/koding/multiconfig v0.0.0-20171124222453-69c27309b2d7
github.com/prometheus/client_golang v1.14.0
github.com/zsais/go-gin-prometheus v0.1.0
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.6.0
golang.org/x/net v0.7.0
golang.org/x/crypto v0.8.0
golang.org/x/net v0.9.0
golang.org/x/sync v0.1.0
golang.org/x/sys v0.5.0
google.golang.org/grpc v1.53.0
google.golang.org/protobuf v1.28.1
golang.org/x/sys v0.7.0
google.golang.org/grpc v1.54.0
google.golang.org/protobuf v1.30.0
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/sonic v1.8.7 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/fatih/camelcase v1.0.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.11.2 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/go-playground/validator/v10 v10.12.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.3 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.39.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
go.opentelemetry.io/otel v1.13.0 // indirect
go.opentelemetry.io/otel/trace v1.13.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

retract (
Expand Down
Loading

0 comments on commit dd8c6ec

Please sign in to comment.