Skip to content

Commit 00629f0

Browse files
committed
feat: support config storage for repository
1 parent c25be11 commit 00629f0

File tree

10 files changed

+268
-95
lines changed

10 files changed

+268
-95
lines changed

api/jiaozifs.gen.go

Lines changed: 60 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger.yml

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ components:
177177
type: string
178178
Name:
179179
type: string
180+
BlockStoreConfig:
181+
description: block storage config url encoded json
182+
type: string
183+
180184
UpdateRepository:
181185
type: object
182186
properties:
@@ -472,7 +476,6 @@ components:
472476
type: object
473477
additionalProperties:
474478
type: string
475-
476479
ObjectStats:
477480
type: object
478481
required:
@@ -500,7 +503,6 @@ components:
500503
content_type:
501504
type: string
502505
description: Object media type
503-
504506
ObjectStatsList:
505507
type: object
506508
required:
@@ -513,7 +515,93 @@ components:
513515
type: array
514516
items:
515517
$ref: "#/components/schemas/ObjectStats"
516-
518+
BlockStoreConfig:
519+
type: object
520+
properties:
521+
Type:
522+
type: string
523+
description: type of support storage type
524+
enum: [ "local", "gs", "azure", "s3" ]
525+
DefaultNamespacePrefix:
526+
type: string
527+
Local:
528+
type: object
529+
required:
530+
- Path
531+
properties:
532+
Path:
533+
type: string
534+
Azure:
535+
type: object
536+
required:
537+
- StorageAccount
538+
- StorageAccessKey
539+
- TryTimeout
540+
properties:
541+
StorageAccessKey:
542+
type: string
543+
StorageAccount:
544+
type: string
545+
TryTimeout:
546+
type: integer
547+
format: int64
548+
GS:
549+
type: object
550+
required:
551+
- CredentialsJSON
552+
- S3Endpoint
553+
properties:
554+
CredentialsJSON:
555+
type: string
556+
S3Endpoint:
557+
type: string
558+
S3:
559+
type: object
560+
required:
561+
- Credentials
562+
- DiscoverBucketRegion
563+
- Region
564+
- Endpoint
565+
properties:
566+
Credentials:
567+
$ref: '#/components/schemas/Credential'
568+
WebIdentity:
569+
$ref: '#/components/schemas/WebIdentity'
570+
DiscoverBucketRegion:
571+
type: boolean
572+
Endpoint:
573+
type: string
574+
ForcePathStyle:
575+
type: boolean
576+
Region:
577+
type: string
578+
WebIdentity:
579+
properties:
580+
SessionDuration:
581+
type: integer
582+
format: int64
583+
SessionExpiryWindow:
584+
type: integer
585+
format: int64
586+
S3AuthInfo:
587+
type: object
588+
description: S3AuthInfo holds S3-style authentication.
589+
properties:
590+
Credentials:
591+
$ref: '#/components/schemas/Credential'
592+
CredentialsFile:
593+
type: string
594+
Credential:
595+
type: object
596+
properties:
597+
AccessKeyID:
598+
$ref: '#/components/schemas/SecureString'
599+
SecretAccessKey:
600+
$ref: '#/components/schemas/SecureString'
601+
SessionToken:
602+
$ref: '#/components/schemas/SecureString'
603+
SecureString:
604+
type: string
517605
Pagination:
518606
type: object
519607
required:
@@ -536,7 +624,6 @@ components:
536624
type: integer
537625
minimum: 0
538626
description: Maximal number of entries per page
539-
540627
Error:
541628
type: object
542629
required:

block/factory/build.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const (
2626
googleAuthCloudPlatform = "https://www.googleapis.com/auth/cloud-platform"
2727
)
2828

29+
type BlockAdapterBuilder = func(context.Context, params.AdapterConfig) (block.Adapter, error)
30+
2931
func BuildBlockAdapter(ctx context.Context, c params.AdapterConfig) (block.Adapter, error) {
3032
blockstore := c.BlockstoreType()
3133
log.With("type", blockstore).

cmd/daemon.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ var daemonCmd = &cobra.Command{
5858
fx_opt.Override(new(*config.DatabaseConfig), &cfg.Database),
5959
fx_opt.Override(new(params.AdapterConfig), &cfg.Blockstore),
6060
//blockstore
61+
fx_opt.Override(new(factory.BlockAdapterBuilder), factory.BuildBlockAdapter),
6162
fx_opt.Override(new(block.Adapter), factory.BuildBlockAdapter),
6263
//database
6364
fx_opt.Override(new(*bun.DB), models.SetupDatabase),

config/default.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package config
22

33
import (
44
"encoding/hex"
5-
6-
"github.com/jiaozifs/jiaozifs/utils"
75
)
86

97
var DefaultLocalBSPath = "~/.jiaozifs/blockstore"
@@ -17,8 +15,7 @@ var defaultCfg = Config{
1715
Listen: "http://127.0.0.1:34913",
1816
},
1917
Blockstore: BlockStoreConfig{
20-
Type: "local",
21-
DefaultNamespacePrefix: utils.String("data"),
18+
Type: "local",
2219
Local: (*struct {
2320
Path string `mapstructure:"path"`
2421
ImportEnabled bool `mapstructure:"import_enabled"`

0 commit comments

Comments
 (0)