cloud-setup: mark environment variables that are supported configuration

"nm-cloud-setup" can by configured via environment variables. Mark all the
names of such variables with NMCS_ENV_VARIABLE() macro. This allows to grep
for them.
This commit is contained in:
Thomas Haller 2019-12-03 10:58:31 +01:00
parent ff816dec17
commit 7b24d6e2dc
3 changed files with 13 additions and 4 deletions

View file

@ -594,7 +594,7 @@ main (int argc, const char *const*argv)
gs_unref_object NMClient *nmc = NULL;
gs_unref_hashtable GHashTable *config_dict = NULL;
_nm_logging_enabled_init (g_getenv ("NM_CLOUD_SETUP_LOG"));
_nm_logging_enabled_init (g_getenv (NMCS_ENV_VARIABLE ("NM_CLOUD_SETUP_LOG")));
_LOGD ("nm-cloud-setup %s starting...", NM_DIST_VERSION);

View file

@ -7,6 +7,12 @@
/*****************************************************************************/
/* mark names for variables that can be used as configuration. Search
* for NMCS_ENV_VARIABLE() to find all honored environment variables. */
#define NMCS_ENV_VARIABLE(var) ""var""
/*****************************************************************************/
extern volatile NMLogLevel _nm_logging_configured_level;
static inline gboolean

View file

@ -24,9 +24,12 @@ _ec2_base (void)
again:
base = g_atomic_pointer_get (&base_cached);
if (G_UNLIKELY (!base)) {
/* The base URI can be set via environment variable.
* This is only for testing, not really to be configurable! */
base = g_getenv ("NM_CLOUD_SETUP_EC2_HOST");
* This is mainly for testing, it's not usually supposed to be configured.
* Consider this private API! */
base = g_getenv (NMCS_ENV_VARIABLE ("NM_CLOUD_SETUP_EC2_HOST"));
if ( base
&& base[0]
&& !strchr (base, '/')) {
@ -546,7 +549,7 @@ nmcs_provider_ec2_class_init (NMCSProviderEC2Class *klass)
NMCSProviderClass *provider_class = NMCS_PROVIDER_CLASS (klass);
provider_class->_name = "ec2";
provider_class->_env_provider_enabled = "NM_CLOUD_SETUP_EC2";
provider_class->_env_provider_enabled = NMCS_ENV_VARIABLE ("NM_CLOUD_SETUP_EC2");
provider_class->detect = detect;
provider_class->get_config = get_config;
}