From 2ca9719ff617360ae6f45777353add1e798e3184 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 18 May 2020 00:59:41 +0800 Subject: [PATCH] Add documents --- cmd/migrate_storage.go | 28 ++++++++++++---------- custom/conf/app.ini.sample | 22 +++++++++++++++-- .../doc/advanced/config-cheat-sheet.en-us.md | 10 +++++++- .../doc/advanced/config-cheat-sheet.zh-cn.md | 10 +++++++- 4 files changed, 54 insertions(+), 16 deletions(-) diff --git a/cmd/migrate_storage.go b/cmd/migrate_storage.go index 496f18e11..4e75a0184 100644 --- a/cmd/migrate_storage.go +++ b/cmd/migrate_storage.go @@ -42,39 +42,43 @@ var CmdMigrateStorage = cli.Command{ cli.StringFlag{ Name: "minio-endpoint", Value: "", - Usage: "New storage placement if store is local", + Usage: "New minio storage endpoint", }, cli.StringFlag{ Name: "minio-access-key-id", Value: "", - Usage: "New storage placement if store is local", + Usage: "New minio storage accessKeyID", }, cli.StringFlag{ - Name: "minio-scret-access-key", + Name: "minio-secret-access-key", Value: "", - Usage: "New storage placement if store is local", + Usage: "New minio storage secretAccessKey", }, cli.StringFlag{ Name: "minio-bucket", Value: "", - Usage: "New storage placement if store is local", + Usage: "New minio storage bucket", }, cli.StringFlag{ Name: "minio-location", Value: "", - Usage: "New storage placement if store is local", + Usage: "New minio storage location to create bucket", }, cli.StringFlag{ - Name: "minio-use-ssl", + Name: "minio-base-path", Value: "", - Usage: "New storage placement if store is local", + Usage: "New minio storage basepath on the bucket", + }, + cli.BoolFlag{ + Name: "minio-use-ssl", + Usage: "New minio storage SSL enabled", }, }, } func migrateAttachments(dstStorage storage.ObjectStorage) error { return models.IterateAttachment(func(attach *models.Attachment) error { - _, err := storage.Copy(dstStorage, attach.UUID, storage.Attachments, attach.RelativePath()) + _, err := storage.Copy(dstStorage, attach.RelativePath(), storage.Attachments, attach.RelativePath()) return err }) } @@ -106,7 +110,7 @@ func runMigrateStorage(ctx *cli.Context) error { var err error switch ctx.String("store") { case "local": - dstStorage, err = storage.NewLocalStorage(ctx.String("dst")) + dstStorage, err = storage.NewLocalStorage(ctx.String("path")) case "minio": dstStorage, err = storage.NewMinioStorage( ctx.String("minio-endpoint"), @@ -114,8 +118,8 @@ func runMigrateStorage(ctx *cli.Context) error { ctx.String("minio-secret-access-key"), ctx.String("minio-bucket"), ctx.String("minio-location"), - ctx.String("minio-basePath"), - ctx.Bool("minio-useSSL"), + ctx.String("minio-base-path"), + ctx.Bool("minio-use-ssl"), ) default: return fmt.Errorf("Unsupported attachments store type: %s", ctx.String("store")) diff --git a/custom/conf/app.ini.sample b/custom/conf/app.ini.sample index c8797ca56..e72017215 100644 --- a/custom/conf/app.ini.sample +++ b/custom/conf/app.ini.sample @@ -727,14 +727,32 @@ ENABLE_FEDERATED_AVATAR = false [attachment] ; Whether attachments are enabled. Defaults to `true` ENABLED = true -; Path for attachments. Defaults to `data/attachments` -PATH = data/attachments + ; One or more allowed types, e.g. "image/jpeg|image/png". Use "*/*" for all types. ALLOWED_TYPES = image/jpeg|image/png|application/zip|application/gzip ; Max size of each file. Defaults to 4MB MAX_SIZE = 4 ; Max number of files per upload. Defaults to 5 MAX_FILES = 5 +; Storage type for attachments, `local` for local disk or `minio` for s3 compitable +; object storage service, default is `local`. +STORE_TYPE = local +; Path for attachments. Defaults to `data/attachments` only available when STORE_TYPE is `local` +PATH = data/attachments +; Minio endpoint to connect only available when STORE_TYPE is `minio` +MINIO_ENDPOINT = localhost:9000 +; Minio accessKeyID to connect only available when STORE_TYPE is `minio` +MINIO_ACCESS_KEY_ID = +; Minio secretAccessKey to connect only available when STORE_TYPE is `minio` +MINIO_SECRET_ACCESS_KEY = +; Minio bucket to store the attachments only available when STORE_TYPE is `minio` +MINIO_BUCKET = gitea +; Minio location to create bucket only available when STORE_TYPE is `minio` +MINIO_LOCATION = us-east-1 +; Minio base path on the bucket only available when STORE_TYPE is `minio` +MINIO_BASE_PATH = attachments/ +; Minio enabled ssl only available when STORE_TYPE is `minio` +MINIO_USE_SSL = false [time] ; Specifies the format for fully outputted dates. Defaults to RFC1123 diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 3ad24776f..2f5d29c1a 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -459,11 +459,19 @@ set name for unique queues. Individual queues will default to ## Attachment (`attachment`) - `ENABLED`: **true**: Enable this to allow uploading attachments. -- `PATH`: **data/attachments**: Path to store attachments. - `ALLOWED_TYPES`: **see app.ini.sample**: Allowed MIME types, e.g. `image/jpeg|image/png`. Use `*/*` for all types. - `MAX_SIZE`: **4**: Maximum size (MB). - `MAX_FILES`: **5**: Maximum number of attachments that can be uploaded at once. +- `STORE_TYPE`: **local**: Storage type for attachments, `local` for local disk or `minio` for s3 compitable object storage service, default is `local`. +- `PATH`: **data/attachments**: Path to store attachments only available when STORE_TYPE is `local` +- `MINIO_ENDPOINT`: **localhost:9000**: Minio endpoint to connect only available when STORE_TYPE is `minio` +- `MINIO_ACCESS_KEY_ID`: Minio accessKeyID to connect only available when STORE_TYPE is `minio` +- `MINIO_SECRET_ACCESS_KEY`: Minio secretAccessKey to connect only available when STORE_TYPE is `minio` +- `MINIO_BUCKET`: **gitea**: Minio bucket to store the attachments only available when STORE_TYPE is `minio` +- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when STORE_TYPE is `minio` +- `MINIO_BASE_PATH`: **attachments/**: Minio base path on the bucket only available when STORE_TYPE is `minio` +- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when STORE_TYPE is `minio` ## Log (`log`) diff --git a/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md b/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md index 082944c8a..a11c37c80 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md +++ b/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md @@ -180,10 +180,18 @@ menu: ## Attachment (`attachment`) - `ENABLED`: 是否允许用户上传附件。 -- `PATH`: 附件存储路径 - `ALLOWED_TYPES`: 允许上传的附件类型。比如:`image/jpeg|image/png`,用 `*/*` 表示允许任何类型。 - `MAX_SIZE`: 附件最大限制,单位 MB,比如: `4`。 - `MAX_FILES`: 一次最多上传的附件数量,比如: `5`。 +- `STORE_TYPE`: **local**: 附件存储类型,`local` 将存储到本地文件夹, `minio` 将存储到 s3 兼容的对象存储服务中。 +- `PATH`: **data/attachments**: 附件存储路径,仅当 `STORE_TYPE` 为 `local` 时有效。 +- `MINIO_ENDPOINT`: **localhost:9000**: Minio 终端,仅当 `STORE_TYPE` 是 `minio` 时有效。 +- `MINIO_ACCESS_KEY_ID`: Minio accessKeyID ,仅当 `STORE_TYPE` 是 `minio` 时有效。 +- `MINIO_SECRET_ACCESS_KEY`: Minio secretAccessKey,仅当 `STORE_TYPE` 是 `minio` 时有效。 +- `MINIO_BUCKET`: **gitea**: Minio bucket to store the attachments,仅当 `STORE_TYPE` 是 `minio` 时有效。 +- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket,仅当 `STORE_TYPE` 是 `minio` 时有效。 +- `MINIO_BASE_PATH`: **attachments/**: Minio base path on the bucket,仅当 `STORE_TYPE` 是 `minio` 时有效。 +- `MINIO_USE_SSL`: **false**: Minio enabled ssl,仅当 `STORE_TYPE` 是 `minio` 时有效。 关于 `ALLOWED_TYPES`, 在 (*)unix 系统中可以使用`file -I ` 来快速获得对应的 `MIME type`。