Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

out_blob: consider auto_create_container #9457

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion plugins/out_azure_blob/azure_blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,9 @@ static int create_container(struct flb_azure_blob *ctx, char *name)
/*
* Check that the container exists, if it doesn't and the configuration property
* auto_create_container is enabled, it will send a request to create it. If it
* could not be created or auto_create_container is disabled, it returns FLB_FALSE.
* could not be created, it returns FLB_FALSE.
* If auto_create_container is disabled, it will return FLB_TRUE assuming the container
* already exists.
*/
static int ensure_container(struct flb_azure_blob *ctx)
{
Expand All @@ -528,8 +530,15 @@ static int ensure_container(struct flb_azure_blob *ctx)
struct flb_http_client *c;
struct flb_connection *u_conn;

if (!ctx->auto_create_container) {
flb_plg_info(ctx->ins, "auto_create_container is disabled, assuming container '%s' already exists",
ctx->container_name);
return FLB_TRUE;
}

uri = azb_uri_ensure_or_create_container(ctx);
if (!uri) {
flb_plg_error(ctx->ins, "cannot create container URI");
return FLB_FALSE;
}

Expand Down Expand Up @@ -582,8 +591,17 @@ static int ensure_container(struct flb_azure_blob *ctx)
return ret;
}
else if (status == 200) {
flb_plg_info(ctx->ins, "container '%s' already exists", ctx->container_name);
return FLB_TRUE;
}
else if (status == 403) {
flb_plg_error(ctx->ins, "failed getting container '%s', access denied",
ctx->container_name);
return FLB_FALSE;
}

flb_plg_error(ctx->ins, "get container request failed, status=%i",
status);

return FLB_FALSE;
}
Expand Down
Loading