MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / hcl_scheduler_source

Function hcl_scheduler_source

internal/cbm/extract_unified.c:1903–1937  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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. */
1903static 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
1939static void scan_hcl_block_for_bindings(CBMExtractCtx *ctx, TSNode block) {
1940 const char *sources[MAX_INFRA_BINDINGS] = {NULL};

Callers 1

Calls 2

cbm_find_child_by_kindFunction · 0.85
cbm_node_textFunction · 0.85

Tested by

no test coverage detected