The QN and properties of the Resource named `name` after indexing `files`; * false when there is no such node or it is not unique. */
| 770 | /* The QN and properties of the Resource named `name` after indexing `files`; |
| 771 | * false when there is no such node or it is not unique. */ |
| 772 | static bool gpf_resource(const GpfFile *files, int nfiles, const char *name, char *qn, |
| 773 | size_t qn_sz, char *props, size_t props_sz) { |
| 774 | GpfProj lp; |
| 775 | cbm_store_t *store = gpf_index_files(&lp, files, nfiles); |
| 776 | bool found = false; |
| 777 | int hits = 0; |
| 778 | cbm_node_t *nodes = NULL; |
| 779 | int count = 0; |
| 780 | if (store && |
| 781 | cbm_store_find_nodes_by_label(store, lp.project, "Resource", &nodes, &count) == |
| 782 | CBM_STORE_OK) { |
| 783 | for (int i = 0; i < count; i++) { |
| 784 | if (nodes[i].name && strcmp(nodes[i].name, name) == 0) { |
| 785 | hits++; |
| 786 | const char *q = nodes[i].qualified_name ? nodes[i].qualified_name : ""; |
| 787 | const char *sep = strstr(q, "::"); |
| 788 | snprintf(qn, qn_sz, "%s", sep ? sep : q); /* the part after the file base */ |
| 789 | snprintf(props, props_sz, "%s", |
| 790 | nodes[i].properties_json ? nodes[i].properties_json : "{}"); |
| 791 | } |
| 792 | } |
| 793 | cbm_store_free_nodes(nodes, count); |
| 794 | found = hits == 1; |
| 795 | } |
| 796 | gpf_cleanup(&lp, store); |
| 797 | return found; |
| 798 | } |
| 799 | |
| 800 | /* A multi-document manifest is a list of objects: kubernetes-sigs and |
| 801 | * microservices-demo ship a Deployment and its Service in one file, and |
no test coverage detected