Skip to content

Commit 8b53611

Browse files
committed
move variables to beginning
Signed-off-by: Hyunsoo Kim <hsookim@amazon.com>
1 parent 1c0104a commit 8b53611

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

plugins/filter_kubernetes/kubernetes_aws.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,12 @@ int determine_platform(struct flb_kube *ctx)
291291
size_t token_size;
292292
char *payload = NULL;
293293
size_t payload_len;
294-
char *issuer_start, *issuer_end;
294+
char *issuer_start,
295+
char *issuer_end;
296+
char *first_dot,
297+
char *second_dot;
298+
size_t payload_b64_len;
299+
char *payload_b64;
295300

296301
/* Read serviceaccount token */
297302
ret = flb_utils_read_file(FLB_KUBE_TOKEN, &token_buf, &token_size);
@@ -300,21 +305,21 @@ int determine_platform(struct flb_kube *ctx)
300305
}
301306

302307
/* JWT tokens have 3 parts separated by dots: header.payload.signature */
303-
char *first_dot = strchr(token_buf, '.');
308+
first_dot = strchr(token_buf, '.');
304309
if (!first_dot) {
305310
flb_free(token_buf);
306311
return -1;
307312
}
308313

309-
char *second_dot = strchr(first_dot + 1, '.');
314+
second_dot = strchr(first_dot + 1, '.');`
310315
if (!second_dot) {
311316
flb_free(token_buf);
312317
return -1;
313318
}
314319

315320
/* Extract and decode the payload (middle part) */
316-
size_t payload_b64_len = second_dot - (first_dot + 1);
317-
char *payload_b64 = flb_malloc(payload_b64_len + 1);
321+
payload_b64_len = second_dot - (first_dot + 1);
322+
payload_b64 = flb_malloc(payload_b64_len + 1);
318323
if (!payload_b64) {
319324
flb_free(token_buf);
320325
return -1;

0 commit comments

Comments
 (0)