feat: add load_primary_config(), myconf_fini(); remove static cf global from myconf.c
- load_primary_config(): resolves conf/current, reads raw bytes, computes SHA-256 tag, decodes Cap'n Proto via load_cluster_config_from_file(), checks reserved names, sets config_generation, checks staleness - myconf_fini(): frees conffile and cluster_config (calls free_ClusterConfig) - Remove static cf global from myconf.c; get_default_conf() now uses a local struct cluster_configuration* via load_cluster_config() - Add load_primary_config_for_test() under XCE_TESTING in config_repl.c to test path resolution without triggering FATAL - Add xce/cluster_def.h include to config_repl.c and test_config_repl.c so cluster_t is complete when XCE_TESTING is active - TDD: test_load_primary_config_missing_returns_error passes (18/18)
This commit is contained in:
parent
ce62406f2c
commit
cd02cf40d2
4 changed files with 192 additions and 7 deletions
|
|
@ -19,6 +19,7 @@
|
|||
#include "byteorder.h"
|
||||
#include "clusterconfig.h"
|
||||
#include "utils.h"
|
||||
#include "xce/cluster_def.h"
|
||||
|
||||
/* ── internal helpers ──────────────────────────── */
|
||||
|
||||
|
|
@ -364,6 +365,29 @@ int config_contains_reserved_name(cluster_config_t *cfg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* ── load_primary_config_for_test ───────────────── */
|
||||
|
||||
#ifdef XCE_TESTING
|
||||
int load_primary_config_for_test(cluster_t *c)
|
||||
{
|
||||
myconf_t *myconf = c->myconf;
|
||||
char conf_dir[4096];
|
||||
snprintf(conf_dir, sizeof(conf_dir), "%s/%s", myconf->workdir, myconf->name);
|
||||
|
||||
char fname[256] = {0};
|
||||
int rc = conf_read_current_filename(conf_dir, fname, sizeof(fname));
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
free(myconf->conffile);
|
||||
myconf->conffile = NULL;
|
||||
if (asprintf(&myconf->conffile, "%s/conf/%s", conf_dir, fname) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ── sanitise_cn ────────────────────────────────── */
|
||||
|
||||
char *sanitise_cn(const char *src, size_t maxlen)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue