From 0c9c67e34c2ba2a7bcd3d0159877e56fd6fe960b Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Thu, 5 Mar 2020 10:10:57 +0100 Subject: [PATCH] Improve store & bucket path handling --- Dockerfile.corteza-server | 4 +--- Dockerfile.corteza-server-compose | 2 +- Dockerfile.corteza-server-messaging | 2 +- Dockerfile.corteza-server-system | 2 +- compose/service/service.go | 15 +++++++++------ messaging/service/service.go | 15 +++++++++------ 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Dockerfile.corteza-server b/Dockerfile.corteza-server index 51cd0c2f9..7c7df5ee0 100644 --- a/Dockerfile.corteza-server +++ b/Dockerfile.corteza-server @@ -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 diff --git a/Dockerfile.corteza-server-compose b/Dockerfile.corteza-server-compose index 6b5a1cc4e..095cb8e32 100644 --- a/Dockerfile.corteza-server-compose +++ b/Dockerfile.corteza-server-compose @@ -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 diff --git a/Dockerfile.corteza-server-messaging b/Dockerfile.corteza-server-messaging index b5136b2b3..d8e0e6a75 100644 --- a/Dockerfile.corteza-server-messaging +++ b/Dockerfile.corteza-server-messaging @@ -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 diff --git a/Dockerfile.corteza-server-system b/Dockerfile.corteza-server-system index c0770fda9..6b87eefe1 100644 --- a/Dockerfile.corteza-server-system +++ b/Dockerfile.corteza-server-system @@ -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 diff --git a/compose/service/service.go b/compose/service/service.go index f3796d974..1d6c5efa7 100644 --- a/compose/service/service.go +++ b/compose/service/service.go @@ -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)) } diff --git a/messaging/service/service.go b/messaging/service/service.go index 08a5913ca..95937f6dd 100644 --- a/messaging/service/service.go +++ b/messaging/service/service.go @@ -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)) }