new environment variable file feature
parent
3591bd344d
commit
722688ebf3
|
@ -3,5 +3,6 @@
|
||||||
"execution_context": "/home/phanes/development/internal/Examplar/conf/",
|
"execution_context": "/home/phanes/development/internal/Examplar/conf/",
|
||||||
"units_path": "units/all_test.units",
|
"units_path": "units/all_test.units",
|
||||||
"plan_path": "plans/test.plan",
|
"plan_path": "plans/test.plan",
|
||||||
"config_version": "2"
|
"config_version": "3",
|
||||||
|
"env_vars_file": "Examplar.variables"
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,14 @@ Conf::Conf( std::string filename, bool verbose ): JSON_Loader()
|
||||||
} else {
|
} else {
|
||||||
this->execution_context_literal = this->execution_context.asString();
|
this->execution_context_literal = this->execution_context.asString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( this->get_serialized(this->env_vars_file, "env_vars_file", true) != 0 )
|
||||||
|
{
|
||||||
|
throw ConfigLoadException("env_vars_file is not set in the config file supplied: " + filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Conf::has_context_override - Specifies whether or not the override context function is enabled in the conf file.
|
/// Conf::has_context_override - Specifies whether or not the override context function is enabled in the conf file.
|
||||||
|
@ -138,3 +146,8 @@ void Conf::set_execution_context( std::string execution_context )
|
||||||
{
|
{
|
||||||
this->execution_context_literal = execution_context;
|
this->execution_context_literal = execution_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Conf::get_env_vars_file()
|
||||||
|
{
|
||||||
|
return this->env_vars_file.asString();
|
||||||
|
}
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#define STRINGIZE2(s) #s
|
#define STRINGIZE2(s) #s
|
||||||
#define STRINGIZE(s) STRINGIZE2(s)
|
#define STRINGIZE(s) STRINGIZE2(s)
|
||||||
# define IMPL_CONFIG_VERSION 2
|
# define IMPL_CONFIG_VERSION 3
|
||||||
# define VERSION_STRING STRINGIZE(IMPL_CONFIG_VERSION)
|
# define VERSION_STRING STRINGIZE(IMPL_CONFIG_VERSION)
|
||||||
|
|
||||||
class Conf: public JSON_Loader
|
class Conf: public JSON_Loader
|
||||||
|
@ -36,6 +36,7 @@ private:
|
||||||
Json::Value units_path;
|
Json::Value units_path;
|
||||||
Json::Value execution_context;
|
Json::Value execution_context;
|
||||||
Json::Value config_version;
|
Json::Value config_version;
|
||||||
|
Json::Value env_vars_file;
|
||||||
|
|
||||||
// flag to indicate if execution context should be overriden in config file
|
// flag to indicate if execution context should be overriden in config file
|
||||||
// if set to true Examplar should use whats in the config file for current working directory
|
// if set to true Examplar should use whats in the config file for current working directory
|
||||||
|
@ -53,8 +54,11 @@ public:
|
||||||
bool has_context_override();
|
bool has_context_override();
|
||||||
|
|
||||||
std::string get_execution_context();
|
std::string get_execution_context();
|
||||||
|
|
||||||
void set_execution_context( std::string );
|
void set_execution_context( std::string );
|
||||||
|
|
||||||
|
std::string get_env_vars_file();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //FTESTS_CONF_H
|
#endif //FTESTS_CONF_H
|
||||||
|
|
|
@ -200,11 +200,12 @@ void Task::execute( Conf * configuration, bool verbose )
|
||||||
// if we're in verbose mode, do some verbose things
|
// if we're in verbose mode, do some verbose things
|
||||||
if ( verbose )
|
if ( verbose )
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
infostring = std::ostringstream();
|
infostring = std::ostringstream();
|
||||||
infostring << "\tUsing unit \"" << task_name << "\"." << std::endl;
|
infostring << "\tUsing unit \"" << task_name << "\"." << std::endl;
|
||||||
syslog( LOG_INFO, infostring.str().c_str() );
|
syslog( LOG_INFO, infostring.str().c_str() );
|
||||||
std::cout << infostring.str();
|
std::cout << infostring.str();
|
||||||
|
*/
|
||||||
|
|
||||||
// check if context override
|
// check if context override
|
||||||
if ( configuration->has_context_override() )
|
if ( configuration->has_context_override() )
|
||||||
|
@ -224,7 +225,8 @@ void Task::execute( Conf * configuration, bool verbose )
|
||||||
}
|
}
|
||||||
|
|
||||||
// a[0] execute target
|
// a[0] execute target
|
||||||
int return_code = Sproc::execute( target_command );
|
// TODO revise variable sourcing strategy
|
||||||
|
int return_code = Sproc::execute( "source " + configuration->get_env_vars_file() + " && " + target_command );
|
||||||
|
|
||||||
// **********************************************
|
// **********************************************
|
||||||
// d[0] Error Code Check
|
// d[0] Error Code Check
|
||||||
|
|
Loading…
Reference in New Issue