From 63c24df9d900d4f15e0e2e42e5e00a88602130be Mon Sep 17 00:00:00 2001 From: Gary Date: Thu, 14 Nov 2024 22:08:33 +0800 Subject: [PATCH] feat(blob): add domain in objecturl (#130) Because for easy usage of our blob service, object url needs the domain This commit add the domain in url --- config/config.go | 5 +++++ config/config.yaml | 2 ++ pkg/service/object.go | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 767393f..62ddf8b 100644 --- a/config/config.go +++ b/config/config.go @@ -31,6 +31,7 @@ type AppConfig struct { Minio MinioConfig `koanf:"minio"` Milvus MilvusConfig `koanf:"milvus"` FileToEmbeddingWorker FileToEmbeddingWorker `koanf:"filetoembeddingworker"` + Blob BlobConfig `koanf:"blob"` } // OpenFGA config @@ -159,6 +160,10 @@ type FileToEmbeddingWorker struct { NumberOfWorkers int `koanf:"numberofworkers"` } +type BlobConfig struct { + HostPort string `koanf:"hostport"` +} + // Init - Assign global config to decoded config struct func Init() error { k := koanf.New(".") diff --git a/config/config.yaml b/config/config.yaml index 7c57bb9..e6cddb4 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -76,3 +76,5 @@ milvus: port: 19530 filetoembeddingworker: numberofworkers: 2 +blob: + hostport: http://localhost:8080 diff --git a/pkg/service/object.go b/pkg/service/object.go index c6cc36d..5ebace7 100644 --- a/pkg/service/object.go +++ b/pkg/service/object.go @@ -10,6 +10,7 @@ import ( "github.com/gofrs/uuid" "github.com/gogo/status" + "github.com/instill-ai/artifact-backend/config" "github.com/instill-ai/artifact-backend/pkg/logger" minio_local "github.com/instill-ai/artifact-backend/pkg/minio" "github.com/instill-ai/artifact-backend/pkg/repository" @@ -228,7 +229,7 @@ func EncodedMinioURLPath(namespaceID string, objectURLUUID uuid.UUID) string { urlPath := path.Join("v1alpha", "namespaces", namespaceID, "blob-urls", objectURLUUID.String()) // Ensure the path starts with a forward slash - return "/" + urlPath + return config.Config.Blob.HostPort + "/" + urlPath } // DecodeMinioURLPath decodes the minio URL path into namespaceID and objectName