static void test_cascade(void) { struct dm_config_tree *t1 = dm_config_from_string(conf), *t2 = dm_config_from_string(overlay), *tree = dm_config_insert_cascaded_tree(t2, t1); CU_ASSERT(!strcmp(dm_config_tree_find_str(tree, "id", "foo"), "yoda-soda")); CU_ASSERT(!strcmp(dm_config_tree_find_str(tree, "idt", "foo"), "foo")); CU_ASSERT(!strcmp(dm_config_tree_find_str(tree, "physical_volumes/pv0/bb", "foo"), "foo")); CU_ASSERT(!strcmp(dm_config_tree_find_str(tree, "physical_volumes/pv1/id", "foo"), "hgfe-dcba")); CU_ASSERT(!strcmp(dm_config_tree_find_str(tree, "physical_volumes/pv3/id", "foo"), "dbcd-efgh")); dm_config_destroy(t1); dm_config_destroy(t2); }
const char *find_config_tree_str(struct cmd_context *cmd, int id, struct profile *profile) { cfg_def_item_t *item = cfg_def_get_item_p(id); const char *path; int profile_applied = 0; const char *str; if (profile && !cmd->profile_params->global_profile) profile_applied = override_config_tree_from_profile(cmd, profile); path = cfg_def_get_path(item); if (item->type != CFG_TYPE_STRING) log_error(INTERNAL_ERROR "%s cfg tree element not declared as string.", path); str = dm_config_tree_find_str(cmd->cft, path, cfg_def_get_default_value(item, CFG_TYPE_STRING)); if (profile_applied) remove_config_tree_by_source(cmd, CONFIG_PROFILE); return str; }
const char *find_config_tree_str(struct cmd_context *cmd, const char *path, const char *fail) { return dm_config_tree_find_str(cmd->cft, path, fail); }