Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ jobs:
runs-on: ubuntu-22.04
env:
CGO_CFLAGS_ALLOW: -Xpreprocessor
VIPS_VERSION: 8.15.3
VIPS_VERSION: 8.16.1
V: 6

steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.22
go-version: ^1.24

- name: Check out code
uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG GOLANG_VERSION=1.22.6
ARG GOLANG_VERSION=1.24.2
FROM golang:${GOLANG_VERSION}-bookworm as builder

ARG VIPS_VERSION=8.15.3
ARG VIPS_VERSION=8.16.1
ARG TARGETARCH

ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ build:
CGO_CFLAGS_ALLOW=-Xpreprocessor go build -o bin/imagor ./cmd/imagor/main.go

test:
go clean -testcache && CGO_CFLAGS_ALLOW=-Xpreprocessor go test -coverprofile=profile.cov $(shell go list ./... | grep -v /examples/)
go clean -testcache && CGO_CFLAGS_ALLOW=-Xpreprocessor go test -coverprofile=profile.cov $(shell go list ./... | grep -v /examples/ | grep -v /cmd/)

dev: build
./bin/imagor -debug -imagor-unsafe
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Test Status](https://github.com/cshum/imagor/workflows/test/badge.svg)](https://github.com/cshum/imagor/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/cshum/imagor/badge.svg?branch=master)](https://coveralls.io/github/cshum/imagor?branch=master)
[![Docker Hub](https://img.shields.io/badge/docker-shumc/imagor-blue.svg)](https://hub.docker.com/r/shumc/imagor/)
[![GitHub Container Registry](https://ghcr-badge.deta.dev/cshum/imagor/latest_tag?trim=major&label=ghcr.io&ignore=master,develop&color=%23007ec6)](https://github.com/cshum/imagor/pkgs/container/imagor)
[![GitHub Container Registry](https://ghcr-badge.egpl.dev/cshum/imagor/latest_tag?trim=major&label=ghcr.io&ignore=master,develop&color=%23007ec6)](https://github.com/cshum/imagor/pkgs/container/imagor)
[![Go Reference](https://pkg.go.dev/badge/github.com/cshum/imagor.svg)](https://pkg.go.dev/github.com/cshum/imagor)

imagor is a fast, secure image processing server and Go library.
Expand Down Expand Up @@ -816,4 +816,7 @@ Usage of imagor:
VIPS avif speed, the lowest is at 0 and the fastest is at 9 (Default 5).
-vips-strip-metadata
VIPS strips all metadata from the resulting image

-sentry-dsn
include sentry dsn to integrate imagor with sentry
```
8 changes: 4 additions & 4 deletions blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package imagor
import (
"bytes"
"encoding/json"
"errors"
"github.com/kumparan/imagor/fanoutreader"
"github.com/kumparan/imagor/seekstream"
"io"
"net/http"
"os"
"regexp"
"strings"
"sync"
"time"

"github.com/kumparan/imagor/fanoutreader"
"github.com/kumparan/imagor/seekstream"
)

// BlobType blob content type
Expand Down Expand Up @@ -294,7 +294,7 @@ func (b *Blob) doInit() {
b.blobType = BlobTypeEmpty
}
if err != nil &&
!errors.Is(err, io.ErrUnexpectedEOF) &&
err != io.ErrUnexpectedEOF &&
err != io.EOF {
if b.err == nil {
b.err = err
Expand Down
30 changes: 29 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import (
"crypto/sha512"
"flag"
"fmt"
"go.uber.org/zap/zapcore"
"runtime"
"strings"
"time"

"github.com/TheZeroSlave/zapsentry"
"github.com/getsentry/sentry-go"
"go.uber.org/zap/zapcore"

"github.com/kumparan/imagor/metrics/prometheusmetrics"

"github.com/kumparan/imagor"
Expand Down Expand Up @@ -153,6 +156,8 @@ func CreateServer(args []string, funcs ...Option) (srv *server.Server) {
"Enable strip query string redirection")
serverAccessLog = fs.Bool("server-access-log", false,
"Enable server access log")
sentryDsn = fs.String("sentry-dsn", "",
"Sentry DSN config")

prometheusBind = fs.String("prometheus-bind", "", "Specify address and port to enable Prometheus metrics, e.g. :5000, prom:7000")
prometheusPath = fs.String("prometheus-path", "/", "Prometheus metrics path")
Expand Down Expand Up @@ -192,6 +197,28 @@ func CreateServer(args []string, funcs ...Option) (srv *server.Server) {
}
logger = zap.Must(config.Build())
}

if len(*sentryDsn) > 0 {
err = sentry.Init(sentry.ClientOptions{
Dsn: *sentryDsn,
})
if err != nil {
fmt.Printf("sentry.Init: %s", err)
}
defer sentry.Flush(2 * time.Second)

// Add Sentry integration to zap logger
core, err := zapsentry.NewCore(zapsentry.Configuration{
Level: zapcore.ErrorLevel, // only log errors or higher levels to Sentry
EnableBreadcrumbs: true, // enable sending breadcrumbs to Sentry
BreadcrumbLevel: zapcore.InfoLevel, // at what level should we sent breadcrumbs to sentry, this level can't be higher than `Level`
}, zapsentry.NewSentryClientFromClient(sentry.CurrentHub().Client()))
if err != nil {
fmt.Printf("zapsentry integration error: %s", err)
}
logger = zapsentry.AttachCoreToLogger(core, logger)
}

return logger, *debug
}, funcs...)

Expand Down Expand Up @@ -225,5 +252,6 @@ func CreateServer(args []string, funcs ...Option) (srv *server.Server) {
server.WithLogger(logger),
server.WithDebug(*debug),
server.WithMetrics(pm),
server.WithSentry(*sentryDsn),
)
}
7 changes: 7 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ func TestBind(t *testing.T) {
assert.Equal(t, ":4567", srv.Addr)
}

func TestSentry(t *testing.T) {
srv := CreateServer([]string{
"-sentry-dsn", "https://12345@sentry.com/123",
})
assert.Equal(t, "https://12345@sentry.com/123", srv.SentryDsn)
}

func TestSignerAlgorithm(t *testing.T) {
srv := CreateServer([]string{
"-imagor-signer-type", "sha256",
Expand Down
104 changes: 60 additions & 44 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,73 +1,89 @@
module github.com/kumparan/imagor

go 1.22
go 1.24

toolchain go1.22.1
toolchain go1.24.2

require (
cloud.google.com/go/storage v1.43.0
github.com/aws/aws-sdk-go v1.55.5
github.com/fsouza/fake-gcs-server v1.49.3
github.com/johannesboyne/gofakes3 v0.0.0-20240701191259-edd0227ffc37
cloud.google.com/go/storage v1.52.0
github.com/TheZeroSlave/zapsentry v1.23.0
github.com/aws/aws-sdk-go v1.55.7
github.com/fsouza/fake-gcs-server v1.50.2
github.com/getsentry/sentry-go v0.32.0
github.com/johannesboyne/gofakes3 v0.0.0-20250402064820-d479899d8cbe
github.com/peterbourgon/ff/v3 v3.4.0
github.com/prometheus/client_golang v1.20.2
github.com/rs/cors v1.11.0
github.com/stretchr/testify v1.9.0
github.com/prometheus/client_golang v1.22.0
github.com/rs/cors v1.11.1
github.com/stretchr/testify v1.10.0
go.uber.org/zap v1.27.0
golang.org/x/image v0.19.0
golang.org/x/sync v0.8.0
golang.org/x/image v0.26.0
golang.org/x/sync v0.13.0
)

require (
cloud.google.com/go v0.115.1 // indirect
cloud.google.com/go/auth v0.9.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
cloud.google.com/go/compute/metadata v0.5.0 // indirect
cloud.google.com/go/iam v1.2.0 // indirect
cloud.google.com/go/pubsub v1.42.0 // indirect
cel.dev/expr v0.23.1 // indirect
cloud.google.com/go v0.121.0 // indirect
cloud.google.com/go/auth v0.16.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
cloud.google.com/go/compute/metadata v0.6.0 // indirect
cloud.google.com/go/iam v1.5.2 // indirect
cloud.google.com/go/monitoring v1.24.2 // indirect
cloud.google.com/go/pubsub v1.49.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.27.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.51.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.51.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-jose/go-jose/v4 v4.1.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/renameio/v2 v2.0.0 // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/google/s2a-go v0.1.9 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.3 // indirect
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
github.com/gorilla/handlers v1.5.2 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/xattr v0.4.10 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.56.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.63.0 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46 // indirect
github.com/shabbyrobe/gocovmerge v0.0.0-20230507112040-c3350d9342df // indirect
github.com/spiffe/go-spiffe/v2 v2.5.0 // indirect
github.com/zeebo/errs v1.4.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/detectors/gcp v1.35.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.60.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect
go.opentelemetry.io/otel v1.35.0 // indirect
go.opentelemetry.io/otel/metric v1.35.0 // indirect
go.opentelemetry.io/otel/sdk v1.35.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.35.0 // indirect
go.opentelemetry.io/otel/trace v1.35.0 // indirect
go.shabbyrobe.org/gocovmerge v0.0.0-20230507111327-fa4f82cfbf4d // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.24.0 // indirect
google.golang.org/api v0.194.0 // indirect
google.golang.org/genproto v0.0.0-20240827150818-7e3bb234dfed // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240827150818-7e3bb234dfed // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect
google.golang.org/grpc v1.66.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
golang.org/x/crypto v0.37.0 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/oauth2 v0.29.0 // indirect
golang.org/x/sys v0.32.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/time v0.11.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/api v0.231.0 // indirect
google.golang.org/genproto v0.0.0-20250428153025-10db94c68c34 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250428153025-10db94c68c34 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250428153025-10db94c68c34 // indirect
google.golang.org/grpc v1.72.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading