A scheduler/cron job has no topic/queue source key — its identity is the * resource itself, and the binding target is the job's invocation endpoint * (uri / http_target / pubsub_target). Detect such a block by its first label * (resource type, e.g. "google_cloud_scheduler_job") and return the job's * synthetic source name (its second label / resource name), or NULL if the * block is not a sc
| 1901 | * synthetic source name (its second label / resource name), or NULL if the |
| 1902 | * block is not a scheduler job. Sets *broker_out to the scheduler broker id. */ |
| 1903 | static const char *hcl_scheduler_source(CBMExtractCtx *ctx, TSNode block, const char **broker_out) { |
| 1904 | const char *first_label = NULL; |
| 1905 | const char *last_label = NULL; |
| 1906 | uint32_t cc = ts_node_named_child_count(block); |
| 1907 | for (uint32_t i = 0; i < cc; i++) { |
| 1908 | TSNode ch = ts_node_named_child(block, i); |
| 1909 | if (strcmp(ts_node_type(ch), "string_lit") != 0) { |
| 1910 | continue; |
| 1911 | } |
| 1912 | TSNode lit = cbm_find_child_by_kind(ch, "template_literal"); |
| 1913 | if (ts_node_is_null(lit)) { |
| 1914 | continue; |
| 1915 | } |
| 1916 | char *label = cbm_node_text(ctx->arena, lit, ctx->source); |
| 1917 | if (!label || !label[0]) { |
| 1918 | continue; |
| 1919 | } |
| 1920 | if (!first_label) { |
| 1921 | first_label = label; |
| 1922 | } |
| 1923 | last_label = label; |
| 1924 | } |
| 1925 | if (!first_label) { |
| 1926 | return NULL; |
| 1927 | } |
| 1928 | /* google_cloud_scheduler_job, aws_cloudwatch_event_rule (cron), etc. */ |
| 1929 | if (strstr(first_label, "scheduler") || strstr(first_label, "schedule") || |
| 1930 | strstr(first_label, "cron")) { |
| 1931 | if (broker_out) { |
| 1932 | *broker_out = "cloud_scheduler"; |
| 1933 | } |
| 1934 | return last_label ? last_label : first_label; |
| 1935 | } |
| 1936 | return NULL; |
| 1937 | } |
| 1938 | |
| 1939 | static void scan_hcl_block_for_bindings(CBMExtractCtx *ctx, TSNode block) { |
| 1940 | const char *sources[MAX_INFRA_BINDINGS] = {NULL}; |
no test coverage detected