mirror of https://github.com/Superioz/aqua.git
Add github workflows and please linter
This commit is contained in:
parent
9ad5a55af5
commit
0a1121bca4
|
@ -0,0 +1,27 @@
|
|||
name: Docker
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: docker/setup-buildx-action@v1
|
||||
- name: get version
|
||||
run: |
|
||||
VER=$(cat VERSION)
|
||||
echo "VERSION=$VER" >> $GITHUB_ENV
|
||||
- name: login
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: true
|
||||
tags: ghcr.io/superioz/aqua:${{ env.VERSION }},ghcr.io/superioz/aqua:latest
|
||||
build-args: |
|
||||
version=${{ env.VERSION }}
|
|
@ -0,0 +1,12 @@
|
|||
name: golangci-lint
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
golangci:
|
||||
name: lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
version: v1.29
|
|
@ -0,0 +1,18 @@
|
|||
on: [push, pull_request]
|
||||
name: Test
|
||||
jobs:
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.17.x]
|
||||
os: [ubuntu-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Test
|
||||
run: go test ./...
|
|
@ -1,4 +1,4 @@
|
|||
FROM golang:1.17.2 AS builder
|
||||
FROM golang:1.17.2-alpine AS builder
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// TODO add github workflows for linting and building docker image
|
||||
// TODO how can we add binaries to github releases? we need it for the cli
|
||||
|
||||
func main() {
|
||||
|
@ -33,12 +32,15 @@ func main() {
|
|||
|
||||
// scheduler to do the cleanup every x minutes
|
||||
s := gocron.NewScheduler(time.UTC)
|
||||
s.Every(env.IntOrDefault("FILE_EXPIRATION_CYCLE", 15)).Minutes().StartImmediately().Do(func() {
|
||||
_, err = s.Every(env.IntOrDefault("FILE_EXPIRATION_CYCLE", 15)).Minutes().StartImmediately().Do(func() {
|
||||
err = uh.FileStorage.Cleanup()
|
||||
if err != nil {
|
||||
klog.Errorln(err)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
klog.Fatalf("could not start cleanup scheduler: %v", err)
|
||||
}
|
||||
s.StartAsync()
|
||||
|
||||
r.GET("/healthz", func(c *gin.Context) {
|
||||
|
|
|
@ -75,12 +75,12 @@ func (fs *FileStorage) Cleanup() error {
|
|||
// delete this file
|
||||
err = fs.fileSystem.DeleteFile(file.Id)
|
||||
if err != nil {
|
||||
return errors.New(fmt.Sprintf("Could not delete file with id=%s: %v", file.Id, err))
|
||||
return fmt.Errorf("could not delete file with id=%s: %v", file.Id, err)
|
||||
}
|
||||
|
||||
err = fs.fileMetaDb.DeleteFile(file.Id)
|
||||
if err != nil {
|
||||
return errors.New(fmt.Sprintf("Could not delete file with id=%s: %v", file.Id, err))
|
||||
return fmt.Errorf("could not delete file with id=%s: %v", file.Id, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
@ -111,7 +111,10 @@ func (fs *FileStorage) StoreFile(of multipart.File, expiration int64) (*StoredFi
|
|||
}
|
||||
|
||||
// write to meta database
|
||||
fs.fileMetaDb.WriteFile(sf)
|
||||
err = fs.fileMetaDb.WriteFile(sf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sf, nil
|
||||
}
|
||||
|
|
|
@ -97,7 +97,10 @@ func GetFileType(file *os.File) (string, error) {
|
|||
}
|
||||
|
||||
head := make([]byte, 261)
|
||||
f.Read(head)
|
||||
_, err = f.Read(head)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
kind, err := filetype.Match(head)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue