Skip to content

Commit f37b059

Browse files
Parse OBJ endpoint domain dynamically (#851)
1 parent 96a05a4 commit f37b059

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

linodecli/plugins/obj/config.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@
22
The config of the object storage plugin.
33
"""
44

5+
import os
6+
import re
57
import shutil
68

79
ENV_ACCESS_KEY_NAME = "LINODE_CLI_OBJ_ACCESS_KEY"
810
ENV_SECRET_KEY_NAME = "LINODE_CLI_OBJ_SECRET_KEY"
9-
# replace {} with the cluster name
10-
BASE_URL_TEMPLATE = "https://{}.linodeobjects.com"
11-
BASE_WEBSITE_TEMPLATE = "{bucket}.website-{cluster}.linodeobjects.com"
11+
12+
API_HOST = os.getenv("LINODE_CLI_API_HOST", "")
13+
14+
OBJ_DOMAIN = "linodeobjects.com"
15+
16+
if API_HOST:
17+
match = re.match(r"api\.([^.]+)\.linode\.com", API_HOST)
18+
if match:
19+
OBJ_DOMAIN = f"{match.group(1)}.linodeobjects.com"
20+
21+
BASE_URL_TEMPLATE = f"https://{{}}.{OBJ_DOMAIN}"
22+
BASE_WEBSITE_TEMPLATE = f"{{bucket}}.website-{{cluster}}.{OBJ_DOMAIN}"
1223

1324
# for all date output
1425
DATE_FORMAT = "%Y-%m-%d %H:%M"

0 commit comments

Comments
 (0)