From 4e995f90a2f8bb9a449b7f59e39bc5dcd2cf68f6 Mon Sep 17 00:00:00 2001 From: Daniel Sonck Date: Tue, 9 Jul 2024 21:28:23 +0200 Subject: [PATCH 01/12] ci: remove duplicate pipelines and fix ui lint --- .github/workflows/build-api.yml | 15 --------------- .github/workflows/build-conversion.yml | 15 --------------- .github/workflows/build-mosaic.yml | 15 --------------- .github/workflows/build-ui.yml | 20 -------------------- .github/workflows/lint-ui.yml | 5 +++++ 5 files changed, 5 insertions(+), 65 deletions(-) diff --git a/.github/workflows/build-api.yml b/.github/workflows/build-api.yml index ce58a7022..3200aa71f 100644 --- a/.github/workflows/build-api.yml +++ b/.github/workflows/build-api.yml @@ -26,21 +26,6 @@ on: - "api/**" jobs: - linting: - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Lint using Golanci lint - uses: golangci/golangci-lint-action@v6 - with: - working-directory: api - permissions: - contents: read - pull-requests: read - checks: write - build_and_push: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/build-conversion.yml b/.github/workflows/build-conversion.yml index 96fac7cd8..ef913a691 100644 --- a/.github/workflows/build-conversion.yml +++ b/.github/workflows/build-conversion.yml @@ -26,21 +26,6 @@ on: - "conversion/**" jobs: - linting: - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Lint using Golanci lint - uses: golangci/golangci-lint-action@v6 - with: - working-directory: conversion - permissions: - contents: read - pull-requests: read - checks: write - build_and_push: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/build-mosaic.yml b/.github/workflows/build-mosaic.yml index bd97ea585..03eaf006f 100644 --- a/.github/workflows/build-mosaic.yml +++ b/.github/workflows/build-mosaic.yml @@ -26,21 +26,6 @@ on: - "mosaic/**" jobs: - linting: - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Lint using Golanci lint - uses: golangci/golangci-lint-action@v6 - with: - working-directory: mosaic - permissions: - contents: read - pull-requests: read - checks: write - build_and_push: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/build-ui.yml b/.github/workflows/build-ui.yml index 958637dcf..25e6efb67 100644 --- a/.github/workflows/build-ui.yml +++ b/.github/workflows/build-ui.yml @@ -26,26 +26,6 @@ on: - "ui/**" jobs: - linting: - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Add dummy embedded files - run: | - mkdir ui/dist - touch ui/dist/index.html - - - name: Lint using Golanci lint - uses: golangci/golangci-lint-action@v6 - with: - working-directory: ui - permissions: - contents: read - pull-requests: read - checks: write - build_and_push: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/lint-ui.yml b/.github/workflows/lint-ui.yml index b7ee6ebf7..d3acdf1d3 100644 --- a/.github/workflows/lint-ui.yml +++ b/.github/workflows/lint-ui.yml @@ -24,6 +24,11 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 + - name: Add dummy embedded files + run: | + mkdir ui/dist + touch ui/dist/index.html + - name: Lint using Golanci lint uses: golangci/golangci-lint-action@v6 with: From aaf3d64af2bf6bffc7a2f397ec6820325667685d Mon Sep 17 00:00:00 2001 From: Daniel Sonck Date: Tue, 9 Jul 2024 18:55:38 +0200 Subject: [PATCH 02/12] chore: api: organize imports with gci for --- api/.golangci.yml | 3 +-- api/errorpkg/error_creators.go | 4 ++-- api/errorpkg/error_handler.go | 4 ++-- api/infra/mail.go | 7 +++---- api/infra/postgres.go | 4 ++-- api/infra/redis.go | 4 ++-- api/infra/s3.go | 6 +++--- api/infra/search.go | 4 ++-- api/main.go | 5 ++--- api/repo/file_repo.go | 4 ++-- api/repo/group_repo.go | 4 ++-- api/repo/invitation_repo.go | 4 ++-- api/repo/organization_repo.go | 4 ++-- api/repo/permission_repo.go | 4 ++-- api/repo/snapshot_repo.go | 6 +++--- api/repo/task_repo.go | 6 +++--- api/repo/user_repo.go | 4 ++-- api/repo/workspace_repo.go | 4 ++-- api/router/file_router.go | 8 ++++---- api/router/group_router.go | 6 +++--- api/router/health_router.go | 4 ++-- api/router/insights_router.go | 8 ++++---- api/router/invitation_router.go | 6 +++--- api/router/mosaic_router.go | 6 +++--- api/router/organization_router.go | 6 +++--- api/router/snapshot_router.go | 6 +++--- api/router/storage_router.go | 4 ++-- api/router/task_router.go | 6 +++--- api/router/user_router.go | 4 ++-- api/router/watermark_router.go | 6 +++--- api/router/workspace_router.go | 6 +++--- api/search/file_search.go | 4 ++-- api/service/file_service.go | 6 +++--- api/service/insights_service.go | 4 ++-- api/service/watermark_service.go | 4 ++-- api/service/workspace_service.go | 4 ++-- 36 files changed, 88 insertions(+), 91 deletions(-) diff --git a/api/.golangci.yml b/api/.golangci.yml index 930b1eaa0..c945759fa 100644 --- a/api/.golangci.yml +++ b/api/.golangci.yml @@ -45,7 +45,6 @@ linters: - godot - gocritic - gocognit - - gci - funlen - forbidigo - errcheck @@ -78,7 +77,7 @@ linters-settings: - standard - default - prefix(github.com/kouprlabs) - - prefix(github.com/kouprlabs/voltaserve) + - prefix(github.com/kouprlabs/voltaserve/api) mnd: ignored-numbers: ['2', '4', '8', '16', '32', '64', '10', '100', '1000'] diff --git a/api/errorpkg/error_creators.go b/api/errorpkg/error_creators.go index c1dab9830..495ac92bc 100644 --- a/api/errorpkg/error_creators.go +++ b/api/errorpkg/error_creators.go @@ -15,9 +15,9 @@ import ( "net/http" "strings" - "github.com/kouprlabs/voltaserve/api/model" - "github.com/go-playground/validator/v10" + + "github.com/kouprlabs/voltaserve/api/model" ) func NewGroupNotFoundError(err error) *ErrorResponse { diff --git a/api/errorpkg/error_handler.go b/api/errorpkg/error_handler.go index a90b2685d..3b9d9fe85 100644 --- a/api/errorpkg/error_handler.go +++ b/api/errorpkg/error_handler.go @@ -14,9 +14,9 @@ import ( "errors" "net/http" - "github.com/kouprlabs/voltaserve/api/log" - "github.com/gofiber/fiber/v2" + + "github.com/kouprlabs/voltaserve/api/log" ) func ErrorHandler(c *fiber.Ctx, err error) error { diff --git a/api/infra/mail.go b/api/infra/mail.go index c0939ebae..4e8c37e0c 100644 --- a/api/infra/mail.go +++ b/api/infra/mail.go @@ -16,14 +16,13 @@ import ( "io" "os" "path/filepath" - - "github.com/kouprlabs/voltaserve/api/config" - "github.com/kouprlabs/voltaserve/api/log" + "text/template" "gopkg.in/gomail.v2" "sigs.k8s.io/yaml" - "text/template" + "github.com/kouprlabs/voltaserve/api/config" + "github.com/kouprlabs/voltaserve/api/log" ) type MessageParams struct { diff --git a/api/infra/postgres.go b/api/infra/postgres.go index b0dc7ed4a..6de0be380 100644 --- a/api/infra/postgres.go +++ b/api/infra/postgres.go @@ -11,10 +11,10 @@ package infra import ( - "github.com/kouprlabs/voltaserve/api/config" - "gorm.io/driver/postgres" "gorm.io/gorm" + + "github.com/kouprlabs/voltaserve/api/config" ) var db *gorm.DB diff --git a/api/infra/redis.go b/api/infra/redis.go index 606b8bf2c..2e37e15ee 100644 --- a/api/infra/redis.go +++ b/api/infra/redis.go @@ -14,9 +14,9 @@ import ( "context" "strings" - "github.com/kouprlabs/voltaserve/api/config" - "github.com/redis/go-redis/v9" + + "github.com/kouprlabs/voltaserve/api/config" ) type RedisManager struct { diff --git a/api/infra/s3.go b/api/infra/s3.go index 5c5e1dae1..64921b5a5 100644 --- a/api/infra/s3.go +++ b/api/infra/s3.go @@ -16,11 +16,11 @@ import ( "io" "strings" - "github.com/kouprlabs/voltaserve/api/config" - "github.com/kouprlabs/voltaserve/api/errorpkg" - "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" + + "github.com/kouprlabs/voltaserve/api/config" + "github.com/kouprlabs/voltaserve/api/errorpkg" ) type S3Manager struct { diff --git a/api/infra/search.go b/api/infra/search.go index 53189ae17..3b7136537 100644 --- a/api/infra/search.go +++ b/api/infra/search.go @@ -11,9 +11,9 @@ package infra import ( - "github.com/kouprlabs/voltaserve/api/config" - "github.com/meilisearch/meilisearch-go" + + "github.com/kouprlabs/voltaserve/api/config" ) var searchClient *meilisearch.Client diff --git a/api/main.go b/api/main.go index a564e74e4..7f5713686 100644 --- a/api/main.go +++ b/api/main.go @@ -15,16 +15,15 @@ import ( "os" "strings" + jwtware "github.com/gofiber/contrib/jwt" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cors" + "github.com/joho/godotenv" "github.com/kouprlabs/voltaserve/api/config" "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/helper" "github.com/kouprlabs/voltaserve/api/router" - - jwtware "github.com/gofiber/contrib/jwt" - "github.com/joho/godotenv" ) // @title Voltaserve API diff --git a/api/repo/file_repo.go b/api/repo/file_repo.go index 2bc2cd4e4..3a737851e 100644 --- a/api/repo/file_repo.go +++ b/api/repo/file_repo.go @@ -14,12 +14,12 @@ import ( "errors" "time" + "gorm.io/gorm" + "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/helper" "github.com/kouprlabs/voltaserve/api/infra" "github.com/kouprlabs/voltaserve/api/model" - - "gorm.io/gorm" ) type FileRepo interface { diff --git a/api/repo/group_repo.go b/api/repo/group_repo.go index cf1683968..105b28610 100644 --- a/api/repo/group_repo.go +++ b/api/repo/group_repo.go @@ -14,12 +14,12 @@ import ( "errors" "time" + "gorm.io/gorm" + "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/helper" "github.com/kouprlabs/voltaserve/api/infra" "github.com/kouprlabs/voltaserve/api/model" - - "gorm.io/gorm" ) type GroupRepo interface { diff --git a/api/repo/invitation_repo.go b/api/repo/invitation_repo.go index 18b50ee60..f4dd44a90 100644 --- a/api/repo/invitation_repo.go +++ b/api/repo/invitation_repo.go @@ -14,12 +14,12 @@ import ( "errors" "time" + "gorm.io/gorm" + "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/helper" "github.com/kouprlabs/voltaserve/api/infra" "github.com/kouprlabs/voltaserve/api/model" - - "gorm.io/gorm" ) type InvitationRepo interface { diff --git a/api/repo/organization_repo.go b/api/repo/organization_repo.go index b3d80fd78..398b0ab8b 100644 --- a/api/repo/organization_repo.go +++ b/api/repo/organization_repo.go @@ -14,12 +14,12 @@ import ( "errors" "time" + "gorm.io/gorm" + "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/helper" "github.com/kouprlabs/voltaserve/api/infra" "github.com/kouprlabs/voltaserve/api/model" - - "gorm.io/gorm" ) type OrganizationRepo interface { diff --git a/api/repo/permission_repo.go b/api/repo/permission_repo.go index 1c46cc8f2..5b24d61fb 100644 --- a/api/repo/permission_repo.go +++ b/api/repo/permission_repo.go @@ -13,10 +13,10 @@ package repo import ( "time" + "gorm.io/gorm" + "github.com/kouprlabs/voltaserve/api/infra" "github.com/kouprlabs/voltaserve/api/model" - - "gorm.io/gorm" ) type PermissionRepo interface { diff --git a/api/repo/snapshot_repo.go b/api/repo/snapshot_repo.go index a73c30d62..598dcb84d 100644 --- a/api/repo/snapshot_repo.go +++ b/api/repo/snapshot_repo.go @@ -15,14 +15,14 @@ import ( "errors" "time" + "gorm.io/datatypes" + "gorm.io/gorm" + "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/helper" "github.com/kouprlabs/voltaserve/api/infra" "github.com/kouprlabs/voltaserve/api/log" "github.com/kouprlabs/voltaserve/api/model" - - "gorm.io/datatypes" - "gorm.io/gorm" ) type SnapshotRepo interface { diff --git a/api/repo/task_repo.go b/api/repo/task_repo.go index 5dd736712..fb95e85dc 100644 --- a/api/repo/task_repo.go +++ b/api/repo/task_repo.go @@ -15,13 +15,13 @@ import ( "errors" "time" + "gorm.io/datatypes" + "gorm.io/gorm" + "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/infra" "github.com/kouprlabs/voltaserve/api/log" "github.com/kouprlabs/voltaserve/api/model" - - "gorm.io/datatypes" - "gorm.io/gorm" ) type taskEntity struct { diff --git a/api/repo/user_repo.go b/api/repo/user_repo.go index 041b4ac17..59517cef3 100644 --- a/api/repo/user_repo.go +++ b/api/repo/user_repo.go @@ -13,11 +13,11 @@ package repo import ( "errors" + "gorm.io/gorm" + "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/infra" "github.com/kouprlabs/voltaserve/api/model" - - "gorm.io/gorm" ) type UserRepo interface { diff --git a/api/repo/workspace_repo.go b/api/repo/workspace_repo.go index 48af06a79..02657292f 100644 --- a/api/repo/workspace_repo.go +++ b/api/repo/workspace_repo.go @@ -14,12 +14,12 @@ import ( "errors" "time" + "gorm.io/gorm" + "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/helper" "github.com/kouprlabs/voltaserve/api/infra" "github.com/kouprlabs/voltaserve/api/model" - - "gorm.io/gorm" ) type WorkspaceRepo interface { diff --git a/api/router/file_router.go b/api/router/file_router.go index e614f86fc..45603b691 100644 --- a/api/router/file_router.go +++ b/api/router/file_router.go @@ -24,6 +24,10 @@ import ( "strings" "sync" + "github.com/go-playground/validator/v10" + "github.com/gofiber/fiber/v2" + "github.com/golang-jwt/jwt/v5" + "github.com/kouprlabs/voltaserve/api/config" "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/helper" @@ -31,10 +35,6 @@ import ( "github.com/kouprlabs/voltaserve/api/log" "github.com/kouprlabs/voltaserve/api/model" "github.com/kouprlabs/voltaserve/api/service" - - "github.com/go-playground/validator/v10" - "github.com/gofiber/fiber/v2" - "github.com/golang-jwt/jwt/v5" ) type FileRouter struct { diff --git a/api/router/group_router.go b/api/router/group_router.go index 1c228c92d..0ea67be90 100644 --- a/api/router/group_router.go +++ b/api/router/group_router.go @@ -15,11 +15,11 @@ import ( "net/url" "strconv" - "github.com/kouprlabs/voltaserve/api/errorpkg" - "github.com/kouprlabs/voltaserve/api/service" - "github.com/go-playground/validator/v10" "github.com/gofiber/fiber/v2" + + "github.com/kouprlabs/voltaserve/api/errorpkg" + "github.com/kouprlabs/voltaserve/api/service" ) type GroupRouter struct { diff --git a/api/router/health_router.go b/api/router/health_router.go index aeb3cbdee..6b46b1f41 100644 --- a/api/router/health_router.go +++ b/api/router/health_router.go @@ -13,9 +13,9 @@ package router import ( "net/http" - "github.com/kouprlabs/voltaserve/api/infra" - "github.com/gofiber/fiber/v2" + + "github.com/kouprlabs/voltaserve/api/infra" ) type HealthRouter struct { diff --git a/api/router/insights_router.go b/api/router/insights_router.go index 130f5d8ed..8c16ba9be 100644 --- a/api/router/insights_router.go +++ b/api/router/insights_router.go @@ -18,14 +18,14 @@ import ( "path/filepath" "strconv" + "github.com/go-playground/validator/v10" + "github.com/gofiber/fiber/v2" + "github.com/golang-jwt/jwt/v5" + "github.com/kouprlabs/voltaserve/api/config" "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/infra" "github.com/kouprlabs/voltaserve/api/service" - - "github.com/go-playground/validator/v10" - "github.com/gofiber/fiber/v2" - "github.com/golang-jwt/jwt/v5" ) type InsightsRouter struct { diff --git a/api/router/invitation_router.go b/api/router/invitation_router.go index 0bc9023ac..c300f50f8 100644 --- a/api/router/invitation_router.go +++ b/api/router/invitation_router.go @@ -14,11 +14,11 @@ import ( "net/http" "strconv" - "github.com/kouprlabs/voltaserve/api/errorpkg" - "github.com/kouprlabs/voltaserve/api/service" - "github.com/go-playground/validator/v10" "github.com/gofiber/fiber/v2" + + "github.com/kouprlabs/voltaserve/api/errorpkg" + "github.com/kouprlabs/voltaserve/api/service" ) type InvitationRouter struct { diff --git a/api/router/mosaic_router.go b/api/router/mosaic_router.go index 98ccd0519..5bd0ea606 100644 --- a/api/router/mosaic_router.go +++ b/api/router/mosaic_router.go @@ -16,13 +16,13 @@ import ( "net/http" "strconv" + "github.com/gofiber/fiber/v2" + "github.com/golang-jwt/jwt/v5" + "github.com/kouprlabs/voltaserve/api/config" "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/infra" "github.com/kouprlabs/voltaserve/api/service" - - "github.com/gofiber/fiber/v2" - "github.com/golang-jwt/jwt/v5" ) type MosaicRouter struct { diff --git a/api/router/organization_router.go b/api/router/organization_router.go index 364429fe1..6f3ad3bf3 100644 --- a/api/router/organization_router.go +++ b/api/router/organization_router.go @@ -15,11 +15,11 @@ import ( "net/url" "strconv" - "github.com/kouprlabs/voltaserve/api/errorpkg" - "github.com/kouprlabs/voltaserve/api/service" - "github.com/go-playground/validator/v10" "github.com/gofiber/fiber/v2" + + "github.com/kouprlabs/voltaserve/api/errorpkg" + "github.com/kouprlabs/voltaserve/api/service" ) type OrganizationRouter struct { diff --git a/api/router/snapshot_router.go b/api/router/snapshot_router.go index f23c0b167..21a1e42c1 100644 --- a/api/router/snapshot_router.go +++ b/api/router/snapshot_router.go @@ -14,12 +14,12 @@ import ( "net/http" "strconv" + "github.com/go-playground/validator/v10" + "github.com/gofiber/fiber/v2" + "github.com/kouprlabs/voltaserve/api/config" "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/service" - - "github.com/go-playground/validator/v10" - "github.com/gofiber/fiber/v2" ) type SnapshotRouter struct { diff --git a/api/router/storage_router.go b/api/router/storage_router.go index 682c9e1f7..7082f0685 100644 --- a/api/router/storage_router.go +++ b/api/router/storage_router.go @@ -11,10 +11,10 @@ package router import ( + "github.com/gofiber/fiber/v2" + "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/service" - - "github.com/gofiber/fiber/v2" ) type StorageRouter struct { diff --git a/api/router/task_router.go b/api/router/task_router.go index 0738095b0..146994901 100644 --- a/api/router/task_router.go +++ b/api/router/task_router.go @@ -15,12 +15,12 @@ import ( "net/url" "strconv" + "github.com/go-playground/validator/v10" + "github.com/gofiber/fiber/v2" + "github.com/kouprlabs/voltaserve/api/config" "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/service" - - "github.com/go-playground/validator/v10" - "github.com/gofiber/fiber/v2" ) type TaskRouter struct { diff --git a/api/router/user_router.go b/api/router/user_router.go index 3638863da..4bb9737b3 100644 --- a/api/router/user_router.go +++ b/api/router/user_router.go @@ -14,10 +14,10 @@ import ( "net/url" "strconv" + "github.com/gofiber/fiber/v2" + "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/service" - - "github.com/gofiber/fiber/v2" ) type UserRouter struct { diff --git a/api/router/watermark_router.go b/api/router/watermark_router.go index 079c8f05c..3eb80cd79 100644 --- a/api/router/watermark_router.go +++ b/api/router/watermark_router.go @@ -16,13 +16,13 @@ import ( "net/http" "path/filepath" + "github.com/gofiber/fiber/v2" + "github.com/golang-jwt/jwt/v5" + "github.com/kouprlabs/voltaserve/api/config" "github.com/kouprlabs/voltaserve/api/errorpkg" "github.com/kouprlabs/voltaserve/api/infra" "github.com/kouprlabs/voltaserve/api/service" - - "github.com/gofiber/fiber/v2" - "github.com/golang-jwt/jwt/v5" ) type WatermarkRouter struct { diff --git a/api/router/workspace_router.go b/api/router/workspace_router.go index d7e94268e..ba6146dc9 100644 --- a/api/router/workspace_router.go +++ b/api/router/workspace_router.go @@ -15,11 +15,11 @@ import ( "net/url" "strconv" - "github.com/kouprlabs/voltaserve/api/errorpkg" - "github.com/kouprlabs/voltaserve/api/service" - "github.com/go-playground/validator/v10" "github.com/gofiber/fiber/v2" + + "github.com/kouprlabs/voltaserve/api/errorpkg" + "github.com/kouprlabs/voltaserve/api/service" ) type WorkspaceRouter struct { diff --git a/api/search/file_search.go b/api/search/file_search.go index c74ccbeef..1617fdd94 100644 --- a/api/search/file_search.go +++ b/api/search/file_search.go @@ -13,11 +13,11 @@ package search import ( "encoding/json" + "github.com/minio/minio-go/v7" + "github.com/kouprlabs/voltaserve/api/infra" "github.com/kouprlabs/voltaserve/api/model" "github.com/kouprlabs/voltaserve/api/repo" - - "github.com/minio/minio-go/v7" ) type FileSearch struct { diff --git a/api/service/file_service.go b/api/service/file_service.go index 8c5ca53ce..c996bb2f0 100644 --- a/api/service/file_service.go +++ b/api/service/file_service.go @@ -19,6 +19,9 @@ import ( "strings" "time" + "github.com/minio/minio-go/v7" + "github.com/reactivex/rxgo/v2" + "github.com/kouprlabs/voltaserve/api/cache" "github.com/kouprlabs/voltaserve/api/client" "github.com/kouprlabs/voltaserve/api/config" @@ -29,9 +32,6 @@ import ( "github.com/kouprlabs/voltaserve/api/model" "github.com/kouprlabs/voltaserve/api/repo" "github.com/kouprlabs/voltaserve/api/search" - - "github.com/minio/minio-go/v7" - "github.com/reactivex/rxgo/v2" ) type FileService struct { diff --git a/api/service/insights_service.go b/api/service/insights_service.go index d997def8c..e7c118b1e 100644 --- a/api/service/insights_service.go +++ b/api/service/insights_service.go @@ -17,6 +17,8 @@ import ( "sort" "strings" + "github.com/minio/minio-go/v7" + "github.com/kouprlabs/voltaserve/api/cache" "github.com/kouprlabs/voltaserve/api/client" "github.com/kouprlabs/voltaserve/api/errorpkg" @@ -26,8 +28,6 @@ import ( "github.com/kouprlabs/voltaserve/api/log" "github.com/kouprlabs/voltaserve/api/model" "github.com/kouprlabs/voltaserve/api/repo" - - "github.com/minio/minio-go/v7" ) type InsightsService struct { diff --git a/api/service/watermark_service.go b/api/service/watermark_service.go index 43edb6af9..b7e3df024 100644 --- a/api/service/watermark_service.go +++ b/api/service/watermark_service.go @@ -13,6 +13,8 @@ package service import ( "bytes" + "github.com/minio/minio-go/v7" + "github.com/kouprlabs/voltaserve/api/cache" "github.com/kouprlabs/voltaserve/api/client" "github.com/kouprlabs/voltaserve/api/errorpkg" @@ -22,8 +24,6 @@ import ( "github.com/kouprlabs/voltaserve/api/log" "github.com/kouprlabs/voltaserve/api/model" "github.com/kouprlabs/voltaserve/api/repo" - - "github.com/minio/minio-go/v7" ) type WatermarkService struct { diff --git a/api/service/workspace_service.go b/api/service/workspace_service.go index e3260fcbc..76886583d 100644 --- a/api/service/workspace_service.go +++ b/api/service/workspace_service.go @@ -15,6 +15,8 @@ import ( "strings" "time" + "github.com/google/uuid" + "github.com/kouprlabs/voltaserve/api/cache" "github.com/kouprlabs/voltaserve/api/config" "github.com/kouprlabs/voltaserve/api/errorpkg" @@ -24,8 +26,6 @@ import ( "github.com/kouprlabs/voltaserve/api/model" "github.com/kouprlabs/voltaserve/api/repo" "github.com/kouprlabs/voltaserve/api/search" - - "github.com/google/uuid" ) type WorkspaceService struct { From 356da13a919f7655c734780f697ffda4c97c219a Mon Sep 17 00:00:00 2001 From: Daniel Sonck Date: Tue, 9 Jul 2024 18:58:10 +0200 Subject: [PATCH 03/12] chore: ui: organize imports with gci --- ui/.golangci.yml | 3 +-- ui/main.go | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ui/.golangci.yml b/ui/.golangci.yml index 402d4e225..56c04886d 100644 --- a/ui/.golangci.yml +++ b/ui/.golangci.yml @@ -17,7 +17,6 @@ linters: - errorlint - revive - nestif - - gci - funlen - gocognit - cyclop @@ -47,7 +46,7 @@ linters-settings: - standard - default - prefix(github.com/kouprlabs) - - prefix(github.com/kouprlabs/voltaserve) + - prefix(github.com/kouprlabs/voltaserve/ui) mnd: ignored-numbers: ['2', '4', '8', '16', '32', '64', '10', '100', '1000'] diff --git a/ui/main.go b/ui/main.go index 0781aadc8..3deb2b673 100644 --- a/ui/main.go +++ b/ui/main.go @@ -18,11 +18,11 @@ import ( "net/url" "os" - "github.com/kouprlabs/voltaserve/ui/config" - "github.com/joho/godotenv" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" + + "github.com/kouprlabs/voltaserve/ui/config" ) var ( From 69d365aa8123cbbd9afd23d403aedbf29f2a16e1 Mon Sep 17 00:00:00 2001 From: Daniel Sonck Date: Tue, 9 Jul 2024 18:58:43 +0200 Subject: [PATCH 04/12] chore: conversion: organize imports with gci --- conversion/.golangci.yml | 3 +-- conversion/infra/s3.go | 4 ++-- conversion/main.go | 6 +++--- conversion/pipeline/audio_video_pipeline.go | 4 ++-- conversion/pipeline/glb_pipeline.go | 4 ++-- conversion/pipeline/image_pipeline.go | 4 ++-- conversion/pipeline/insights_pipeline.go | 4 ++-- conversion/pipeline/mosaic_pipeline.go | 4 ++-- conversion/pipeline/office_pipeline.go | 4 ++-- conversion/pipeline/pdf_pipeline.go | 4 ++-- conversion/pipeline/watermark_pipeline.go | 4 ++-- conversion/pipeline/zip_pipeline.go | 4 ++-- conversion/router/health_router.go | 4 ++-- conversion/router/pipeline_router.go | 6 +++--- conversion/runtime/scheduler.go | 3 +-- 15 files changed, 30 insertions(+), 32 deletions(-) diff --git a/conversion/.golangci.yml b/conversion/.golangci.yml index 765adaf21..7392ae980 100644 --- a/conversion/.golangci.yml +++ b/conversion/.golangci.yml @@ -40,7 +40,6 @@ linters: - godot - gocritic - gocognit - - gci - funlen - errcheck - dupl @@ -71,7 +70,7 @@ linters-settings: - standard - default - prefix(github.com/kouprlabs) - - prefix(github.com/kouprlabs/voltaserve) + - prefix(github.com/kouprlabs/voltaserve/conversion) mnd: ignored-numbers: ['2', '4', '8', '16', '32', '64', '10', '100', '1000'] diff --git a/conversion/infra/s3.go b/conversion/infra/s3.go index ad1745ead..69028fdab 100644 --- a/conversion/infra/s3.go +++ b/conversion/infra/s3.go @@ -17,10 +17,10 @@ import ( "io" "strings" - "github.com/kouprlabs/voltaserve/conversion/config" - "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" + + "github.com/kouprlabs/voltaserve/conversion/config" ) type S3Manager struct { diff --git a/conversion/main.go b/conversion/main.go index aa81e60b2..f47ec390b 100644 --- a/conversion/main.go +++ b/conversion/main.go @@ -15,14 +15,14 @@ import ( "fmt" "os" + "github.com/gofiber/fiber/v2" + "github.com/joho/godotenv" + "github.com/kouprlabs/voltaserve/conversion/config" "github.com/kouprlabs/voltaserve/conversion/errorpkg" "github.com/kouprlabs/voltaserve/conversion/helper" "github.com/kouprlabs/voltaserve/conversion/router" "github.com/kouprlabs/voltaserve/conversion/runtime" - - "github.com/gofiber/fiber/v2" - "github.com/joho/godotenv" ) // @title Voltaserve Conversion diff --git a/conversion/pipeline/audio_video_pipeline.go b/conversion/pipeline/audio_video_pipeline.go index b2dadeaa0..774c6f474 100644 --- a/conversion/pipeline/audio_video_pipeline.go +++ b/conversion/pipeline/audio_video_pipeline.go @@ -14,14 +14,14 @@ import ( "os" "path/filepath" + "github.com/minio/minio-go/v7" + "github.com/kouprlabs/voltaserve/conversion/client" "github.com/kouprlabs/voltaserve/conversion/config" "github.com/kouprlabs/voltaserve/conversion/helper" "github.com/kouprlabs/voltaserve/conversion/infra" "github.com/kouprlabs/voltaserve/conversion/model" "github.com/kouprlabs/voltaserve/conversion/processor" - - "github.com/minio/minio-go/v7" ) type audioVideoPipeline struct { diff --git a/conversion/pipeline/glb_pipeline.go b/conversion/pipeline/glb_pipeline.go index 0a4f7798e..bf32dc61b 100644 --- a/conversion/pipeline/glb_pipeline.go +++ b/conversion/pipeline/glb_pipeline.go @@ -14,14 +14,14 @@ import ( "os" "path/filepath" + "github.com/minio/minio-go/v7" + "github.com/kouprlabs/voltaserve/conversion/client" "github.com/kouprlabs/voltaserve/conversion/config" "github.com/kouprlabs/voltaserve/conversion/helper" "github.com/kouprlabs/voltaserve/conversion/infra" "github.com/kouprlabs/voltaserve/conversion/model" "github.com/kouprlabs/voltaserve/conversion/processor" - - "github.com/minio/minio-go/v7" ) type glbPipeline struct { diff --git a/conversion/pipeline/image_pipeline.go b/conversion/pipeline/image_pipeline.go index 57126ea15..6859c7d4b 100644 --- a/conversion/pipeline/image_pipeline.go +++ b/conversion/pipeline/image_pipeline.go @@ -14,6 +14,8 @@ import ( "os" "path/filepath" + "github.com/minio/minio-go/v7" + "github.com/kouprlabs/voltaserve/conversion/client" "github.com/kouprlabs/voltaserve/conversion/config" "github.com/kouprlabs/voltaserve/conversion/helper" @@ -21,8 +23,6 @@ import ( "github.com/kouprlabs/voltaserve/conversion/infra" "github.com/kouprlabs/voltaserve/conversion/model" "github.com/kouprlabs/voltaserve/conversion/processor" - - "github.com/minio/minio-go/v7" ) type imagePipeline struct { diff --git a/conversion/pipeline/insights_pipeline.go b/conversion/pipeline/insights_pipeline.go index 0cf1fd4b4..3385c3eee 100644 --- a/conversion/pipeline/insights_pipeline.go +++ b/conversion/pipeline/insights_pipeline.go @@ -16,14 +16,14 @@ import ( "os" "path/filepath" + "github.com/minio/minio-go/v7" + "github.com/kouprlabs/voltaserve/conversion/client" "github.com/kouprlabs/voltaserve/conversion/helper" "github.com/kouprlabs/voltaserve/conversion/identifier" "github.com/kouprlabs/voltaserve/conversion/infra" "github.com/kouprlabs/voltaserve/conversion/model" "github.com/kouprlabs/voltaserve/conversion/processor" - - "github.com/minio/minio-go/v7" ) type insightsPipeline struct { diff --git a/conversion/pipeline/mosaic_pipeline.go b/conversion/pipeline/mosaic_pipeline.go index c0d11a625..a82ad28ac 100644 --- a/conversion/pipeline/mosaic_pipeline.go +++ b/conversion/pipeline/mosaic_pipeline.go @@ -15,14 +15,14 @@ import ( "os" "path/filepath" + "github.com/minio/minio-go/v7" + "github.com/kouprlabs/voltaserve/conversion/client" "github.com/kouprlabs/voltaserve/conversion/helper" "github.com/kouprlabs/voltaserve/conversion/identifier" "github.com/kouprlabs/voltaserve/conversion/infra" "github.com/kouprlabs/voltaserve/conversion/model" "github.com/kouprlabs/voltaserve/conversion/processor" - - "github.com/minio/minio-go/v7" ) type mosaicPipeline struct { diff --git a/conversion/pipeline/office_pipeline.go b/conversion/pipeline/office_pipeline.go index 134d6d70a..a28117294 100644 --- a/conversion/pipeline/office_pipeline.go +++ b/conversion/pipeline/office_pipeline.go @@ -14,14 +14,14 @@ import ( "os" "path/filepath" + "github.com/minio/minio-go/v7" + "github.com/kouprlabs/voltaserve/conversion/client" "github.com/kouprlabs/voltaserve/conversion/config" "github.com/kouprlabs/voltaserve/conversion/helper" "github.com/kouprlabs/voltaserve/conversion/infra" "github.com/kouprlabs/voltaserve/conversion/model" "github.com/kouprlabs/voltaserve/conversion/processor" - - "github.com/minio/minio-go/v7" ) type officePipeline struct { diff --git a/conversion/pipeline/pdf_pipeline.go b/conversion/pipeline/pdf_pipeline.go index 9114eb1b5..444d4315f 100644 --- a/conversion/pipeline/pdf_pipeline.go +++ b/conversion/pipeline/pdf_pipeline.go @@ -14,6 +14,8 @@ import ( "os" "path/filepath" + "github.com/minio/minio-go/v7" + "github.com/kouprlabs/voltaserve/conversion/client" "github.com/kouprlabs/voltaserve/conversion/config" "github.com/kouprlabs/voltaserve/conversion/helper" @@ -21,8 +23,6 @@ import ( "github.com/kouprlabs/voltaserve/conversion/infra" "github.com/kouprlabs/voltaserve/conversion/model" "github.com/kouprlabs/voltaserve/conversion/processor" - - "github.com/minio/minio-go/v7" ) type pdfPipeline struct { diff --git a/conversion/pipeline/watermark_pipeline.go b/conversion/pipeline/watermark_pipeline.go index 6df18e70e..ad00fcede 100644 --- a/conversion/pipeline/watermark_pipeline.go +++ b/conversion/pipeline/watermark_pipeline.go @@ -15,14 +15,14 @@ import ( "os" "path/filepath" + "github.com/minio/minio-go/v7" + "github.com/kouprlabs/voltaserve/conversion/client" "github.com/kouprlabs/voltaserve/conversion/helper" "github.com/kouprlabs/voltaserve/conversion/identifier" "github.com/kouprlabs/voltaserve/conversion/infra" "github.com/kouprlabs/voltaserve/conversion/model" "github.com/kouprlabs/voltaserve/conversion/processor" - - "github.com/minio/minio-go/v7" ) type watermarkPipeline struct { diff --git a/conversion/pipeline/zip_pipeline.go b/conversion/pipeline/zip_pipeline.go index fd3d6bed1..aa87a7b8a 100644 --- a/conversion/pipeline/zip_pipeline.go +++ b/conversion/pipeline/zip_pipeline.go @@ -14,14 +14,14 @@ import ( "os" "path/filepath" + "github.com/minio/minio-go/v7" + "github.com/kouprlabs/voltaserve/conversion/client" "github.com/kouprlabs/voltaserve/conversion/helper" "github.com/kouprlabs/voltaserve/conversion/identifier" "github.com/kouprlabs/voltaserve/conversion/infra" "github.com/kouprlabs/voltaserve/conversion/model" "github.com/kouprlabs/voltaserve/conversion/processor" - - "github.com/minio/minio-go/v7" ) type zipPipeline struct { diff --git a/conversion/router/health_router.go b/conversion/router/health_router.go index ab9a02012..c4aaf7c4e 100644 --- a/conversion/router/health_router.go +++ b/conversion/router/health_router.go @@ -13,10 +13,10 @@ package router import ( "net/http" + "github.com/gofiber/fiber/v2" + "github.com/kouprlabs/voltaserve/conversion/client" "github.com/kouprlabs/voltaserve/conversion/infra" - - "github.com/gofiber/fiber/v2" ) type HealthRouter struct { diff --git a/conversion/router/pipeline_router.go b/conversion/router/pipeline_router.go index d43bdbb11..bad0f7e7a 100644 --- a/conversion/router/pipeline_router.go +++ b/conversion/router/pipeline_router.go @@ -11,13 +11,13 @@ package router import ( + "github.com/go-playground/validator/v10" + "github.com/gofiber/fiber/v2" + "github.com/kouprlabs/voltaserve/conversion/client" "github.com/kouprlabs/voltaserve/conversion/config" "github.com/kouprlabs/voltaserve/conversion/errorpkg" "github.com/kouprlabs/voltaserve/conversion/runtime" - - "github.com/go-playground/validator/v10" - "github.com/gofiber/fiber/v2" ) type PipelineRouter struct { diff --git a/conversion/runtime/scheduler.go b/conversion/runtime/scheduler.go index 36fd9f5e2..f08d4df72 100644 --- a/conversion/runtime/scheduler.go +++ b/conversion/runtime/scheduler.go @@ -14,10 +14,9 @@ import ( "runtime" "time" - "github.com/kouprlabs/voltaserve/conversion/pipeline" - "github.com/kouprlabs/voltaserve/conversion/client" "github.com/kouprlabs/voltaserve/conversion/infra" + "github.com/kouprlabs/voltaserve/conversion/pipeline" ) type Scheduler struct { From dc8ee2a4c5a2b013394140a3a1f3ac73d6390d54 Mon Sep 17 00:00:00 2001 From: Daniel Sonck Date: Tue, 9 Jul 2024 18:59:33 +0200 Subject: [PATCH 05/12] chore: mosaic: organize imports with gci --- mosaic/.golangci.yml | 1 - mosaic/infra/s3.go | 4 ++-- mosaic/main.go | 6 +++--- mosaic/router/health_router.go | 4 ++-- mosaic/router/mosaic_router.go | 4 ++-- mosaic/service/mosaic_service.go | 4 ++-- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/mosaic/.golangci.yml b/mosaic/.golangci.yml index 002933f30..29afc388e 100644 --- a/mosaic/.golangci.yml +++ b/mosaic/.golangci.yml @@ -32,7 +32,6 @@ linters: - gofumpt - godot - gocritic - - gci - funlen - gocognit diff --git a/mosaic/infra/s3.go b/mosaic/infra/s3.go index b66003849..c6a4b02b6 100644 --- a/mosaic/infra/s3.go +++ b/mosaic/infra/s3.go @@ -17,10 +17,10 @@ import ( "io" "strings" - "github.com/kouprlabs/voltaserve/mosaic/config" - "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" + + "github.com/kouprlabs/voltaserve/mosaic/config" ) type S3Manager struct { diff --git a/mosaic/main.go b/mosaic/main.go index f92b1a8ac..cf29d25d9 100644 --- a/mosaic/main.go +++ b/mosaic/main.go @@ -14,13 +14,13 @@ import ( "fmt" "os" + "github.com/gofiber/fiber/v2" + "github.com/joho/godotenv" + "github.com/kouprlabs/voltaserve/mosaic/config" "github.com/kouprlabs/voltaserve/mosaic/errorpkg" "github.com/kouprlabs/voltaserve/mosaic/helper" "github.com/kouprlabs/voltaserve/mosaic/router" - - "github.com/gofiber/fiber/v2" - "github.com/joho/godotenv" ) // @title Voltaserve Mosaic diff --git a/mosaic/router/health_router.go b/mosaic/router/health_router.go index 910677610..94d21902f 100644 --- a/mosaic/router/health_router.go +++ b/mosaic/router/health_router.go @@ -13,9 +13,9 @@ package router import ( "net/http" - "github.com/kouprlabs/voltaserve/mosaic/infra" - "github.com/gofiber/fiber/v2" + + "github.com/kouprlabs/voltaserve/mosaic/infra" ) type HealthRouter struct { diff --git a/mosaic/router/mosaic_router.go b/mosaic/router/mosaic_router.go index 0e4fa5294..d1b4104a9 100644 --- a/mosaic/router/mosaic_router.go +++ b/mosaic/router/mosaic_router.go @@ -15,12 +15,12 @@ import ( "path/filepath" "strconv" + "github.com/gofiber/fiber/v2" + "github.com/kouprlabs/voltaserve/mosaic/config" "github.com/kouprlabs/voltaserve/mosaic/helper" "github.com/kouprlabs/voltaserve/mosaic/infra" "github.com/kouprlabs/voltaserve/mosaic/service" - - "github.com/gofiber/fiber/v2" ) type MosaicRouter struct { diff --git a/mosaic/service/mosaic_service.go b/mosaic/service/mosaic_service.go index 94c6740d0..b7e3b0997 100644 --- a/mosaic/service/mosaic_service.go +++ b/mosaic/service/mosaic_service.go @@ -18,13 +18,13 @@ import ( "os" "path/filepath" + "github.com/minio/minio-go/v7" + "github.com/kouprlabs/voltaserve/mosaic/builder" "github.com/kouprlabs/voltaserve/mosaic/config" "github.com/kouprlabs/voltaserve/mosaic/errorpkg" "github.com/kouprlabs/voltaserve/mosaic/helper" "github.com/kouprlabs/voltaserve/mosaic/infra" - - "github.com/minio/minio-go/v7" ) type MosaicService struct { From b78fb8594e38088485f84aadc08c5ecd0213d1b5 Mon Sep 17 00:00:00 2001 From: Daniel Sonck Date: Tue, 9 Jul 2024 21:34:06 +0200 Subject: [PATCH 06/12] chore: api: enable and apply gofumpt --- api/.golangci.yml | 1 - api/infra/postgres.go | 3 +-- api/repo/file_repo.go | 2 +- api/repo/group_repo.go | 2 +- api/repo/invitation_repo.go | 2 +- api/repo/organization_repo.go | 2 +- api/repo/snapshot_repo.go | 18 +++++++++--------- api/repo/task_repo.go | 2 +- api/repo/user_repo.go | 4 ++-- api/repo/workspace_repo.go | 2 +- api/router/health_router.go | 3 +-- api/service/constants.go | 26 +++++++++++++++----------- api/service/file_service.go | 4 ++-- api/service/storage_service.go | 3 +-- api/service/user_service.go | 3 +-- 15 files changed, 38 insertions(+), 39 deletions(-) diff --git a/api/.golangci.yml b/api/.golangci.yml index c945759fa..c56b3b424 100644 --- a/api/.golangci.yml +++ b/api/.golangci.yml @@ -41,7 +41,6 @@ linters: - nestif - lll - gosec - - gofumpt - godot - gocritic - gocognit diff --git a/api/infra/postgres.go b/api/infra/postgres.go index 6de0be380..d41798c54 100644 --- a/api/infra/postgres.go +++ b/api/infra/postgres.go @@ -19,8 +19,7 @@ import ( var db *gorm.DB -type PostgresManager struct { -} +type PostgresManager struct{} func NewPostgresManager() *PostgresManager { return &PostgresManager{} diff --git a/api/repo/file_repo.go b/api/repo/file_repo.go index 3a737851e..10cfe6851 100644 --- a/api/repo/file_repo.go +++ b/api/repo/file_repo.go @@ -223,7 +223,7 @@ func (repo *fileRepo) Find(id string) (model.File, error) { } func (repo *fileRepo) find(id string) (*fileEntity, error) { - var res = fileEntity{} + res := fileEntity{} db := repo.db.Raw("SELECT * FROM file WHERE id = ?", id).Scan(&res) if db.Error != nil { if errors.Is(db.Error, gorm.ErrRecordNotFound) { diff --git a/api/repo/group_repo.go b/api/repo/group_repo.go index 105b28610..c505b9d0c 100644 --- a/api/repo/group_repo.go +++ b/api/repo/group_repo.go @@ -156,7 +156,7 @@ func (repo *groupRepo) Insert(opts GroupInsertOptions) (model.Group, error) { } func (repo *groupRepo) find(id string) (*groupEntity, error) { - var res = groupEntity{} + res := groupEntity{} db := repo.db.Where("id = ?", id).First(&res) if db.Error != nil { if errors.Is(db.Error, gorm.ErrRecordNotFound) { diff --git a/api/repo/invitation_repo.go b/api/repo/invitation_repo.go index f4dd44a90..52776d983 100644 --- a/api/repo/invitation_repo.go +++ b/api/repo/invitation_repo.go @@ -134,7 +134,7 @@ func (repo *invitationRepo) Insert(opts InvitationInsertOptions) ([]model.Invita } func (repo *invitationRepo) Find(id string) (model.Invitation, error) { - var invitation = invitationEntity{} + invitation := invitationEntity{} db := repo.db.Where("id = ?", id).First(&invitation) if db.Error != nil { if errors.Is(db.Error, gorm.ErrRecordNotFound) { diff --git a/api/repo/organization_repo.go b/api/repo/organization_repo.go index 398b0ab8b..be30b1a08 100644 --- a/api/repo/organization_repo.go +++ b/api/repo/organization_repo.go @@ -145,7 +145,7 @@ func (repo *organizationRepo) Insert(opts OrganizationInsertOptions) (model.Orga } func (repo *organizationRepo) find(id string) (*organizationEntity, error) { - var res = organizationEntity{} + res := organizationEntity{} db := repo.db.Where("id = ?", id).First(&res) if db.Error != nil { if errors.Is(db.Error, gorm.ErrRecordNotFound) { diff --git a/api/repo/snapshot_repo.go b/api/repo/snapshot_repo.go index 598dcb84d..8773c9928 100644 --- a/api/repo/snapshot_repo.go +++ b/api/repo/snapshot_repo.go @@ -98,7 +98,7 @@ func (s *snapshotEntity) GetOriginal() *model.S3Object { if s.Original.String() == "" { return nil } - var res = model.S3Object{} + res := model.S3Object{} if err := json.Unmarshal([]byte(s.Original.String()), &res); err != nil { log.GetLogger().Fatal(err) return nil @@ -110,7 +110,7 @@ func (s *snapshotEntity) GetPreview() *model.S3Object { if s.Preview.String() == "" { return nil } - var res = model.S3Object{} + res := model.S3Object{} if err := json.Unmarshal([]byte(s.Preview.String()), &res); err != nil { log.GetLogger().Fatal(err) return nil @@ -122,7 +122,7 @@ func (s *snapshotEntity) GetText() *model.S3Object { if s.Text.String() == "" { return nil } - var res = model.S3Object{} + res := model.S3Object{} if err := json.Unmarshal([]byte(s.Text.String()), &res); err != nil { log.GetLogger().Fatal(err) return nil @@ -134,7 +134,7 @@ func (s *snapshotEntity) GetOCR() *model.S3Object { if s.OCR.String() == "" { return nil } - var res = model.S3Object{} + res := model.S3Object{} if err := json.Unmarshal([]byte(s.OCR.String()), &res); err != nil { log.GetLogger().Fatal(err) return nil @@ -146,7 +146,7 @@ func (s *snapshotEntity) GetEntities() *model.S3Object { if s.Entities.String() == "" { return nil } - var res = model.S3Object{} + res := model.S3Object{} if err := json.Unmarshal([]byte(s.Entities.String()), &res); err != nil { log.GetLogger().Fatal(err) return nil @@ -158,7 +158,7 @@ func (s *snapshotEntity) GetMosaic() *model.S3Object { if s.Mosaic.String() == "" { return nil } - var res = model.S3Object{} + res := model.S3Object{} if err := json.Unmarshal([]byte(s.Mosaic.String()), &res); err != nil { log.GetLogger().Fatal(err) return nil @@ -170,7 +170,7 @@ func (s *snapshotEntity) GetWatermark() *model.S3Object { if s.Watermark.String() == "" { return nil } - var res = model.S3Object{} + res := model.S3Object{} if err := json.Unmarshal([]byte(s.Watermark.String()), &res); err != nil { log.GetLogger().Fatal(err) return nil @@ -182,7 +182,7 @@ func (s *snapshotEntity) GetThumbnail() *model.S3Object { if s.Thumbnail.String() == "" { return nil } - var res = model.S3Object{} + res := model.S3Object{} if err := json.Unmarshal([]byte(s.Thumbnail.String()), &res); err != nil { log.GetLogger().Fatal(err) return nil @@ -413,7 +413,7 @@ func (repo *snapshotRepo) Find(id string) (model.Snapshot, error) { } func (repo *snapshotRepo) FindByVersion(version int64) (model.Snapshot, error) { - var res = snapshotEntity{} + res := snapshotEntity{} db := repo.db.Where("version = ?", version).First(&res) if db.Error != nil { if errors.Is(db.Error, gorm.ErrRecordNotFound) { diff --git a/api/repo/task_repo.go b/api/repo/task_repo.go index fb95e85dc..74de855eb 100644 --- a/api/repo/task_repo.go +++ b/api/repo/task_repo.go @@ -205,7 +205,7 @@ func (repo *taskRepo) Insert(opts TaskInsertOptions) (model.Task, error) { } func (repo *taskRepo) find(id string) (*taskEntity, error) { - var res = taskEntity{} + res := taskEntity{} db := repo.db.Where("id = ?", id).First(&res) if db.Error != nil { if errors.Is(db.Error, gorm.ErrRecordNotFound) { diff --git a/api/repo/user_repo.go b/api/repo/user_repo.go index 59517cef3..7e66278e5 100644 --- a/api/repo/user_repo.go +++ b/api/repo/user_repo.go @@ -97,7 +97,7 @@ func newUserRepo() *userRepo { } func (repo *userRepo) Find(id string) (model.User, error) { - var res = userEntity{} + res := userEntity{} db := repo.db.Where("id = ?", id).First(&res) if db.Error != nil { if errors.Is(db.Error, gorm.ErrRecordNotFound) { @@ -110,7 +110,7 @@ func (repo *userRepo) Find(id string) (model.User, error) { } func (repo *userRepo) FindByEmail(email string) (model.User, error) { - var res = userEntity{} + res := userEntity{} db := repo.db.Where("email = ?", email).First(&res) if db.Error != nil { if errors.Is(db.Error, gorm.ErrRecordNotFound) { diff --git a/api/repo/workspace_repo.go b/api/repo/workspace_repo.go index 02657292f..195909f36 100644 --- a/api/repo/workspace_repo.go +++ b/api/repo/workspace_repo.go @@ -173,7 +173,7 @@ func (repo *workspaceRepo) Insert(opts WorkspaceInsertOptions) (model.Workspace, } func (repo *workspaceRepo) find(id string) (*workspaceEntity, error) { - var res = workspaceEntity{} + res := workspaceEntity{} db := repo.db.Where("id = ?", id).First(&res) if db.Error != nil { if errors.Is(db.Error, gorm.ErrRecordNotFound) { diff --git a/api/router/health_router.go b/api/router/health_router.go index 6b46b1f41..7238cfc42 100644 --- a/api/router/health_router.go +++ b/api/router/health_router.go @@ -18,8 +18,7 @@ import ( "github.com/kouprlabs/voltaserve/api/infra" ) -type HealthRouter struct { -} +type HealthRouter struct{} func NewHealthRouter() *HealthRouter { return &HealthRouter{} diff --git a/api/service/constants.go b/api/service/constants.go index 1b83d9f15..f95d680c5 100644 --- a/api/service/constants.go +++ b/api/service/constants.go @@ -10,15 +10,19 @@ package service -const SortByEmail = "email" -const SortByFullName = "full_name" -const SortByName = "name" -const SortByKind = "kind" -const SortBySize = "size" -const SortByVersion = "version" -const SortByFrequency = "frequency" -const SortByDateCreated = "date_created" -const SortByDateModified = "date_modified" +const ( + SortByEmail = "email" + SortByFullName = "full_name" + SortByName = "name" + SortByKind = "kind" + SortBySize = "size" + SortByVersion = "version" + SortByFrequency = "frequency" + SortByDateCreated = "date_created" + SortByDateModified = "date_modified" +) -const SortOrderAsc = "asc" -const SortOrderDesc = "desc" +const ( + SortOrderAsc = "asc" + SortOrderDesc = "desc" +) diff --git a/api/service/file_service.go b/api/service/file_service.go index c996bb2f0..8737a0f33 100644 --- a/api/service/file_service.go +++ b/api/service/file_service.go @@ -819,8 +819,8 @@ func (svc *FileService) Copy(targetID string, sourceIDs []string, userID string) /* Clone source tree */ var rootCloneIndex int - var cloneIDs = make(map[string]string) - var originalIDs = make(map[string]string) + cloneIDs := make(map[string]string) + originalIDs := make(map[string]string) var clones []model.File var permissions []model.UserPermission for i, o := range sourceTree { diff --git a/api/service/storage_service.go b/api/service/storage_service.go index d9ed60131..e3c2e4ab1 100644 --- a/api/service/storage_service.go +++ b/api/service/storage_service.go @@ -119,8 +119,7 @@ func (svc *StorageService) GetFileUsage(fileID string, userID string) (*StorageU return svc.storageMapper.mapStorageUsage(size, workspace.GetStorageCapacity()), nil } -type storageMapper struct { -} +type storageMapper struct{} func newStorageMapper() *storageMapper { return &storageMapper{} diff --git a/api/service/user_service.go b/api/service/user_service.go index 629a62c65..0fa22b745 100644 --- a/api/service/user_service.go +++ b/api/service/user_service.go @@ -223,8 +223,7 @@ func (svc *UserService) doPagination(data []model.User, page, size uint) ([]mode return pageData, totalElements, totalPages } -type userMapper struct { -} +type userMapper struct{} func newUserMapper() *userMapper { return &userMapper{} From 607ad858711c4c11d85cd88d46baefb5dddc2b6d Mon Sep 17 00:00:00 2001 From: Daniel Sonck Date: Tue, 9 Jul 2024 21:35:08 +0200 Subject: [PATCH 07/12] chore: conversion: enable and apply gofumpt --- conversion/.golangci.yml | 1 - conversion/identifier/file_identifier.go | 3 +-- conversion/infra/logger.go | 14 ++++++++------ conversion/router/health_router.go | 3 +-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/conversion/.golangci.yml b/conversion/.golangci.yml index 7392ae980..2f1d7e760 100644 --- a/conversion/.golangci.yml +++ b/conversion/.golangci.yml @@ -36,7 +36,6 @@ linters: - nestif - lll - gosec - - gofumpt - godot - gocritic - gocognit diff --git a/conversion/identifier/file_identifier.go b/conversion/identifier/file_identifier.go index 37941756c..b1e9c53e2 100644 --- a/conversion/identifier/file_identifier.go +++ b/conversion/identifier/file_identifier.go @@ -17,8 +17,7 @@ import ( "strings" ) -type FileIdentifier struct { -} +type FileIdentifier struct{} func NewFileIdentifier() *FileIdentifier { return &FileIdentifier{} diff --git a/conversion/infra/logger.go b/conversion/infra/logger.go index ca2d3ad5f..bb2be146c 100644 --- a/conversion/infra/logger.go +++ b/conversion/infra/logger.go @@ -17,12 +17,14 @@ import ( "go.uber.org/zap/zapcore" ) -var StrScheduler = fmt.Sprintf("%-13s", "scheduler") -var StrPipeline = fmt.Sprintf("%-13s", "pipeline") -var StrBuilder = fmt.Sprintf("%-13s", "builder") -var StrWorkerStatus = fmt.Sprintf("%-13s", "worker_status") -var StrQueueStatus = fmt.Sprintf("%-13s", "queue_status") -var StrToolRunner = fmt.Sprintf("%-13s", "tool_runner") +var ( + StrScheduler = fmt.Sprintf("%-13s", "scheduler") + StrPipeline = fmt.Sprintf("%-13s", "pipeline") + StrBuilder = fmt.Sprintf("%-13s", "builder") + StrWorkerStatus = fmt.Sprintf("%-13s", "worker_status") + StrQueueStatus = fmt.Sprintf("%-13s", "queue_status") + StrToolRunner = fmt.Sprintf("%-13s", "tool_runner") +) var logger *zap.SugaredLogger diff --git a/conversion/router/health_router.go b/conversion/router/health_router.go index c4aaf7c4e..4d2fe2f98 100644 --- a/conversion/router/health_router.go +++ b/conversion/router/health_router.go @@ -19,8 +19,7 @@ import ( "github.com/kouprlabs/voltaserve/conversion/infra" ) -type HealthRouter struct { -} +type HealthRouter struct{} func NewHealthRouter() *HealthRouter { return &HealthRouter{} From 9a6d120eff5651898557a1c5b6683fe3fb31d39c Mon Sep 17 00:00:00 2001 From: Daniel Sonck Date: Tue, 9 Jul 2024 21:35:50 +0200 Subject: [PATCH 08/12] chore: mosaic: enable and apply gofumpt --- mosaic/.golangci.yml | 1 - mosaic/router/health_router.go | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/mosaic/.golangci.yml b/mosaic/.golangci.yml index 29afc388e..6d4fa4c9c 100644 --- a/mosaic/.golangci.yml +++ b/mosaic/.golangci.yml @@ -29,7 +29,6 @@ linters: - prealloc - lll - gosec - - gofumpt - godot - gocritic - funlen diff --git a/mosaic/router/health_router.go b/mosaic/router/health_router.go index 94d21902f..3ef7849b5 100644 --- a/mosaic/router/health_router.go +++ b/mosaic/router/health_router.go @@ -18,8 +18,7 @@ import ( "github.com/kouprlabs/voltaserve/mosaic/infra" ) -type HealthRouter struct { -} +type HealthRouter struct{} func NewHealthRouter() *HealthRouter { return &HealthRouter{} From cecc03fee8001b04b462cff54e8e2f0db1d94a90 Mon Sep 17 00:00:00 2001 From: Daniel Sonck Date: Tue, 9 Jul 2024 21:41:12 +0200 Subject: [PATCH 09/12] chore: api: enable and apply tagalign --- api/.golangci.yml | 1 - api/repo/file_repo.go | 22 ++++++++++----------- api/repo/group_repo.go | 16 +++++++-------- api/repo/invitation_repo.go | 14 +++++++------- api/repo/organization_repo.go | 14 +++++++------- api/repo/permission_repo.go | 20 +++++++++---------- api/repo/snapshot_repo.go | 30 ++++++++++++++--------------- api/repo/task_repo.go | 20 +++++++++---------- api/repo/user_repo.go | 26 ++++++++++++------------- api/repo/workspace_repo.go | 20 +++++++++---------- api/router/file_router.go | 14 +++++++------- api/service/file_service.go | 10 +++++----- api/service/group_service.go | 2 +- api/service/invitation_service.go | 2 +- api/service/organization_service.go | 2 +- api/service/workspace_service.go | 4 ++-- 16 files changed, 108 insertions(+), 109 deletions(-) diff --git a/api/.golangci.yml b/api/.golangci.yml index c56b3b424..882c523b7 100644 --- a/api/.golangci.yml +++ b/api/.golangci.yml @@ -32,7 +32,6 @@ linters: - asasalint - bodyclose - unparam - - tagalign - revive - predeclared - interfacebloat diff --git a/api/repo/file_repo.go b/api/repo/file_repo.go index 10cfe6851..8d3b7f3ac 100644 --- a/api/repo/file_repo.go +++ b/api/repo/file_repo.go @@ -54,17 +54,17 @@ func NewFile() model.File { } type fileEntity struct { - ID string `json:"id" gorm:"column:id"` - WorkspaceID string `json:"workspaceId" gorm:"column:workspace_id"` - Name string `json:"name" gorm:"column:name"` - Type string `json:"type" gorm:"column:type"` - ParentID *string `json:"parentId,omitempty" gorm:"column:parent_id"` - UserPermissions []*UserPermissionValue `json:"userPermissions" gorm:"-"` - GroupPermissions []*GroupPermissionValue `json:"groupPermissions" gorm:"-"` - Text *string `json:"text,omitempty" gorm:"-"` - SnapshotID *string `json:"snapshotId,omitempty" gorm:"column:snapshot_id"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime,omitempty" gorm:"column:update_time"` + ID string `gorm:"column:id" json:"id"` + WorkspaceID string `gorm:"column:workspace_id" json:"workspaceId"` + Name string `gorm:"column:name" json:"name"` + Type string `gorm:"column:type" json:"type"` + ParentID *string `gorm:"column:parent_id" json:"parentId,omitempty"` + UserPermissions []*UserPermissionValue `gorm:"-" json:"userPermissions"` + GroupPermissions []*GroupPermissionValue `gorm:"-" json:"groupPermissions"` + Text *string `gorm:"-" json:"text,omitempty"` + SnapshotID *string `gorm:"column:snapshot_id" json:"snapshotId,omitempty"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime,omitempty"` } func (*fileEntity) TableName() string { diff --git a/api/repo/group_repo.go b/api/repo/group_repo.go index c505b9d0c..33ad17eab 100644 --- a/api/repo/group_repo.go +++ b/api/repo/group_repo.go @@ -47,14 +47,14 @@ func NewGroup() model.Group { } type groupEntity struct { - ID string `json:"id" gorm:"column:id"` - Name string `json:"name" gorm:"column:name"` - OrganizationID string `json:"organizationId" gorm:"column:organization_id"` - UserPermissions []*UserPermissionValue `json:"userPermissions" gorm:"-"` - GroupPermissions []*GroupPermissionValue `json:"groupPermissions" gorm:"-"` - Members []string `json:"members" gorm:"-"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime" gorm:"column:update_time"` + ID string `gorm:"column:id" json:"id"` + Name string `gorm:"column:name" json:"name"` + OrganizationID string `gorm:"column:organization_id" json:"organizationId"` + UserPermissions []*UserPermissionValue `gorm:"-" json:"userPermissions"` + GroupPermissions []*GroupPermissionValue `gorm:"-" json:"groupPermissions"` + Members []string `gorm:"-" json:"members"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime"` } func (*groupEntity) TableName() string { diff --git a/api/repo/invitation_repo.go b/api/repo/invitation_repo.go index 52776d983..0816207b9 100644 --- a/api/repo/invitation_repo.go +++ b/api/repo/invitation_repo.go @@ -37,13 +37,13 @@ func NewInvitationRepo() InvitationRepo { } type invitationEntity struct { - ID string `json:"id" gorm:"column:id"` - OrganizationID string `json:"organizationId" gorm:"column:organization_id"` - OwnerID string `json:"ownerId" gorm:"column:owner_id"` - Email string `json:"email" gorm:"column:email"` - Status string `json:"status" gorm:"column:status"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime" gorm:"column:update_time"` + ID string `gorm:"column:id" json:"id"` + OrganizationID string `gorm:"column:organization_id" json:"organizationId"` + OwnerID string `gorm:"column:owner_id" json:"ownerId"` + Email string `gorm:"column:email" json:"email"` + Status string `gorm:"column:status" json:"status"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime"` } func (*invitationEntity) TableName() string { diff --git a/api/repo/organization_repo.go b/api/repo/organization_repo.go index be30b1a08..a61ed832f 100644 --- a/api/repo/organization_repo.go +++ b/api/repo/organization_repo.go @@ -46,13 +46,13 @@ func NewOrganization() model.Organization { } type organizationEntity struct { - ID string `json:"id" gorm:"column:id"` - Name string `json:"name" gorm:"column:name"` - UserPermissions []*UserPermissionValue `json:"userPermissions" gorm:"-"` - GroupPermissions []*GroupPermissionValue `json:"groupPermissions" gorm:"-"` - Members []string `json:"members" gorm:"-"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime,omitempty" gorm:"column:update_time"` + ID string `gorm:"column:id" json:"id"` + Name string `gorm:"column:name" json:"name"` + UserPermissions []*UserPermissionValue `gorm:"-" json:"userPermissions"` + GroupPermissions []*GroupPermissionValue `gorm:"-" json:"groupPermissions"` + Members []string `gorm:"-" json:"members"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime,omitempty"` } func (*organizationEntity) TableName() string { diff --git a/api/repo/permission_repo.go b/api/repo/permission_repo.go index 5b24d61fb..a3d374f06 100644 --- a/api/repo/permission_repo.go +++ b/api/repo/permission_repo.go @@ -37,11 +37,11 @@ func NewGroupPermission() model.GroupPermission { } type userPermissionEntity struct { - ID string `json:"id" gorm:"column:id"` - UserID string `json:"userId" gorm:"column:user_id"` - ResourceID string `json:"resourceId" gorm:"column:resource_id"` - Permission string `json:"permission" gorm:"column:permission"` - CreateTime string `json:"createTime" gorm:"column:create_time"` + ID string `gorm:"column:id" json:"id"` + UserID string `gorm:"column:user_id" json:"userId"` + ResourceID string `gorm:"column:resource_id" json:"resourceId"` + Permission string `gorm:"column:permission" json:"permission"` + CreateTime string `gorm:"column:create_time" json:"createTime"` } func (*userPermissionEntity) TableName() string { @@ -94,11 +94,11 @@ func (u *userPermissionEntity) SetCreateTime(createTime string) { } type groupPermissionEntity struct { - ID string `json:"id" gorm:"column:id"` - GroupID string `json:"groupId" gorm:"column:group_id"` - ResourceID string `json:"resourceId" gorm:"column:resource_id"` - Permission string `json:"permission" gorm:"column:permission"` - CreateTime string `json:"createTime" gorm:"column:create_time"` + ID string `gorm:"column:id" json:"id"` + GroupID string `gorm:"column:group_id" json:"groupId"` + ResourceID string `gorm:"column:resource_id" json:"resourceId"` + Permission string `gorm:"column:permission" json:"permission"` + CreateTime string `gorm:"column:create_time" json:"createTime"` } func (*groupPermissionEntity) TableName() string { diff --git a/api/repo/snapshot_repo.go b/api/repo/snapshot_repo.go index 8773c9928..e51767fee 100644 --- a/api/repo/snapshot_repo.go +++ b/api/repo/snapshot_repo.go @@ -54,21 +54,21 @@ func NewSnapshot() model.Snapshot { } type snapshotEntity struct { - ID string `json:"id" gorm:"column:id;size:36"` - Version int64 `json:"version" gorm:"column:version"` - Original datatypes.JSON `json:"original,omitempty" gorm:"column:original"` - Preview datatypes.JSON `json:"preview,omitempty" gorm:"column:preview"` - Text datatypes.JSON `json:"text,omitempty" gorm:"column:text"` - OCR datatypes.JSON `json:"ocr,omitempty" gorm:"column:ocr"` - Entities datatypes.JSON `json:"entities,omitempty" gorm:"column:entities"` - Mosaic datatypes.JSON `json:"mosaic,omitempty" gorm:"column:mosaic"` - Watermark datatypes.JSON `json:"watermark,omitempty" gorm:"column:watermark"` - Thumbnail datatypes.JSON `json:"thumbnail,omitempty" gorm:"column:thumbnail"` - Status string `json:"status,omitempty" gorm:"column,status"` - Language *string `json:"language,omitempty" gorm:"column:language"` - TaskID *string `json:"taskID,omitempty" gorm:"column:task_id"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime,omitempty" gorm:"column:update_time"` + ID string `gorm:"column:id;size:36" json:"id"` + Version int64 `gorm:"column:version" json:"version"` + Original datatypes.JSON `gorm:"column:original" json:"original,omitempty"` + Preview datatypes.JSON `gorm:"column:preview" json:"preview,omitempty"` + Text datatypes.JSON `gorm:"column:text" json:"text,omitempty"` + OCR datatypes.JSON `gorm:"column:ocr" json:"ocr,omitempty"` + Entities datatypes.JSON `gorm:"column:entities" json:"entities,omitempty"` + Mosaic datatypes.JSON `gorm:"column:mosaic" json:"mosaic,omitempty"` + Watermark datatypes.JSON `gorm:"column:watermark" json:"watermark,omitempty"` + Thumbnail datatypes.JSON `gorm:"column:thumbnail" json:"thumbnail,omitempty"` + Status string `gorm:"column,status" json:"status,omitempty"` + Language *string `gorm:"column:language" json:"language,omitempty"` + TaskID *string `gorm:"column:task_id" json:"taskID,omitempty"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime,omitempty"` } func (*snapshotEntity) TableName() string { diff --git a/api/repo/task_repo.go b/api/repo/task_repo.go index 74de855eb..b6d89b943 100644 --- a/api/repo/task_repo.go +++ b/api/repo/task_repo.go @@ -25,16 +25,16 @@ import ( ) type taskEntity struct { - ID string `json:"id" gorm:"column:id"` - Name string `json:"name" gorm:"column:name"` - Error *string `json:"error,omitempty" gorm:"column:error"` - Percentage *int `json:"percentage,omitempty" gorm:"column:percentage"` - IsIndeterminate bool `json:"isIndeterminate" gorm:"column:is_indeterminate"` - UserID string `json:"userId" gorm:"column:user_id"` - Status string `json:"status" gorm:"column:status"` - Payload datatypes.JSON `json:"payload" gorm:"column:payload"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime,omitempty" gorm:"column:update_time"` + ID string `gorm:"column:id" json:"id"` + Name string `gorm:"column:name" json:"name"` + Error *string `gorm:"column:error" json:"error,omitempty"` + Percentage *int `gorm:"column:percentage" json:"percentage,omitempty"` + IsIndeterminate bool `gorm:"column:is_indeterminate" json:"isIndeterminate"` + UserID string `gorm:"column:user_id" json:"userId"` + Status string `gorm:"column:status" json:"status"` + Payload datatypes.JSON `gorm:"column:payload" json:"payload"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime,omitempty"` } func (*taskEntity) TableName() string { diff --git a/api/repo/user_repo.go b/api/repo/user_repo.go index 7e66278e5..db3db3fdc 100644 --- a/api/repo/user_repo.go +++ b/api/repo/user_repo.go @@ -35,19 +35,19 @@ func NewUser() model.User { } type userEntity struct { - ID string `json:"id" gorm:"column:id"` - FullName string `json:"fullName" gorm:"column:full_name"` - Username string `json:"username" gorm:"column:username"` - Email string `json:"email" gorm:"column:email"` - Picture *string `json:"picture" gorm:"column:picture"` - IsEmailConfirmed bool `json:"isEmailConfirmed" gorm:"column:is_email_confirmed"` - PasswordHash string `json:"passwordHash" gorm:"column:password_hash"` - RefreshTokenValue *string `json:"refreshTokenValue" gorm:"column:refresh_token_value"` - RefreshTokenValidTo *int64 `json:"refreshTokenValidTo" gorm:"column:refresh_token_valid_to"` - ResetPasswordToken *string `json:"resetPasswordToken" gorm:"column:reset_password_token"` - EmailConfirmationToken *string `json:"emailConfirmationToken" gorm:"column:email_confirmation_token"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime" gorm:"column:update_time"` + ID string `gorm:"column:id" json:"id"` + FullName string `gorm:"column:full_name" json:"fullName"` + Username string `gorm:"column:username" json:"username"` + Email string `gorm:"column:email" json:"email"` + Picture *string `gorm:"column:picture" json:"picture"` + IsEmailConfirmed bool `gorm:"column:is_email_confirmed" json:"isEmailConfirmed"` + PasswordHash string `gorm:"column:password_hash" json:"passwordHash"` + RefreshTokenValue *string `gorm:"column:refresh_token_value" json:"refreshTokenValue"` + RefreshTokenValidTo *int64 `gorm:"column:refresh_token_valid_to" json:"refreshTokenValidTo"` + ResetPasswordToken *string `gorm:"column:reset_password_token" json:"resetPasswordToken"` + EmailConfirmationToken *string `gorm:"column:email_confirmation_token" json:"emailConfirmationToken"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime"` } func (userEntity) TableName() string { diff --git a/api/repo/workspace_repo.go b/api/repo/workspace_repo.go index 195909f36..62addbf67 100644 --- a/api/repo/workspace_repo.go +++ b/api/repo/workspace_repo.go @@ -43,16 +43,16 @@ func NewWorkspace() model.Workspace { } type workspaceEntity struct { - ID string `json:"id," gorm:"column:id;size:36"` - Name string `json:"name" gorm:"column:name;size:255"` - StorageCapacity int64 `json:"storageCapacity" gorm:"column:storage_capacity"` - RootID string `json:"rootId" gorm:"column:root_id;size:36"` - OrganizationID string `json:"organizationId" gorm:"column:organization_id;size:36"` - UserPermissions []*UserPermissionValue `json:"userPermissions" gorm:"-"` - GroupPermissions []*GroupPermissionValue `json:"groupPermissions" gorm:"-"` - Bucket string `json:"bucket" gorm:"column:bucket;size:255"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime,omitempty" gorm:"column:update_time"` + ID string `gorm:"column:id;size:36" json:"id"` + Name string `gorm:"column:name;size:255" json:"name"` + StorageCapacity int64 `gorm:"column:storage_capacity" json:"storageCapacity"` + RootID string `gorm:"column:root_id;size:36" json:"rootId"` + OrganizationID string `gorm:"column:organization_id;size:36" json:"organizationId"` + UserPermissions []*UserPermissionValue `gorm:"-" json:"userPermissions"` + GroupPermissions []*GroupPermissionValue `gorm:"-" json:"groupPermissions"` + Bucket string `gorm:"column:bucket;size:255" json:"bucket"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime,omitempty"` } func (*workspaceEntity) TableName() string { diff --git a/api/router/file_router.go b/api/router/file_router.go index 45603b691..667da7051 100644 --- a/api/router/file_router.go +++ b/api/router/file_router.go @@ -237,7 +237,7 @@ func (r *FileRouter) Patch(c *fiber.Ctx) error { type FileCreateFolderOptions struct { WorkspaceID string `json:"workspaceId" validate:"required"` - Name string `json:"name" validate:"required,max=255"` + Name string `json:"name" validate:"required,max=255"` ParentID *string `json:"parentId"` } @@ -596,8 +596,8 @@ func (r *FileRouter) GetCount(c *fiber.Ctx) error { } type FileGrantUserPermissionOptions struct { - UserID string `json:"userId" validate:"required"` - IDs []string `json:"ids" validate:"required"` + UserID string `json:"userId" validate:"required"` + IDs []string `json:"ids" validate:"required"` Permission string `json:"permission" validate:"required,oneof=viewer editor owner"` } @@ -629,7 +629,7 @@ func (r *FileRouter) GrantUserPermission(c *fiber.Ctx) error { } type FileRevokeUserPermissionOptions struct { - IDs []string `json:"ids" validate:"required"` + IDs []string `json:"ids" validate:"required"` UserID string `json:"userId" validate:"required"` } @@ -661,8 +661,8 @@ func (r *FileRouter) RevokeUserPermission(c *fiber.Ctx) error { } type FileGrantGroupPermissionOptions struct { - GroupID string `json:"groupId" validate:"required"` - IDs []string `json:"ids" validate:"required"` + GroupID string `json:"groupId" validate:"required"` + IDs []string `json:"ids" validate:"required"` Permission string `json:"permission" validate:"required,oneof=viewer editor owner"` } @@ -694,7 +694,7 @@ func (r *FileRouter) GrantGroupPermission(c *fiber.Ctx) error { } type FileRevokeGroupPermissionOptions struct { - IDs []string `json:"ids" validate:"required"` + IDs []string `json:"ids" validate:"required"` GroupID string `json:"groupId" validate:"required"` } diff --git a/api/service/file_service.go b/api/service/file_service.go index 8737a0f33..f76eb8bd4 100644 --- a/api/service/file_service.go +++ b/api/service/file_service.go @@ -90,9 +90,9 @@ func NewFileService() *FileService { type FileCreateOptions struct { WorkspaceID string `json:"workspaceId" validate:"required"` - Name string `json:"name" validate:"required,max=255"` - Type string `json:"type" validate:"required,oneof=file folder"` - ParentID *string `json:"parentId" validate:"required"` + Name string `json:"name" validate:"required,max=255"` + Type string `json:"type" validate:"required,oneof=file folder"` + ParentID *string `json:"parentId" validate:"required"` } type File struct { @@ -622,8 +622,8 @@ func (svc *FileService) ListByPath(path string, userID string) ([]*File, error) } type FileQuery struct { - Text string `json:"text" validate:"required"` - Type *string `json:"type,omitempty" validate:"omitempty,oneof=file folder"` + Text string `json:"text" validate:"required"` + Type *string `json:"type,omitempty" validate:"omitempty,oneof=file folder"` CreateTimeAfter *int64 `json:"createTimeAfter,omitempty"` CreateTimeBefore *int64 `json:"createTimeBefore,omitempty"` UpdateTimeAfter *int64 `json:"updateTimeAfter,omitempty"` diff --git a/api/service/group_service.go b/api/service/group_service.go index 2c83e055b..0c20bb361 100644 --- a/api/service/group_service.go +++ b/api/service/group_service.go @@ -66,7 +66,7 @@ func NewGroupService() *GroupService { } type GroupCreateOptions struct { - Name string `json:"name" validate:"required,max=255"` + Name string `json:"name" validate:"required,max=255"` Image *string `json:"image"` OrganizationID string `json:"organizationId" validate:"required"` } diff --git a/api/service/invitation_service.go b/api/service/invitation_service.go index ada2992b9..138a1278e 100644 --- a/api/service/invitation_service.go +++ b/api/service/invitation_service.go @@ -52,7 +52,7 @@ func NewInvitationService() *InvitationService { type InvitationCreateOptions struct { OrganizationID string `json:"organizationId" validate:"required"` - Emails []string `json:"emails" validate:"required,dive,email"` + Emails []string `json:"emails" validate:"required,dive,email"` } func (svc *InvitationService) Create(opts InvitationCreateOptions, userID string) error { diff --git a/api/service/organization_service.go b/api/service/organization_service.go index cf939361a..6fc484440 100644 --- a/api/service/organization_service.go +++ b/api/service/organization_service.go @@ -56,7 +56,7 @@ func NewOrganizationService() *OrganizationService { } type OrganizationCreateOptions struct { - Name string `json:"name" validate:"required,max=255"` + Name string `json:"name" validate:"required,max=255"` Image *string `json:"image"` } diff --git a/api/service/workspace_service.go b/api/service/workspace_service.go index 76886583d..b674cce03 100644 --- a/api/service/workspace_service.go +++ b/api/service/workspace_service.go @@ -71,9 +71,9 @@ type Workspace struct { } type WorkspaceCreateOptions struct { - Name string `json:"name" validate:"required,max=255"` + Name string `json:"name" validate:"required,max=255"` Image *string `json:"image"` - OrganizationID string `json:"organizationId" validate:"required"` + OrganizationID string `json:"organizationId" validate:"required"` StorageCapacity int64 `json:"storageCapacity"` } From 9a318d06c4868a8e15b94baf786fdc3222ca39c8 Mon Sep 17 00:00:00 2001 From: Daniel Sonck Date: Tue, 9 Jul 2024 22:40:17 +0200 Subject: [PATCH 10/12] chore: enable godot --- api/.golangci.yml | 1 - api/main.go | 2 ++ conversion/.golangci.yml | 1 - conversion/main.go | 2 ++ conversion/runtime/scheduler.go | 2 +- mosaic/.golangci.yml | 1 - mosaic/main.go | 2 ++ 7 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api/.golangci.yml b/api/.golangci.yml index 882c523b7..7fc36c952 100644 --- a/api/.golangci.yml +++ b/api/.golangci.yml @@ -40,7 +40,6 @@ linters: - nestif - lll - gosec - - godot - gocritic - gocognit - funlen diff --git a/api/main.go b/api/main.go index 7f5713686..1b1426a5d 100644 --- a/api/main.go +++ b/api/main.go @@ -29,6 +29,8 @@ import ( // @title Voltaserve API // @version 2.0.0 // @BasePath /v2 +// +// . func main() { if _, err := os.Stat(".env.local"); err == nil { err := godotenv.Load(".env.local") diff --git a/conversion/.golangci.yml b/conversion/.golangci.yml index 2f1d7e760..0da178343 100644 --- a/conversion/.golangci.yml +++ b/conversion/.golangci.yml @@ -36,7 +36,6 @@ linters: - nestif - lll - gosec - - godot - gocritic - gocognit - funlen diff --git a/conversion/main.go b/conversion/main.go index f47ec390b..48c75252e 100644 --- a/conversion/main.go +++ b/conversion/main.go @@ -28,6 +28,8 @@ import ( // @title Voltaserve Conversion // @version 2.0.0 // @BasePath /v2 +// +// . func main() { if _, err := os.Stat(".env.local"); err == nil { err := godotenv.Load(".env.local") diff --git a/conversion/runtime/scheduler.go b/conversion/runtime/scheduler.go index f08d4df72..d49187892 100644 --- a/conversion/runtime/scheduler.go +++ b/conversion/runtime/scheduler.go @@ -63,7 +63,7 @@ func (s *Scheduler) SchedulePipeline(opts *client.PipelineRunOptions) { s.pipelineQueue[index] = append(s.pipelineQueue[index], *opts) } -/* Choose the pipeline with the least number of items in the queue */ +// Choose the pipeline with the least number of items in the queue. func (s *Scheduler) choosePipeline() int { index := 0 length := len(s.pipelineQueue[0]) diff --git a/mosaic/.golangci.yml b/mosaic/.golangci.yml index 6d4fa4c9c..efe6206fa 100644 --- a/mosaic/.golangci.yml +++ b/mosaic/.golangci.yml @@ -29,7 +29,6 @@ linters: - prealloc - lll - gosec - - godot - gocritic - funlen - gocognit diff --git a/mosaic/main.go b/mosaic/main.go index cf29d25d9..95505e92d 100644 --- a/mosaic/main.go +++ b/mosaic/main.go @@ -26,6 +26,8 @@ import ( // @title Voltaserve Mosaic // @version 2.0.0 // @BasePath /v2 +// +// . func main() { if _, err := os.Stat(".env.local"); err == nil { err := godotenv.Load(".env.local") From 446a2e6de9e375bb0f83bc1b6b5a21e80def573f Mon Sep 17 00:00:00 2001 From: Daniel Sonck Date: Wed, 10 Jul 2024 00:18:15 +0200 Subject: [PATCH 11/12] chore: webdav: add linting --- .github/workflows/lint-webdav.yml | 34 ++++++++ webdav/.golangci.yml | 125 ++++++++++++++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 .github/workflows/lint-webdav.yml create mode 100644 webdav/.golangci.yml diff --git a/.github/workflows/lint-webdav.yml b/.github/workflows/lint-webdav.yml new file mode 100644 index 000000000..9525bf650 --- /dev/null +++ b/.github/workflows/lint-webdav.yml @@ -0,0 +1,34 @@ +# Copyright 2023 Daniël Sonck, Piotr Łoboda. +# +# Use of this software is governed by the Business Source License +# included in the file licenses/BSL.txt. +# +# As of the Change Date specified in that file, in accordance with +# the Business Source License, use of this software will be governed +# by the GNU Affero General Public License v3.0 only, included in the file +# licenses/AGPL.txt. + +name: Lint voltaserve/webdav + +on: + pull_request: + branches: + - main + paths: + - "webdav/**" + +jobs: + linting: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Lint using Golanci lint + uses: golangci/golangci-lint-action@v6 + with: + working-directory: webdav + permissions: + contents: read + pull-requests: read + checks: write diff --git a/webdav/.golangci.yml b/webdav/.golangci.yml new file mode 100644 index 000000000..4b0aae34c --- /dev/null +++ b/webdav/.golangci.yml @@ -0,0 +1,125 @@ +--- +linters: + enable-all: true + disable: + - exhaustruct # Structs may be uninitialized + - nlreturn # covered by wsl cuddle rules + - nonamedreturns # named returns are acceptable + - depguard # no dependency management + # deprecated + - execinquery + - gomnd + # To fix ############################################### + - wsl + - wrapcheck + - usestdlibvars + - tagliatelle + - stylecheck + - perfsprint + - noctx + - nilerr + - nilnil + - musttag + - mnd + - govet + - gochecknoglobals + - err113 + - bodyclose + - revive + - staticcheck + - cyclop + - nestif + - canonicalheader + - lll + - gosec + - funlen + - goimports + - gofmt + - gofumpt + - gci + - tagalign + +severity: + default-severity: major + +issues: + fast: false + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false + exclude-case-sensitive: true + exclude-rules: + - path: _test\.go + linters: + - errcheck + - errchkjson + - funlen + - gochecknoglobals + - goconst + - wrapcheck + +linters-settings: + gci: + sections: + - standard + - default + - prefix(github.com/kouprlabs) + - prefix(github.com/kouprlabs/voltaserve/webdav) + + mnd: + ignored-numbers: ['2', '4', '8', '16', '32', '64', '10', '100', '1000'] + + gosec: + excludes: + - G104 # Errors unhandled. Already covered by errcheck linter. + - G307 # Deferring a method which returns an error. Already covered by errcheck linter. + - G601 # No longer applicable since go v1.22 update to for loops. + + govet: + enable-all: true + disable: + - fieldalignment # misalignment is accepted + + revive: + # see https://github.com/mgechev/revive#recommended-configuration + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: error-return + - name: error-strings + - name: error-naming + - name: exported + - name: if-return + - name: increment-decrement + - name: var-naming + - name: var-declaration + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: unexported-return + - name: indent-error-flow + - name: errorf + - name: empty-block + - name: superfluous-else + - name: unused-parameter + - name: unreachable-code + - name: redefines-builtin-id + + stylecheck: + checks: [all] + + tagliatelle: + case: + rules: + json: goCamel + yaml: goSnake + + varnamelen: + min-name-length: 1 + + wsl: + force-err-cuddling: true + From 6c4ffcffa51655383ecfb1c2148d88557b520de0 Mon Sep 17 00:00:00 2001 From: Daniel Sonck Date: Wed, 10 Jul 2024 00:24:04 +0200 Subject: [PATCH 12/12] chore: webdav: reorder imports --- webdav/.golangci.yml | 5 ----- webdav/cache/workspace_cache.go | 17 +++++++++-------- webdav/client/api_client.go | 7 ++++--- webdav/client/idp_client.go | 5 +++-- webdav/handler/handler.go | 3 ++- webdav/handler/method_copy.go | 5 +++-- webdav/handler/method_delete.go | 3 ++- webdav/handler/method_get.go | 10 ++++++---- webdav/handler/method_head.go | 3 ++- webdav/handler/method_mkcol.go | 5 +++-- webdav/handler/method_move.go | 7 ++++--- webdav/handler/method_propfind.go | 3 ++- webdav/handler/method_put.go | 12 +++++++----- webdav/helper/token.go | 3 ++- webdav/infra/redis.go | 6 ++++-- webdav/infra/s3.go | 8 +++++--- webdav/main.go | 11 +++++++---- 17 files changed, 65 insertions(+), 48 deletions(-) diff --git a/webdav/.golangci.yml b/webdav/.golangci.yml index 4b0aae34c..235f51c42 100644 --- a/webdav/.golangci.yml +++ b/webdav/.golangci.yml @@ -33,11 +33,6 @@ linters: - lll - gosec - funlen - - goimports - - gofmt - - gofumpt - - gci - - tagalign severity: default-severity: major diff --git a/webdav/cache/workspace_cache.go b/webdav/cache/workspace_cache.go index fb54a1876..773c7a2fc 100644 --- a/webdav/cache/workspace_cache.go +++ b/webdav/cache/workspace_cache.go @@ -12,6 +12,7 @@ package cache import ( "encoding/json" + "github.com/kouprlabs/voltaserve/webdav/infra" ) @@ -28,14 +29,14 @@ func NewWorkspaceCache() *WorkspaceCache { } type Workspace struct { - ID string `json:"id," gorm:"column:id;size:36"` - Name string `json:"name" gorm:"column:name;size:255"` - StorageCapacity int64 `json:"storageCapacity" gorm:"column:storage_capacity"` - RootID string `json:"rootId" gorm:"column:root_id;size:36"` - OrganizationID string `json:"organizationId" gorm:"column:organization_id;size:36"` - Bucket string `json:"bucket" gorm:"column:bucket;size:255"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime,omitempty" gorm:"column:update_time"` + ID string `gorm:"column:id;size:36" json:"id"` + Name string `gorm:"column:name;size:255" json:"name"` + StorageCapacity int64 `gorm:"column:storage_capacity" json:"storageCapacity"` + RootID string `gorm:"column:root_id;size:36" json:"rootId"` + OrganizationID string `gorm:"column:organization_id;size:36" json:"organizationId"` + Bucket string `gorm:"column:bucket;size:255" json:"bucket"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime,omitempty"` } func (c *WorkspaceCache) Get(id string) (*Workspace, error) { diff --git a/webdav/client/api_client.go b/webdav/client/api_client.go index e0f41137a..4ab05fa73 100644 --- a/webdav/client/api_client.go +++ b/webdav/client/api_client.go @@ -15,14 +15,15 @@ import ( "encoding/json" "errors" "fmt" - "github.com/kouprlabs/voltaserve/webdav/config" - "github.com/kouprlabs/voltaserve/webdav/helper" - "github.com/kouprlabs/voltaserve/webdav/infra" "io" "net/http" "net/url" "os" "strings" + + "github.com/kouprlabs/voltaserve/webdav/config" + "github.com/kouprlabs/voltaserve/webdav/helper" + "github.com/kouprlabs/voltaserve/webdav/infra" ) const ( diff --git a/webdav/client/idp_client.go b/webdav/client/idp_client.go index 55186dd05..2ffc52843 100644 --- a/webdav/client/idp_client.go +++ b/webdav/client/idp_client.go @@ -15,12 +15,13 @@ import ( "encoding/json" "errors" "fmt" - "github.com/kouprlabs/voltaserve/webdav/config" - "github.com/kouprlabs/voltaserve/webdav/infra" "io" "net/http" "net/url" "strings" + + "github.com/kouprlabs/voltaserve/webdav/config" + "github.com/kouprlabs/voltaserve/webdav/infra" ) const ( diff --git a/webdav/handler/handler.go b/webdav/handler/handler.go index caa87ffd9..57dd7193e 100644 --- a/webdav/handler/handler.go +++ b/webdav/handler/handler.go @@ -11,10 +11,11 @@ package handler import ( + "net/http" + "github.com/kouprlabs/voltaserve/webdav/cache" "github.com/kouprlabs/voltaserve/webdav/client" "github.com/kouprlabs/voltaserve/webdav/infra" - "net/http" ) type Handler struct { diff --git a/webdav/handler/method_copy.go b/webdav/handler/method_copy.go index cafe39f4d..0d6647804 100644 --- a/webdav/handler/method_copy.go +++ b/webdav/handler/method_copy.go @@ -12,11 +12,12 @@ package handler import ( "fmt" + "net/http" + "path" + "github.com/kouprlabs/voltaserve/webdav/client" "github.com/kouprlabs/voltaserve/webdav/helper" "github.com/kouprlabs/voltaserve/webdav/infra" - "net/http" - "path" ) /* diff --git a/webdav/handler/method_delete.go b/webdav/handler/method_delete.go index ecb883145..81930281f 100644 --- a/webdav/handler/method_delete.go +++ b/webdav/handler/method_delete.go @@ -12,10 +12,11 @@ package handler import ( "fmt" + "net/http" + "github.com/kouprlabs/voltaserve/webdav/client" "github.com/kouprlabs/voltaserve/webdav/helper" "github.com/kouprlabs/voltaserve/webdav/infra" - "net/http" ) /* diff --git a/webdav/handler/method_get.go b/webdav/handler/method_get.go index d79866587..24f9a28c5 100644 --- a/webdav/handler/method_get.go +++ b/webdav/handler/method_get.go @@ -12,16 +12,18 @@ package handler import ( "fmt" - "github.com/google/uuid" - "github.com/kouprlabs/voltaserve/webdav/client" - "github.com/kouprlabs/voltaserve/webdav/helper" - "github.com/kouprlabs/voltaserve/webdav/infra" "io" "net/http" "os" "path/filepath" "strconv" "strings" + + "github.com/google/uuid" + + "github.com/kouprlabs/voltaserve/webdav/client" + "github.com/kouprlabs/voltaserve/webdav/helper" + "github.com/kouprlabs/voltaserve/webdav/infra" ) /* diff --git a/webdav/handler/method_head.go b/webdav/handler/method_head.go index 6be2bd8a9..c0c7885ae 100644 --- a/webdav/handler/method_head.go +++ b/webdav/handler/method_head.go @@ -12,10 +12,11 @@ package handler import ( "fmt" + "net/http" + "github.com/kouprlabs/voltaserve/webdav/client" "github.com/kouprlabs/voltaserve/webdav/helper" "github.com/kouprlabs/voltaserve/webdav/infra" - "net/http" ) /* diff --git a/webdav/handler/method_mkcol.go b/webdav/handler/method_mkcol.go index 191226d55..23222a26f 100644 --- a/webdav/handler/method_mkcol.go +++ b/webdav/handler/method_mkcol.go @@ -12,11 +12,12 @@ package handler import ( "fmt" + "net/http" + "path" + "github.com/kouprlabs/voltaserve/webdav/client" "github.com/kouprlabs/voltaserve/webdav/helper" "github.com/kouprlabs/voltaserve/webdav/infra" - "net/http" - "path" ) /* diff --git a/webdav/handler/method_move.go b/webdav/handler/method_move.go index eda6ad9c4..ba07964c1 100644 --- a/webdav/handler/method_move.go +++ b/webdav/handler/method_move.go @@ -12,12 +12,13 @@ package handler import ( "fmt" - "github.com/kouprlabs/voltaserve/webdav/client" - "github.com/kouprlabs/voltaserve/webdav/helper" - "github.com/kouprlabs/voltaserve/webdav/infra" "net/http" "path" "strings" + + "github.com/kouprlabs/voltaserve/webdav/client" + "github.com/kouprlabs/voltaserve/webdav/helper" + "github.com/kouprlabs/voltaserve/webdav/infra" ) /* diff --git a/webdav/handler/method_propfind.go b/webdav/handler/method_propfind.go index bd04cf55a..60c56f416 100644 --- a/webdav/handler/method_propfind.go +++ b/webdav/handler/method_propfind.go @@ -12,10 +12,11 @@ package handler import ( "fmt" + "net/http" + "github.com/kouprlabs/voltaserve/webdav/client" "github.com/kouprlabs/voltaserve/webdav/helper" "github.com/kouprlabs/voltaserve/webdav/infra" - "net/http" ) /* diff --git a/webdav/handler/method_put.go b/webdav/handler/method_put.go index a23d58d69..907b83d59 100644 --- a/webdav/handler/method_put.go +++ b/webdav/handler/method_put.go @@ -12,17 +12,19 @@ package handler import ( "fmt" - "github.com/google/uuid" - "github.com/kouprlabs/voltaserve/webdav/client" - "github.com/kouprlabs/voltaserve/webdav/helper" - "github.com/kouprlabs/voltaserve/webdav/infra" - "github.com/minio/minio-go/v7" "io" "net/http" "os" "path" "path/filepath" "strings" + + "github.com/google/uuid" + "github.com/minio/minio-go/v7" + + "github.com/kouprlabs/voltaserve/webdav/client" + "github.com/kouprlabs/voltaserve/webdav/helper" + "github.com/kouprlabs/voltaserve/webdav/infra" ) /* diff --git a/webdav/helper/token.go b/webdav/helper/token.go index d175e2b4d..73af6c0a2 100644 --- a/webdav/helper/token.go +++ b/webdav/helper/token.go @@ -11,8 +11,9 @@ package helper import ( - "github.com/kouprlabs/voltaserve/webdav/infra" "time" + + "github.com/kouprlabs/voltaserve/webdav/infra" ) func NewExpiry(token *infra.Token) time.Time { diff --git a/webdav/infra/redis.go b/webdav/infra/redis.go index 266ffcf27..d92ca0bd2 100644 --- a/webdav/infra/redis.go +++ b/webdav/infra/redis.go @@ -12,9 +12,11 @@ package infra import ( "context" - "github.com/kouprlabs/voltaserve/webdav/config" - "github.com/redis/go-redis/v9" "strings" + + "github.com/redis/go-redis/v9" + + "github.com/kouprlabs/voltaserve/webdav/config" ) type RedisManager struct { diff --git a/webdav/infra/s3.go b/webdav/infra/s3.go index 687e88143..e1c477899 100644 --- a/webdav/infra/s3.go +++ b/webdav/infra/s3.go @@ -14,11 +14,13 @@ import ( "bytes" "context" "errors" - "github.com/kouprlabs/voltaserve/webdav/config" - "github.com/minio/minio-go/v7" - "github.com/minio/minio-go/v7/pkg/credentials" "io" "strings" + + "github.com/minio/minio-go/v7" + "github.com/minio/minio-go/v7/pkg/credentials" + + "github.com/kouprlabs/voltaserve/webdav/config" ) type S3Manager struct { diff --git a/webdav/main.go b/webdav/main.go index 8a7b7403c..ae3f5f9cc 100644 --- a/webdav/main.go +++ b/webdav/main.go @@ -13,10 +13,6 @@ package main import ( "context" "fmt" - "github.com/kouprlabs/voltaserve/webdav/client" - "github.com/kouprlabs/voltaserve/webdav/handler" - "github.com/kouprlabs/voltaserve/webdav/helper" - "github.com/kouprlabs/voltaserve/webdav/infra" "log" "net/http" "os" @@ -25,7 +21,12 @@ import ( "time" "github.com/joho/godotenv" + + "github.com/kouprlabs/voltaserve/webdav/client" "github.com/kouprlabs/voltaserve/webdav/config" + "github.com/kouprlabs/voltaserve/webdav/handler" + "github.com/kouprlabs/voltaserve/webdav/helper" + "github.com/kouprlabs/voltaserve/webdav/infra" ) var ( @@ -90,6 +91,8 @@ func basicAuthMiddleware(next http.Handler, idpClient *client.IdPClient) http.Ha // @title Voltaserve WebDAV // @version 2.0.0 // @BasePath /v2 +// +// . func main() { if _, err := os.Stat(".env.local"); err == nil { if err := godotenv.Load(".env.local"); err != nil {