From 9e5ecb5515b2a65101d25a08319651f54dd245e1 Mon Sep 17 00:00:00 2001 From: Matthias Gatto Date: Thu, 16 Jun 2022 13:02:31 +0000 Subject: [PATCH] support OSC_ENDPOINT_API Signed-off-by: Matthias Gatto --- lib.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib.c b/lib.c index 67995a5..a018fb0 100644 --- a/lib.c +++ b/lib.c @@ -81,18 +81,24 @@ int osc_init_sdk(struct osc_env *e, unsigned int flag) { char ak_sk[AK_SIZE + SK_SIZE + 2]; char *ca = getenv("CURL_CA_BUNDLE"); + char *endpoint; e->ak = getenv("OSC_ACCESS_KEY"); e->sk = getenv("OSC_SECRET_KEY"); e->region = getenv("OSC_REGION"); + endpoint = getenv("OSC_ENDPOINT_API"); osc_init_str(&e->endpoint); if (!e->region) e->region = "eu-west-2"; - osc_str_append_string(&e->endpoint, "https://api."); - osc_str_append_string(&e->endpoint, e->region); - osc_str_append_string(&e->endpoint, ".outscale.com"); + if (!endpoint) { + osc_str_append_string(&e->endpoint, "https://api."); + osc_str_append_string(&e->endpoint, e->region); + osc_str_append_string(&e->endpoint, ".outscale.com"); + } else { + osc_str_append_string(&e->endpoint, endpoint); + } if (!e->ak || !e->sk) { fprintf(stderr, "OSC_ACCESS_KEY and OSC_SECRET_KEY needed\n");