Skip to content

Commit 026c7b3

Browse files
committed
Fix
1 parent c15788b commit 026c7b3

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

contrib/pg_tde/src/keyring/keyring_vault.c

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ typedef enum
3333
JRESP_EXPECT_KEY
3434
} JsonVaultRespSemState;
3535

36-
typedef enum // TODO
36+
typedef enum
3737
{
3838
JRESP_MOUNT_INFO_EXPECT_TOPLEVEL_FIELD,
3939
JRESP_MOUNT_INFO_EXPECT_TYPE_VALUE,
@@ -64,8 +64,8 @@ typedef struct JsonVaultMountInfoState
6464
JsonVaultRespMountInfoSemState state;
6565
int level;
6666

67-
char *type;
68-
char *version;
67+
char *type;
68+
char *version;
6969
} JsonVaultMountInfoState;
7070

7171
static JsonParseErrorType json_resp_object_start(void *state);
@@ -314,9 +314,9 @@ static void
314314
validate(GenericKeyring *keyring)
315315
{
316316
VaultV2Keyring *vault_keyring = (VaultV2Keyring *) keyring;
317-
char url[VAULT_URL_MAX_LEN];
318-
CurlString str;
319-
long httpCode = 0;
317+
char url[VAULT_URL_MAX_LEN];
318+
CurlString str;
319+
long httpCode = 0;
320320
JsonParseErrorType json_error;
321321
JsonLexContext *jlex = NULL;
322322
JsonVaultMountInfoState parse;
@@ -325,40 +325,35 @@ validate(GenericKeyring *keyring)
325325

326326
if (!curl_perform(vault_keyring, url, &str, &httpCode, NULL))
327327
{
328-
ereport(WARNING,
328+
ereport(ERROR,
329329
errmsg("HTTP(S) request to keyring provider \"%s\" failed",
330-
vault_keyring->keyring.provider_name));
331-
goto cleanup;
330+
vault_keyring->keyring.provider_name));
332331
}
333332

334333
if (httpCode != 200)
335334
{
336-
ereport(WARNING,
335+
ereport(ERROR,
337336
errmsg("Failed to get mount info for \"%s\" at mountpoint \"%s\" (HTTP %ld)",
338-
vault_keyring->vault_url, vault_keyring->vault_mount_path, httpCode));
339-
goto cleanup;
337+
vault_keyring->vault_url, vault_keyring->vault_mount_path, httpCode));
340338
}
341339

342340
jlex = makeJsonLexContextCstringLen(NULL, str.ptr, str.len, PG_UTF8, true);
343341
json_error = parse_vault_mount_info(&parse, jlex);
344342

345343
if (json_error != JSON_SUCCESS)
346344
{
347-
ereport(WARNING,
345+
ereport(ERROR,
348346
errmsg("Failed to parse mount info for \"%s\" at mountpoint \"%s\": %s",
349-
vault_keyring->vault_url, vault_keyring->vault_mount_path, json_errdetail(json_error, jlex)));
350-
goto cleanup;
347+
vault_keyring->vault_url, vault_keyring->vault_mount_path, json_errdetail(json_error, jlex)));
351348
}
352349

353350
if (strcmp(parse.type, "kv") != 0 || strcmp(parse.version, "2") != 0)
354351
{
355352
ereport(ERROR,
356-
errmsg("Vault mount at '%s' is not a KV version 2 engine (type=kv, version=2 required)",
357-
vault_keyring->vault_mount_path));
358-
goto cleanup;
353+
errmsg("Vault mount at '%s' is not a KV version 2 engine (type=kv, version=2 required)",
354+
vault_keyring->vault_mount_path));
359355
}
360356

361-
cleanup:
362357
if (str.ptr != NULL)
363358
pfree(str.ptr);
364359

@@ -494,7 +489,8 @@ parse_vault_mount_info(JsonVaultMountInfoState *state, JsonLexContext *lex)
494489
return pg_parse_json(lex, &sem);
495490
}
496491

497-
static JsonParseErrorType json_mountinfo_object_start(void *state)
492+
static JsonParseErrorType
493+
json_mountinfo_object_start(void *state)
498494
{
499495
JsonVaultMountInfoState *parse = (JsonVaultMountInfoState *) state;
500496

@@ -513,7 +509,8 @@ static JsonParseErrorType json_mountinfo_object_start(void *state)
513509
return JSON_SUCCESS;
514510
}
515511

516-
static JsonParseErrorType json_mountinfo_object_end(void *state)
512+
static JsonParseErrorType
513+
json_mountinfo_object_end(void *state)
517514
{
518515
JsonVaultMountInfoState *parse = (JsonVaultMountInfoState *) state;
519516

@@ -525,7 +522,8 @@ static JsonParseErrorType json_mountinfo_object_end(void *state)
525522
return JSON_SUCCESS;
526523
}
527524

528-
static JsonParseErrorType json_mountinfo_scalar(void *state, char *token, JsonTokenType tokentype)
525+
static JsonParseErrorType
526+
json_mountinfo_scalar(void *state, char *token, JsonTokenType tokentype)
529527
{
530528
JsonVaultMountInfoState *parse = (JsonVaultMountInfoState *) state;
531529

@@ -547,7 +545,8 @@ static JsonParseErrorType json_mountinfo_scalar(void *state, char *token, JsonTo
547545
return JSON_SUCCESS;
548546
}
549547

550-
static JsonParseErrorType json_mountinfo_object_field_start(void *state, char *fname, bool isnull)
548+
static JsonParseErrorType
549+
json_mountinfo_object_field_start(void *state, char *fname, bool isnull)
551550
{
552551
JsonVaultMountInfoState *parse = (JsonVaultMountInfoState *) state;
553552

0 commit comments

Comments
 (0)