Skip to content

Commit 5f73fa7

Browse files
committed
fix CR comments
1 parent 9462c67 commit 5f73fa7

File tree

3 files changed

+23
-38
lines changed

3 files changed

+23
-38
lines changed

include/fluent-bit/flb_aws_credentials.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
/* 5 second timeout for credential related http requests */
3535
#define FLB_AWS_CREDENTIAL_NET_TIMEOUT 5
3636

37+
/* IoT Credentials Environment Variables */
38+
#define AWS_IOT_KEY_FILE "AWS_IOT_KEY_FILE"
39+
#define AWS_IOT_CERT_FILE "AWS_IOT_CERT_FILE"
40+
#define AWS_IOT_CA_CERT_FILE "AWS_IOT_CA_CERT_FILE"
41+
#define AWS_IOT_CREDENTIALS_ENDPOINT "AWS_IOT_CREDENTIALS_ENDPOINT"
42+
#define AWS_IOT_THING_NAME "AWS_IOT_THING_NAME"
43+
#define AWS_IOT_ROLE_ALIAS "AWS_IOT_ROLE_ALIAS"
44+
3745
/*
3846
* A structure that wraps the sensitive data needed to sign an AWS request
3947
*/

src/aws/flb_aws_credentials.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@
3838

3939
#define EKS_POD_EXECUTION_ROLE "EKS_POD_EXECUTION_ROLE"
4040

41-
/* IoT Credentials Environment Variables */
42-
#define AWS_IOT_KEY_FILE "AWS_IOT_KEY_FILE"
43-
#define AWS_IOT_CERT_FILE "AWS_IOT_CERT_FILE"
44-
#define AWS_IOT_CA_CERT_FILE "AWS_IOT_CA_CERT_FILE"
45-
#define AWS_IOT_CREDENTIALS_ENDPOINT "AWS_IOT_CREDENTIALS_ENDPOINT"
46-
#define AWS_IOT_THING_NAME "AWS_IOT_THING_NAME"
47-
#define AWS_IOT_ROLE_ALIAS "AWS_IOT_ROLE_ALIAS"
48-
4941
/* declarations */
5042
static struct flb_aws_provider *standard_chain_create(struct flb_config
5143
*config,
@@ -59,11 +51,6 @@ static struct flb_aws_provider *standard_chain_create(struct flb_config
5951
int eks_irsa,
6052
char *profile);
6153

62-
/* IoT Provider declaration */
63-
struct flb_aws_provider *flb_iot_provider_create(struct flb_config *config,
64-
struct flb_aws_client_generator *generator);
65-
66-
6754
/*
6855
* The standard credential provider chain:
6956
* 1. Environment variables

src/aws/flb_aws_credentials_iot.c

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,15 @@
2525
#include <fluent-bit/flb_jsmn.h>
2626
#include <fluent-bit/flb_output_plugin.h>
2727
#include <fluent-bit/flb_utils.h>
28+
#include <fluent-bit/flb_log.h>
29+
#include <fluent-bit/flb_mem.h>
2830

2931
#include <stdlib.h>
3032
#include <time.h>
3133
#include <string.h>
3234
#include <sys/types.h>
3335
#include <sys/stat.h>
3436

35-
/* IoT Credentials Environment Variables */
36-
#define AWS_IOT_KEY_FILE "AWS_IOT_KEY_FILE"
37-
#define AWS_IOT_CERT_FILE "AWS_IOT_CERT_FILE"
38-
#define AWS_IOT_CA_CERT_FILE "AWS_IOT_CA_CERT_FILE"
39-
#define AWS_IOT_CREDENTIALS_ENDPOINT "AWS_IOT_CREDENTIALS_ENDPOINT"
40-
#define AWS_IOT_THING_NAME "AWS_IOT_THING_NAME"
41-
#define AWS_IOT_ROLE_ALIAS "AWS_IOT_ROLE_ALIAS"
42-
4337
/* IoT Provider */
4438
struct flb_aws_provider_iot {
4539
struct flb_aws_credentials *creds;
@@ -377,22 +371,18 @@ struct flb_aws_provider *flb_iot_provider_create(struct flb_config *config,
377371
implementation->client->static_headers = &implementation->thing_name_header;
378372
implementation->client->static_headers_len = 1;
379373

380-
/* Clean up temporary variables */
381-
flb_sds_destroy(protocol);
382-
flb_sds_destroy(host);
383-
flb_sds_destroy(port_sds);
384-
flb_sds_destroy(endpoint_path);
385-
386-
return provider;
387-
388-
error:
389-
flb_aws_provider_destroy(provider);
390-
flb_sds_destroy(protocol);
391-
flb_sds_destroy(host);
392-
flb_sds_destroy(port_sds);
393-
flb_sds_destroy(endpoint_path);
394-
return NULL;
395-
}
374+
goto cleanup; // At the end of the func
375+
error:
376+
flb_aws_provider_destroy(provider);
377+
provider = NULL;
378+
// if no return it just keep executing :)
379+
cleanup:
380+
flb_sds_destroy(protocol);
381+
flb_sds_destroy(host);
382+
flb_sds_destroy(port_sds);
383+
flb_sds_destroy(endpoint_path);
384+
return provider;
385+
}
396386

397387
static int iot_credentials_request(struct flb_aws_provider_iot *implementation)
398388
{
@@ -648,4 +638,4 @@ static struct flb_aws_credentials *flb_parse_iot_credentials(char *response, siz
648638
flb_aws_credentials_destroy(creds);
649639
flb_free(tokens);
650640
return NULL;
651-
}
641+
}

0 commit comments

Comments
 (0)