From fea516182695b6324e61b73f4672f195d49b511d Mon Sep 17 00:00:00 2001 From: l3uddz Date: Sun, 10 Apr 2022 21:33:56 +0100 Subject: [PATCH 1/6] refactor(build): use go 1.18 and task rather than make --- .github/workflows/build.yml | 51 +++++++++++++++++++++------ .gitignore | 4 ++- .goreleaser.yml | 2 +- Makefile | 57 ------------------------------ Taskfile.yml | 66 ++++++++++++++++++++++++++++++++++ docker/Dockerfile | 2 +- go.mod | 24 ++++++------- go.sum | 70 +++++++++++++++++++++---------------- 8 files changed, 163 insertions(+), 113 deletions(-) delete mode 100644 Makefile create mode 100644 Taskfile.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cef6427a..f3b828c0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,15 @@ jobs: with: install-only: true + - name: goreleaser info + run: goreleaser -v + + - name: task + uses: arduino/setup-task@v1 + + - name: task info + run: task --version + - name: qemu uses: docker/setup-qemu-action@v1 @@ -33,7 +42,7 @@ jobs: - name: go uses: actions/setup-go@v1 with: - go-version: 1.17 + go-version: 1.18 - name: go info run: | @@ -41,23 +50,39 @@ jobs: go env # cache - - name: cache - uses: actions/cache@v1 + - name: cache-paths + id: go-cache-paths + run: | + echo "::set-output name=go-build::$(go env GOCACHE)" + echo "::set-output name=go-mod::$(go env GOMODCACHE)" + + - name: cache-build + uses: actions/cache@v2 + with: + path: ${{ steps.go-cache-paths.outputs.go-build }} + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + + - name: cache-mod + uses: actions/cache@v2 + with: + path: ${{ steps.go-cache-paths.outputs.go-mod }} + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + + - name: cache-task + uses: actions/cache@v2 with: - path: vendor - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- + path: .task/**/* + key: ${{ runner.os }}-go-task # vendor - name: vendor run: | - make vendor + task vendor # test - name: tests run: | - make test + task test # git status - name: git status @@ -67,7 +92,7 @@ jobs: - name: build if: startsWith(github.ref, 'refs/tags/') == false run: | - make snapshot + task snapshot # publish - name: publish @@ -76,7 +101,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_REF: ${{ github.ref }} run: | - make publish + task publish # artifacts - name: artifact_linux @@ -116,6 +141,8 @@ jobs: platforms: linux/amd64,linux/arm64,linux/arm/v7 pull: true push: true + cache-from: type=gha + cache-to: type=gha,mode=max tags: | cloudb0x/autoscan:${{ steps.releasetag.outputs.tag }} cloudb0x/autoscan:latest @@ -145,6 +172,8 @@ jobs: platforms: linux/amd64,linux/arm64,linux/arm/v7 pull: true push: true + cache-from: type=gha + cache-to: type=gha,mode=max tags: | cloudb0x/autoscan:${{ steps.dockertag.outputs.replaced }} diff --git a/.gitignore b/.gitignore index 30afe056..759cc039 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ dist/ *.db *.log /autoscan -/config.yml \ No newline at end of file +/config.yml + +/.task/ \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml index ae045d32..cbfd5143 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -48,7 +48,7 @@ checksum: # Snapshot snapshot: - name_template: "{{ .Major }}.{{ .Minor }}.{{ .Patch }}-dev+{{ .ShortCommit }}" + name_template: "{{ .Major }}.{{ .Minor }}.{{ .Patch }}-dev+{{ .Branch }}" # Changelog changelog: diff --git a/Makefile b/Makefile deleted file mode 100644 index c11e97d8..00000000 --- a/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -.DEFAULT_GOAL := build -CMD := autoscan -TARGET := $(shell go env GOOS)_$(shell go env GOARCH) -DIST_PATH := dist -BUILD_PATH := ${DIST_PATH}/${CMD}_${TARGET} -GO_FILES := $(shell find . -path ./vendor -prune -or -type f -name '*.go' -print) -HTML_FILES := $(shell find . -path ./vendor -prune -or -type f -name '*.html' -print) -SQL_FILES := $(shell find . -path ./vendor -prune -or -type f -name '*.sql' -print) -GIT_COMMIT := $(shell git rev-parse --short HEAD) -TIMESTAMP := $(shell date +%s) -VERSION ?= 0.0.0-dev -CGO := 0 - -# Deps -.PHONY: check_goreleaser -check_goreleaser: - @command -v goreleaser >/dev/null || (echo "goreleaser is required."; exit 1) - -.PHONY: test -test: ## Run tests - go test ./... -cover -v -race ${GO_PACKAGES} - -.PHONY: vendor -vendor: ## Vendor files and tidy go.mod - go mod vendor - go mod tidy - -.PHONY: vendor_update -vendor_update: ## Update vendor dependencies - go get -u ./... - ${MAKE} vendor - -.PHONY: build -build: vendor ${BUILD_PATH}/${CMD} ## Build application - -# Binary -${BUILD_PATH}/${CMD}: ${GO_FILES} ${HTML_FILES} ${SQL_FILES} go.sum - @echo "Building for ${TARGET}..." && \ - mkdir -p ${BUILD_PATH} && \ - CGO_ENABLED=${CGO} go build \ - -mod vendor \ - -trimpath \ - -ldflags "-s -w -X main.Version=${VERSION} -X main.GitCommit=${GIT_COMMIT} -X main.Timestamp=${TIMESTAMP}" \ - -o ${BUILD_PATH}/${CMD} \ - ./cmd/autoscan - -.PHONY: release -release: check_goreleaser ## Generate a release, but don't publish - goreleaser --skip-validate --skip-publish --rm-dist - -.PHONY: publish -publish: check_goreleaser ## Generate a release, and publish - goreleaser --rm-dist - -.PHONY: snapshot -snapshot: check_goreleaser ## Generate a snapshot release - goreleaser --snapshot --skip-publish --rm-dist diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 00000000..d239499c --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,66 @@ +version: '3' + +vars: + APP: autoscan + CGO_ENABLED: 0 + GOOS: + sh: go env GOOS + GOARCH: + sh: go env GOARCH + DIST_PATH: dist + BUILD_PATH: "{{.DIST_PATH}}/{{.APP}}_{{.GOOS}}_{{.GOARCH}}" + +env: + GIT_COMMIT: + sh: git rev-parse --short HEAD + TIMESTAMP: '{{now | unixEpoch}}' + VERSION: 0.0.0-dev + +tasks: + test: + desc: Go tests + cmds: + - go test ./... -cover -v -race ${GO_PACKAGES} + + vendor: + desc: Go vendor + sources: + - '**/*.go' + - ./go.sum + cmds: + - go mod vendor + - go mod tidy + + vendor_update: + desc: Go vendor update + cmds: + - go get -u ./... + - task: vendor + + build: + desc: Generate a development binary + dir: '{{.BUILD_PATH}}' + deps: [ vendor ] + cmds: + - | + CGO_ENABLED={{.CGO_ENABLED}} \ + go build \ + -mod vendor \ + -trimpath \ + -ldflags "-s -w -X main.Version=${VERSION} -X main.GitCommit=${GIT_COMMIT} -X main.Timestamp=${TIMESTAMP}" \ + ../../cmd/{{.APP}} + + release: + desc: Generate a release, but don't publish + cmds: + - goreleaser --skip-validate --skip-publish --rm-dist + + snapshot: + desc: Generate a snapshot release + cmds: + - goreleaser --snapshot --skip-publish --rm-dist + + publish: + desc: Generate a release, and publish + cmds: + - goreleaser --rm-dist \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 6509f47d..77ea25c6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM sc4h/alpine-s6overlay:3.12 +FROM sc4h/alpine-s6overlay:3.10 ARG TARGETOS ARG TARGETARCH diff --git a/go.mod b/go.mod index f758cd01..fcc4539a 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module github.com/cloudbox/autoscan -go 1.17 +go 1.18 require ( github.com/BurntSushi/toml v0.3.1 // indirect - github.com/alecthomas/kong v0.4.1 + github.com/alecthomas/kong v0.5.0 github.com/fsnotify/fsnotify v1.5.1 github.com/go-chi/chi/v5 v5.0.7 github.com/l3uddz/bernard v0.5.1 @@ -15,15 +15,15 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/robfig/cron/v3 v3.0.1 github.com/rs/zerolog v1.26.1 - golang.org/x/mod v0.5.1 // indirect + golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c - golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 // indirect + golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f // indirect golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 - golang.org/x/tools v0.1.9 // indirect + golang.org/x/tools v0.1.10 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 - modernc.org/cc/v3 v3.35.22 // indirect - modernc.org/sqlite v1.14.7 + modernc.org/cc/v3 v3.35.25 // indirect + modernc.org/sqlite v1.16.0 modernc.org/strutil v1.1.1 // indirect ) @@ -32,13 +32,13 @@ require ( github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect - github.com/rs/xid v1.3.0 // indirect + github.com/rs/xid v1.4.0 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect lukechampine.com/uint128 v1.2.0 // indirect - modernc.org/ccgo/v3 v3.15.13 // indirect - modernc.org/libc v1.14.5 // indirect + modernc.org/ccgo/v3 v3.15.18 // indirect + modernc.org/libc v1.14.12 // indirect modernc.org/mathutil v1.4.1 // indirect - modernc.org/memory v1.0.5 // indirect - modernc.org/opt v0.1.1 // indirect + modernc.org/memory v1.0.7 // indirect + modernc.org/opt v0.1.3 // indirect modernc.org/token v1.0.0 // indirect ) diff --git a/go.sum b/go.sum index 83b9519a..17ca4258 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/alecthomas/kong v0.2.9/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE= github.com/alecthomas/kong v0.2.11/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE= -github.com/alecthomas/kong v0.4.1 h1:0sFnMts+ijOiFuSHsMB9MlDi3NGINBkx9KIw1/gcuDw= -github.com/alecthomas/kong v0.4.1/go.mod h1:uzxf/HUh0tj43x1AyJROl3JT7SgsZ5m+icOv1csRhc0= +github.com/alecthomas/kong v0.5.0 h1:u8Kdw+eeml93qtMZ04iei0CFYve/WPcA5IFh+9wSskE= +github.com/alecthomas/kong v0.5.0/go.mod h1:uzxf/HUh0tj43x1AyJROl3JT7SgsZ5m+icOv1csRhc0= github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142 h1:8Uy0oSf5co/NZXje7U1z8Mpep++QJOldL2hs/sBQf48= github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= @@ -32,7 +32,7 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U= github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM= @@ -49,8 +49,9 @@ github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6O github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= -github.com/rs/xid v1.3.0 h1:6NjYksEUlhurdVehpc7S7dk6DAmcKv8V9gG0FsVN2U4= github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY= +github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc= github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -60,21 +61,19 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= -golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= @@ -91,22 +90,20 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 h1:nhht2DYV/Sn3qOayu8lM+cU1ii9sTLUeBQwQQfUHtrs= -golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f h1:8w7RhxzTVgUzw/AH/9mUV5q0vMgy40SQRursCcfmkCw= +golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 h1:M73Iuj3xbbb9Uk1DYhzydthsj6oOd6l9bpuFcNoUvTs= golang.org/x/time v0.0.0-20220224211638-0e9765cccd65/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= -golang.org/x/tools v0.1.9 h1:j9KsMiaP1c3B0OTQGth0/k+miLGTgLsAFUCrF2vLcF8= -golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -140,8 +137,10 @@ modernc.org/cc/v3 v3.35.16/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g modernc.org/cc/v3 v3.35.17/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= modernc.org/cc/v3 v3.35.18/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= modernc.org/cc/v3 v3.35.20/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= -modernc.org/cc/v3 v3.35.22 h1:BzShpwCAP7TWzFppM4k2t03RhXhgYqaibROWkrWq7lE= modernc.org/cc/v3 v3.35.22/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= +modernc.org/cc/v3 v3.35.24/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= +modernc.org/cc/v3 v3.35.25 h1:GwDPOIj37Ek5Kh+rsH5bKrgGUx/s5KDGOxeWz/MbXUI= +modernc.org/cc/v3 v3.35.25/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= modernc.org/ccgo/v3 v3.9.0/go.mod h1:nQbgkn8mwzPdp4mm6BT6+p85ugQ7FrGgIcYaE7nSrpY= modernc.org/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60= modernc.org/ccgo/v3 v3.10.0/go.mod h1:c0yBmkRFi7uW4J7fwx/JiijwOjeAeR2NoSaRVFPmjMw= @@ -181,15 +180,18 @@ modernc.org/ccgo/v3 v3.12.86/go.mod h1:dN7S26DLTgVSni1PVA3KxxHTcykyDurf3OgUzNqTS modernc.org/ccgo/v3 v3.12.90/go.mod h1:obhSc3CdivCRpYZmrvO88TXlW0NvoSVvdh/ccRjJYko= modernc.org/ccgo/v3 v3.12.92/go.mod h1:5yDdN7ti9KWPi5bRVWPl8UNhpEAtCjuEE7ayQnzzqHA= modernc.org/ccgo/v3 v3.13.1/go.mod h1:aBYVOUfIlcSnrsRVU8VRS35y2DIfpgkmVkYZ0tpIXi4= -modernc.org/ccgo/v3 v3.15.1/go.mod h1:md59wBwDT2LznX/OTCPoVS6KIsdRgY8xqQwBV+hkTH0= modernc.org/ccgo/v3 v3.15.9/go.mod h1:md59wBwDT2LznX/OTCPoVS6KIsdRgY8xqQwBV+hkTH0= modernc.org/ccgo/v3 v3.15.10/go.mod h1:wQKxoFn0ynxMuCLfFD09c8XPUCc8obfchoVR9Cn0fI8= modernc.org/ccgo/v3 v3.15.12/go.mod h1:VFePOWoCd8uDGRJpq/zfJ29D0EVzMSyID8LCMWYbX6I= -modernc.org/ccgo/v3 v3.15.13 h1:hqlCzNJTXLrhS70y1PqWckrF9x1btSQRC7JFuQcBg5c= -modernc.org/ccgo/v3 v3.15.13/go.mod h1:QHtvdpeODlXjdK3tsbpyK+7U9JV4PQsrPGIbtmc0KfY= +modernc.org/ccgo/v3 v3.15.14/go.mod h1:144Sz2iBCKogb9OKwsu7hQEub3EVgOlyI8wMUPGKUXQ= +modernc.org/ccgo/v3 v3.15.15/go.mod h1:z5qltXjU4PJl0pE5nhYQCvA9DhPHiWsl5GWl89+NSYE= +modernc.org/ccgo/v3 v3.15.16/go.mod h1:XbKRMeMWMdq712Tr5ECgATYMrzJ+g9zAZEj2ktzBe24= +modernc.org/ccgo/v3 v3.15.17/go.mod h1:bofnFkpRFf5gLY+mBZIyTW6FEcp26xi2lgOFk2Rlvs0= +modernc.org/ccgo/v3 v3.15.18 h1:X5ym656Ye7/ubL+wox0SeF9aRX5od1UDFn1tAbQR+90= +modernc.org/ccgo/v3 v3.15.18/go.mod h1:/2lv3WjHyanEr2sAPdGKRC38n6f0werut9BRXUjjX+A= modernc.org/ccorpus v1.11.1/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ= -modernc.org/ccorpus v1.11.4 h1:YOmQBBzE8GC/puUx76D5j/gJYIZQsydrh6VMJVfXF0M= -modernc.org/ccorpus v1.11.4/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ= +modernc.org/ccorpus v1.11.6 h1:J16RXiiqiCgua6+ZvQot4yUuUy8zxgqbqEEUuGPlISk= +modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ= modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM= modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= modernc.org/libc v1.7.13-0.20210308123627-12f642a52bb8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w= @@ -235,30 +237,38 @@ modernc.org/libc v1.12.0/go.mod h1:2MH3DaF/gCU8i/UBiVE1VFRos4o523M7zipmwH8SIgQ= modernc.org/libc v1.14.1/go.mod h1:npFeGWjmZTjFeWALQLrvklVmAxv4m80jnG3+xI8FdJk= modernc.org/libc v1.14.2/go.mod h1:MX1GBLnRLNdvmK9azU9LCxZ5lMyhrbEMK8rG3X/Fe34= modernc.org/libc v1.14.3/go.mod h1:GPIvQVOVPizzlqyRX3l756/3ppsAgg1QgPxjr5Q4agQ= -modernc.org/libc v1.14.5 h1:DAHvwGoVRDZs5iJXnX9RJrgXSsorupCWmJ2ac964Owk= -modernc.org/libc v1.14.5/go.mod h1:2PJHINagVxO4QW/5OQdRrvMYo+bm5ClpUFfyXCYl9ak= +modernc.org/libc v1.14.6/go.mod h1:2PJHINagVxO4QW/5OQdRrvMYo+bm5ClpUFfyXCYl9ak= +modernc.org/libc v1.14.7/go.mod h1:f8xfWXW8LW41qb4X5+huVQo5dcfPlq7Cbny2TDheMv0= +modernc.org/libc v1.14.8/go.mod h1:9+JCLb1MWSY23smyOpIPbd5ED+rSS/ieiDWUpdyO3mo= +modernc.org/libc v1.14.10/go.mod h1:y1MtIWhwpJFpLYm6grAThtuXJKEsY6xkdZmXbRngIdo= +modernc.org/libc v1.14.11/go.mod h1:l5/Mz/GrZwOqzwRHA3abgSCnSeJzzTl+Ify0bAwKbAw= +modernc.org/libc v1.14.12 h1:pUBZTYoISfbb4pCf4PECENpbvwDBxeKc+/dS9LyOWFM= +modernc.org/libc v1.14.12/go.mod h1:fJdoe23MHu2ruPQkFPPqCpToDi5cckzsbmkI6Ez0LqQ= modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.4.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.4.1 h1:ij3fYGe8zBF4Vu+g0oT7mB06r8sqGWKuJu1yXeR4by8= modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc= -modernc.org/memory v1.0.5 h1:XRch8trV7GgvTec2i7jc33YlUI0RKVDBvZ5eZ5m8y14= modernc.org/memory v1.0.5/go.mod h1:B7OYswTRnfGg+4tDH1t1OeUNnsy2viGTdME4tzd+IjM= -modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A= +modernc.org/memory v1.0.6/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw= +modernc.org/memory v1.0.7 h1:UE3cxTRFa5tfUibAV7Jqq8P7zRY0OlJg+yWVIIaluEE= +modernc.org/memory v1.0.7/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw= modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= +modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4= +modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= modernc.org/sqlite v1.10.0/go.mod h1:PGzq6qlhyYjL6uVbSgS6WoF7ZopTW/sI7+7p+mb4ZVU= -modernc.org/sqlite v1.14.7 h1:A+6rGjtRQbt9SORXfV+hUyXOP3mDf7J5uz+EES/CNPE= -modernc.org/sqlite v1.14.7/go.mod h1:yiCvMv3HblGmzENNIaNtFhfaNIwcla4u2JQEwJPzfEc= +modernc.org/sqlite v1.16.0 h1:DdvOGaWN0y+X7t2L7RUD63gcwbVjYZjcBZnA68g44EI= +modernc.org/sqlite v1.16.0/go.mod h1:Jwe13ItpESZ+78K5WS6+AjXsUg+JvirsjN3iIDO4C8k= modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= modernc.org/strutil v1.1.1 h1:xv+J1BXY3Opl2ALrBwyfEikFAj8pmqcpnfmuwUwcozs= modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw= modernc.org/tcl v1.5.0/go.mod h1:gb57hj4pO8fRrK54zveIfFXBaMHK3SKJNWcmRw1cRzc= -modernc.org/tcl v1.11.0 h1:B/zzEYjINeaki38KcIqdQRQx7W3WE7TkrlTwGnbm2II= -modernc.org/tcl v1.11.0/go.mod h1:zsTUpbQ+NxQEjOjCUlImDLPv1sG8Ww0qp66ZvyOxCgw= +modernc.org/tcl v1.11.2 h1:mXpsx3AZqJt83uDiFu9UYQVBjNjaWKGCF1YDSlpCL6Y= +modernc.org/tcl v1.11.2/go.mod h1:BRzgpajcGdS2qTxniOx9c/dcxjlbA7p12eJNmiriQYo= modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk= modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= modernc.org/z v1.0.1-0.20210308123920-1f282aa71362/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA= modernc.org/z v1.0.1/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA= -modernc.org/z v1.3.0 h1:4RWULo1Nvaq5ZBhbLe74u8p6tV4Mmm0ZrPBXYPm/xjM= -modernc.org/z v1.3.0/go.mod h1:+mvgLH814oDjtATDdT3rs84JnUIpkvAF5B8AVkNlE2g= +modernc.org/z v1.3.2 h1:4GWBVMa48UDC7KQ9tnaggN/yTlXg+CdCX9bhgHPQ9AM= +modernc.org/z v1.3.2/go.mod h1:PEU2oK2OEA1CfzDTd+8E908qEXhC9s0MfyKp5LZsd+k= From 35b201b4ec31ebdce803dea70065b5a106444dd8 Mon Sep 17 00:00:00 2001 From: l3uddz Date: Sun, 10 Apr 2022 21:41:56 +0100 Subject: [PATCH 2/6] refactor: goimports --- cmd/autoscan/config.go | 2 +- cmd/autoscan/stats.go | 3 ++- migrate/migrator.go | 1 + processor/datastore_test.go | 3 ++- targets/autoscan/api.go | 5 +++-- triggers/bernard/datastore.go | 1 + triggers/bernard/limiter.go | 5 +++-- triggers/bernard/paths.go | 3 ++- triggers/bernard/postprocess.go | 1 + triggers/inotify/inotify.go | 7 ++++--- 10 files changed, 20 insertions(+), 11 deletions(-) diff --git a/cmd/autoscan/config.go b/cmd/autoscan/config.go index c727f99d..953eb454 100644 --- a/cmd/autoscan/config.go +++ b/cmd/autoscan/config.go @@ -42,4 +42,4 @@ func getBinaryPath() string { } return dir -} \ No newline at end of file +} diff --git a/cmd/autoscan/stats.go b/cmd/autoscan/stats.go index 62abcc58..8de22c48 100644 --- a/cmd/autoscan/stats.go +++ b/cmd/autoscan/stats.go @@ -2,10 +2,11 @@ package main import ( "errors" + "time" + "github.com/cloudbox/autoscan" "github.com/cloudbox/autoscan/processor" "github.com/rs/zerolog/log" - "time" ) func scanStats(proc *processor.Processor, interval time.Duration) { diff --git a/migrate/migrator.go b/migrate/migrator.go index ac61c65c..de91afc9 100644 --- a/migrate/migrator.go +++ b/migrate/migrator.go @@ -5,6 +5,7 @@ import ( "embed" "errors" "fmt" + "github.com/oriser/regroup" "modernc.org/sqlite" ) diff --git a/processor/datastore_test.go b/processor/datastore_test.go index f68a329a..d23342d5 100644 --- a/processor/datastore_test.go +++ b/processor/datastore_test.go @@ -3,11 +3,12 @@ package processor import ( "database/sql" "errors" - "github.com/cloudbox/autoscan/migrate" "reflect" "testing" "time" + "github.com/cloudbox/autoscan/migrate" + "github.com/cloudbox/autoscan" // sqlite3 driver diff --git a/targets/autoscan/api.go b/targets/autoscan/api.go index fc4bdc1f..9766e602 100644 --- a/targets/autoscan/api.go +++ b/targets/autoscan/api.go @@ -2,10 +2,11 @@ package autoscan import ( "fmt" - "github.com/cloudbox/autoscan" - "github.com/rs/zerolog" "net/http" "net/url" + + "github.com/cloudbox/autoscan" + "github.com/rs/zerolog" ) type apiClient struct { diff --git a/triggers/bernard/datastore.go b/triggers/bernard/datastore.go index f9f89c98..34a95b68 100644 --- a/triggers/bernard/datastore.go +++ b/triggers/bernard/datastore.go @@ -4,6 +4,7 @@ import ( "database/sql" "errors" "fmt" + "github.com/l3uddz/bernard/datastore" "github.com/l3uddz/bernard/datastore/sqlite" ) diff --git a/triggers/bernard/limiter.go b/triggers/bernard/limiter.go index a714e01e..78cde8e4 100644 --- a/triggers/bernard/limiter.go +++ b/triggers/bernard/limiter.go @@ -2,10 +2,11 @@ package bernard import ( "context" - "golang.org/x/sync/semaphore" - "golang.org/x/time/rate" "sync" "time" + + "golang.org/x/sync/semaphore" + "golang.org/x/time/rate" ) const ( diff --git a/triggers/bernard/paths.go b/triggers/bernard/paths.go index edbb5e90..86fbb3a8 100644 --- a/triggers/bernard/paths.go +++ b/triggers/bernard/paths.go @@ -2,10 +2,11 @@ package bernard import ( "fmt" + "path/filepath" + "github.com/l3uddz/bernard" "github.com/l3uddz/bernard/datastore" "github.com/l3uddz/bernard/datastore/sqlite" - "path/filepath" ) type Paths struct { diff --git a/triggers/bernard/postprocess.go b/triggers/bernard/postprocess.go index b1a89ddc..f976cd5f 100644 --- a/triggers/bernard/postprocess.go +++ b/triggers/bernard/postprocess.go @@ -2,6 +2,7 @@ package bernard import ( "fmt" + "github.com/l3uddz/bernard" "github.com/l3uddz/bernard/datastore" "github.com/l3uddz/bernard/datastore/sqlite" diff --git a/triggers/inotify/inotify.go b/triggers/inotify/inotify.go index 740a079d..5fb3cba9 100644 --- a/triggers/inotify/inotify.go +++ b/triggers/inotify/inotify.go @@ -2,14 +2,15 @@ package inotify import ( "fmt" - "github.com/cloudbox/autoscan" - "github.com/fsnotify/fsnotify" - "github.com/rs/zerolog" "os" "path/filepath" "strings" "sync" "time" + + "github.com/cloudbox/autoscan" + "github.com/fsnotify/fsnotify" + "github.com/rs/zerolog" ) type Config struct { From d767d6394777449a9be74178c01123065370b1d7 Mon Sep 17 00:00:00 2001 From: l3uddz Date: Mon, 11 Apr 2022 09:29:47 +0100 Subject: [PATCH 3/6] docker: v2 s6overlay base image --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 77ea25c6..457b0053 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM sc4h/alpine-s6overlay:3.10 +FROM sc4h/alpine-s6overlay:v2-3.15 ARG TARGETOS ARG TARGETARCH From 9034044589dae7e8d4a3ccd33f9b802cfda43122 Mon Sep 17 00:00:00 2001 From: l3uddz Date: Tue, 12 Apr 2022 23:03:59 +0100 Subject: [PATCH 4/6] refactor: imports re-organisation --- cmd/autoscan/router.go | 5 +++-- cmd/autoscan/stats.go | 3 ++- processor/datastore_test.go | 3 +-- targets/autoscan/api.go | 3 ++- targets/autoscan/autoscan.go | 3 ++- targets/emby/api.go | 3 ++- targets/emby/emby.go | 3 ++- targets/jellyfin/api.go | 3 ++- targets/jellyfin/jellyfin.go | 3 ++- targets/plex/api.go | 3 ++- targets/plex/plex.go | 3 ++- triggers/a_train/a_train.go | 3 ++- triggers/a_train/a_train_test.go | 3 ++- triggers/inotify/inotify.go | 3 ++- triggers/lidarr/lidarr.go | 3 ++- triggers/manual/manual.go | 3 ++- triggers/radarr/radarr.go | 3 ++- triggers/sonarr/sonarr.go | 3 ++- 18 files changed, 36 insertions(+), 20 deletions(-) diff --git a/cmd/autoscan/router.go b/cmd/autoscan/router.go index 72d7f78d..22ccc1ff 100644 --- a/cmd/autoscan/router.go +++ b/cmd/autoscan/router.go @@ -8,14 +8,15 @@ import ( "github.com/rs/zerolog/hlog" "github.com/rs/zerolog/log" + "github.com/go-chi/chi/v5" + "github.com/go-chi/chi/v5/middleware" + "github.com/cloudbox/autoscan/processor" "github.com/cloudbox/autoscan/triggers/a_train" "github.com/cloudbox/autoscan/triggers/lidarr" "github.com/cloudbox/autoscan/triggers/manual" "github.com/cloudbox/autoscan/triggers/radarr" "github.com/cloudbox/autoscan/triggers/sonarr" - "github.com/go-chi/chi/v5" - "github.com/go-chi/chi/v5/middleware" ) func pattern(name string) string { diff --git a/cmd/autoscan/stats.go b/cmd/autoscan/stats.go index 8de22c48..7abbe053 100644 --- a/cmd/autoscan/stats.go +++ b/cmd/autoscan/stats.go @@ -4,9 +4,10 @@ import ( "errors" "time" + "github.com/rs/zerolog/log" + "github.com/cloudbox/autoscan" "github.com/cloudbox/autoscan/processor" - "github.com/rs/zerolog/log" ) func scanStats(proc *processor.Processor, interval time.Duration) { diff --git a/processor/datastore_test.go b/processor/datastore_test.go index d23342d5..86858391 100644 --- a/processor/datastore_test.go +++ b/processor/datastore_test.go @@ -7,9 +7,8 @@ import ( "testing" "time" - "github.com/cloudbox/autoscan/migrate" - "github.com/cloudbox/autoscan" + "github.com/cloudbox/autoscan/migrate" // sqlite3 driver _ "modernc.org/sqlite" diff --git a/targets/autoscan/api.go b/targets/autoscan/api.go index 9766e602..82cdd557 100644 --- a/targets/autoscan/api.go +++ b/targets/autoscan/api.go @@ -5,8 +5,9 @@ import ( "net/http" "net/url" - "github.com/cloudbox/autoscan" "github.com/rs/zerolog" + + "github.com/cloudbox/autoscan" ) type apiClient struct { diff --git a/targets/autoscan/autoscan.go b/targets/autoscan/autoscan.go index d57afd7f..5d4efcc5 100644 --- a/targets/autoscan/autoscan.go +++ b/targets/autoscan/autoscan.go @@ -1,8 +1,9 @@ package autoscan import ( - "github.com/cloudbox/autoscan" "github.com/rs/zerolog" + + "github.com/cloudbox/autoscan" ) type Config struct { diff --git a/targets/emby/api.go b/targets/emby/api.go index 3d3d0d8d..0498fd3a 100644 --- a/targets/emby/api.go +++ b/targets/emby/api.go @@ -6,8 +6,9 @@ import ( "fmt" "net/http" - "github.com/cloudbox/autoscan" "github.com/rs/zerolog" + + "github.com/cloudbox/autoscan" ) type apiClient struct { diff --git a/targets/emby/emby.go b/targets/emby/emby.go index fb64a094..90e415a7 100644 --- a/targets/emby/emby.go +++ b/targets/emby/emby.go @@ -4,8 +4,9 @@ import ( "fmt" "strings" - "github.com/cloudbox/autoscan" "github.com/rs/zerolog" + + "github.com/cloudbox/autoscan" ) type Config struct { diff --git a/targets/jellyfin/api.go b/targets/jellyfin/api.go index ac581f25..cb992598 100644 --- a/targets/jellyfin/api.go +++ b/targets/jellyfin/api.go @@ -6,8 +6,9 @@ import ( "fmt" "net/http" - "github.com/cloudbox/autoscan" "github.com/rs/zerolog" + + "github.com/cloudbox/autoscan" ) type apiClient struct { diff --git a/targets/jellyfin/jellyfin.go b/targets/jellyfin/jellyfin.go index f8f88d0c..f5d2135c 100644 --- a/targets/jellyfin/jellyfin.go +++ b/targets/jellyfin/jellyfin.go @@ -4,8 +4,9 @@ import ( "fmt" "strings" - "github.com/cloudbox/autoscan" "github.com/rs/zerolog" + + "github.com/cloudbox/autoscan" ) type Config struct { diff --git a/targets/plex/api.go b/targets/plex/api.go index 26b31b0b..cec392ed 100644 --- a/targets/plex/api.go +++ b/targets/plex/api.go @@ -7,8 +7,9 @@ import ( "net/url" "strconv" - "github.com/cloudbox/autoscan" "github.com/rs/zerolog" + + "github.com/cloudbox/autoscan" ) type apiClient struct { diff --git a/targets/plex/plex.go b/targets/plex/plex.go index 2b078f6b..ec526f9e 100644 --- a/targets/plex/plex.go +++ b/targets/plex/plex.go @@ -5,8 +5,9 @@ import ( "strconv" "strings" - "github.com/cloudbox/autoscan" "github.com/rs/zerolog" + + "github.com/cloudbox/autoscan" ) type Config struct { diff --git a/triggers/a_train/a_train.go b/triggers/a_train/a_train.go index 2ddc283c..cc94870a 100644 --- a/triggers/a_train/a_train.go +++ b/triggers/a_train/a_train.go @@ -5,9 +5,10 @@ import ( "net/http" "time" - "github.com/cloudbox/autoscan" "github.com/go-chi/chi/v5" "github.com/rs/zerolog/hlog" + + "github.com/cloudbox/autoscan" ) type Drive struct { diff --git a/triggers/a_train/a_train_test.go b/triggers/a_train/a_train_test.go index 0f2a3d5b..1a85bf34 100644 --- a/triggers/a_train/a_train_test.go +++ b/triggers/a_train/a_train_test.go @@ -10,8 +10,9 @@ import ( "testing" "time" - "github.com/cloudbox/autoscan" "github.com/go-chi/chi/v5" + + "github.com/cloudbox/autoscan" ) func TestHandler(t *testing.T) { diff --git a/triggers/inotify/inotify.go b/triggers/inotify/inotify.go index 5fb3cba9..bda505b4 100644 --- a/triggers/inotify/inotify.go +++ b/triggers/inotify/inotify.go @@ -8,9 +8,10 @@ import ( "sync" "time" - "github.com/cloudbox/autoscan" "github.com/fsnotify/fsnotify" "github.com/rs/zerolog" + + "github.com/cloudbox/autoscan" ) type Config struct { diff --git a/triggers/lidarr/lidarr.go b/triggers/lidarr/lidarr.go index f7c72b3d..b093ac58 100644 --- a/triggers/lidarr/lidarr.go +++ b/triggers/lidarr/lidarr.go @@ -7,8 +7,9 @@ import ( "strings" "time" - "github.com/cloudbox/autoscan" "github.com/rs/zerolog/hlog" + + "github.com/cloudbox/autoscan" ) type Config struct { diff --git a/triggers/manual/manual.go b/triggers/manual/manual.go index a3561017..eea260ab 100644 --- a/triggers/manual/manual.go +++ b/triggers/manual/manual.go @@ -6,8 +6,9 @@ import ( "path" "time" - "github.com/cloudbox/autoscan" "github.com/rs/zerolog/hlog" + + "github.com/cloudbox/autoscan" ) type Config struct { diff --git a/triggers/radarr/radarr.go b/triggers/radarr/radarr.go index 67e01f9a..5d1f9365 100644 --- a/triggers/radarr/radarr.go +++ b/triggers/radarr/radarr.go @@ -7,8 +7,9 @@ import ( "strings" "time" - "github.com/cloudbox/autoscan" "github.com/rs/zerolog/hlog" + + "github.com/cloudbox/autoscan" ) type Config struct { diff --git a/triggers/sonarr/sonarr.go b/triggers/sonarr/sonarr.go index 034fce4e..4fc9a769 100644 --- a/triggers/sonarr/sonarr.go +++ b/triggers/sonarr/sonarr.go @@ -7,8 +7,9 @@ import ( "strings" "time" - "github.com/cloudbox/autoscan" "github.com/rs/zerolog/hlog" + + "github.com/cloudbox/autoscan" ) type Config struct { From 2fc368d173dee58d2babf3b5309ec710f419b2e7 Mon Sep 17 00:00:00 2001 From: l3uddz Date: Wed, 13 Apr 2022 11:28:15 +0100 Subject: [PATCH 5/6] fix(migrations): ensure migrations are ran in version order --- migrate/migrator.go | 8 ++++---- migrate/util.go | 12 +++++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/migrate/migrator.go b/migrate/migrator.go index de91afc9..7ee9eaf6 100644 --- a/migrate/migrator.go +++ b/migrate/migrator.go @@ -64,15 +64,15 @@ func (m *Migrator) Migrate(fs *embed.FS, component string) error { } // migrate - for _, migration := range migrations { + for _, mg := range migrations { // already have this version? - if _, exists := versions[migration.Version]; exists { + if _, exists := versions[mg.Version]; exists { continue } // migrate - if err := m.exec(component, migration); err != nil { - return fmt.Errorf("migrate: %v: %w", migration.Filename, err) + if err := m.exec(component, mg); err != nil { + return fmt.Errorf("migrate: %v: %w", mg.Filename, err) } } diff --git a/migrate/util.go b/migrate/util.go index 2cec6711..b6ea0310 100644 --- a/migrate/util.go +++ b/migrate/util.go @@ -5,6 +5,7 @@ import ( "embed" "fmt" "path/filepath" + "sort" ) type migration struct { @@ -77,7 +78,7 @@ func (m *Migrator) exec(component string, migration *migration) (err error) { return nil } -func (m *Migrator) parse(fs *embed.FS) (map[int]*migration, error) { +func (m *Migrator) parse(fs *embed.FS) ([]*migration, error) { // parse migrations from filesystem files, err := fs.ReadDir(m.dir) if err != nil { @@ -85,7 +86,7 @@ func (m *Migrator) parse(fs *embed.FS) (map[int]*migration, error) { } // parse migrations - migrations := make(map[int]*migration) + migrations := make([]*migration, 0) for _, f := range files { // skip dirs if f.IsDir() { @@ -106,9 +107,14 @@ func (m *Migrator) parse(fs *embed.FS) (map[int]*migration, error) { md.Filename = f.Name() // set migration - migrations[md.Version] = md + migrations = append(migrations, md) } + // sort migrations + sort.Slice(migrations, func(i, j int) bool { + return migrations[i].Version < migrations[j].Version + }) + return migrations, nil } From ffc0e41c84a8d9a5267cb105b4e3f87a07efd5df Mon Sep 17 00:00:00 2001 From: l3uddz Date: Sun, 17 Apr 2022 20:28:11 +0100 Subject: [PATCH 6/6] build: goreleaser 1.7.0 --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f3b828c0..f661e45c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,7 @@ jobs: uses: goreleaser/goreleaser-action@v2 with: install-only: true + version: 1.7.0 - name: goreleaser info run: goreleaser -v