Skip to content

Commit 7cf740c

Browse files
committed
out_stackdriver: abort initialization if 'project_id' is not set
Signed-off-by: Eduardo Silva <[email protected]>
1 parent a8f9e4a commit 7cf740c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

plugins/out_stackdriver/stackdriver.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ static struct mk_list *parse_local_resource_id_to_list(char *local_resource_id,
363363
return list;
364364
}
365365

366-
/*
366+
/*
367367
* extract_local_resource_id():
368368
* - extract the value from "logging.googleapis.com/local_resource_id" field
369369
* - if local_resource_id is missing from the payLoad, use the tag of the log
@@ -415,7 +415,7 @@ static int extract_local_resource_id(const void *data, size_t bytes,
415415
return 0;
416416
}
417417

418-
/*
418+
/*
419419
* process_local_resource_id():
420420
* - use the extracted local_resource_id to assign the label keys for different
421421
* resource types that are specified in the configuration of stackdriver_out plugin
@@ -563,7 +563,7 @@ static int process_local_resource_id(struct flb_stackdriver *ctx, char *type)
563563
flb_slist_destroy(list);
564564
flb_free(list);
565565
}
566-
566+
567567
return ret;
568568

569569
error:
@@ -682,6 +682,12 @@ static int cb_stackdriver_init(struct flb_output_instance *ins,
682682
}
683683
}
684684

685+
/* Validate project_id */
686+
if (!ctx->project_id) {
687+
flb_plg_error(ctx->ins, "property 'project_id' is not set");
688+
return -1;
689+
}
690+
685691
return 0;
686692
}
687693

0 commit comments

Comments
 (0)