fix: fix various issues before merging
This commit is contained in:
@@ -64,6 +64,9 @@ def resolve_image_storage_key(image: dict | None) -> str | None:
|
||||
|
||||
|
||||
class TencentCosStorageService:
|
||||
_instance: "TencentCosStorageService | None" = None
|
||||
_instance_config: tuple[str, str, str, str, str] | None = None
|
||||
|
||||
def __init__(self, secret_id: str, secret_key: str, region: str, bucket: str, base_url: str):
|
||||
self.secret_id = secret_id
|
||||
self.secret_key = secret_key
|
||||
@@ -91,10 +94,20 @@ class TencentCosStorageService:
|
||||
|
||||
@classmethod
|
||||
def from_env(cls) -> "TencentCosStorageService":
|
||||
return cls(
|
||||
secret_id=os.getenv("TENCENT_COS_SECRET_ID", ""),
|
||||
secret_key=os.getenv("TENCENT_COS_SECRET_KEY", ""),
|
||||
region=os.getenv("TENCENT_COS_REGION", ""),
|
||||
bucket=os.getenv("TENCENT_COS_BUCKET", ""),
|
||||
base_url=os.getenv("TENCENT_COS_BASE_URL", ""),
|
||||
config = (
|
||||
os.getenv("TENCENT_COS_SECRET_ID", ""),
|
||||
os.getenv("TENCENT_COS_SECRET_KEY", ""),
|
||||
os.getenv("TENCENT_COS_REGION", ""),
|
||||
os.getenv("TENCENT_COS_BUCKET", ""),
|
||||
os.getenv("TENCENT_COS_BASE_URL", ""),
|
||||
)
|
||||
if cls._instance is None or cls._instance_config != config:
|
||||
cls._instance = cls(
|
||||
secret_id=config[0],
|
||||
secret_key=config[1],
|
||||
region=config[2],
|
||||
bucket=config[3],
|
||||
base_url=config[4],
|
||||
)
|
||||
cls._instance_config = config
|
||||
return cls._instance
|
||||
|
||||
Reference in New Issue
Block a user