3
0

Improve store & bucket path handling

This commit is contained in:
Denis Arh
2020-03-05 10:10:57 +01:00
parent 86fcfff237
commit 0c9c67e34c
6 changed files with 22 additions and 18 deletions

View File

@@ -15,9 +15,7 @@ RUN apk add --no-cache ca-certificates
COPY --from=builder /tmp/corteza-server /bin
ENV COMPOSE_STORAGE_PATH /data/compose
ENV MESSAGING_STORAGE_PATH /data/messaging
ENV SYSTEM_STORAGE_PATH /data/system
ENV STORAGE_PATH /data
ENV CORREDOR_ADDR corredor:80

View File

@@ -15,7 +15,7 @@ RUN apk add --no-cache ca-certificates
COPY --from=builder /tmp/corteza-server-compose /bin
ENV COMPOSE_STORAGE_PATH /data/compose
ENV STORAGE_PATH /data
ENV CORREDOR_ADDR corredor:80
VOLUME /data

View File

@@ -15,7 +15,7 @@ RUN apk add --no-cache ca-certificates
COPY --from=builder /tmp/corteza-server-messaging /bin
ENV MESSAGING_STORAGE_PATH /data/messaging
ENV STORAGE_PATH /data
ENV CORREDOR_ADDR corredor:80
VOLUME /data

View File

@@ -15,7 +15,7 @@ RUN apk add --no-cache ca-certificates
COPY --from=builder /tmp/corteza-server-system /bin
ENV SYSTEM_STORAGE_PATH /data/system
ENV STORAGE_PATH /data
ENV CORREDOR_ADDR corredor:80
VOLUME /data

View File

@@ -87,12 +87,14 @@ func Initialize(ctx context.Context, log *zap.Logger, c Config) (err error) {
)
if DefaultStore == nil {
const svcPath = "compose"
if c.Storage.MinioEndpoint != "" {
if c.Storage.MinioBucket == "" {
c.Storage.MinioBucket = "compose"
var bucket = svcPath
if c.Storage.MinioBucket != "" {
bucket = c.Storage.MinioBucket + "/" + svcPath
}
DefaultStore, err = minio.New(c.Storage.MinioBucket, minio.Options{
DefaultStore, err = minio.New(bucket, minio.Options{
Endpoint: c.Storage.MinioEndpoint,
Secure: c.Storage.MinioSecure,
Strict: c.Storage.MinioStrict,
@@ -103,13 +105,14 @@ func Initialize(ctx context.Context, log *zap.Logger, c Config) (err error) {
})
log.Info("initializing minio",
zap.String("bucket", c.Storage.MinioBucket),
zap.String("bucket", bucket),
zap.String("endpoint", c.Storage.MinioEndpoint),
zap.Error(err))
} else {
DefaultStore, err = plain.New(c.Storage.Path)
path := c.Storage.Path + "/" + svcPath
DefaultStore, err = plain.New(path)
log.Info("initializing store",
zap.String("path", c.Storage.Path),
zap.String("path", path),
zap.Error(err))
}

View File

@@ -72,12 +72,14 @@ func Initialize(ctx context.Context, log *zap.Logger, c Config) (err error) {
)
if DefaultStore == nil {
const svcPath = "messaging"
if c.Storage.MinioEndpoint != "" {
if c.Storage.MinioBucket == "" {
c.Storage.MinioBucket = "messaging"
var bucket = svcPath
if c.Storage.MinioBucket != "" {
bucket = c.Storage.MinioBucket + "/" + svcPath
}
DefaultStore, err = minio.New(c.Storage.MinioBucket, minio.Options{
DefaultStore, err = minio.New(bucket, minio.Options{
Endpoint: c.Storage.MinioEndpoint,
Secure: c.Storage.MinioSecure,
Strict: c.Storage.MinioStrict,
@@ -88,14 +90,15 @@ func Initialize(ctx context.Context, log *zap.Logger, c Config) (err error) {
})
log.Info("initializing minio",
zap.String("bucket", c.Storage.MinioBucket),
zap.String("bucket", bucket),
zap.String("endpoint", c.Storage.MinioEndpoint),
zap.Error(err))
} else {
DefaultStore, err = plain.New(c.Storage.Path)
path := c.Storage.Path + "/" + svcPath
DefaultStore, err = plain.New(path)
log.Info("initializing store",
zap.String("path", c.Storage.Path),
zap.String("path", path),
zap.Error(err))
}