#419 Allow to specify config file from cmdline
Opened 4 years ago by jlanda. Modified 4 years ago
taskotron/ jlanda/libtaskotron cmd-config-file  into  develop

file modified
+9 -5
@@ -34,6 +34,8 @@ 

  NS_CONF_FILE = 'namespaces.yaml'

  '''the name of result namespaces configuration file'''

  

+ CMD_CONF_FILE = None

+ 

  PROFILE_VAR = 'TASKOTRON_PROFILE'

  '''environment variable name for setting config profile'''

  
@@ -91,11 +93,13 @@ 

          return config

  

      # load config files

-     filename = _search_dirs(CONF_DIRS, CONF_FILE)

-     if not filename:

-         log.warning(

-             'No config file %s found in dirs: %s' % (CONF_FILE, CONF_DIRS))

-         return config

+     if CMD_CONF_FILE:

+         filename = CMD_CONF_FILE

+     else:

+         filename = _search_dirs(CONF_DIRS, CONF_FILE)

+         if not filename:

+             log.warning('No config file %s found in dirs: %s' % (CONF_FILE, CONF_DIRS))

+             return config

  

      log.debug('Using config file: %s', filename)

      file_config = _load_file(filename)

file modified
+8
@@ -102,6 +102,8 @@ 

                          help="path to private key for remote connections over ssh")

      parser.add_argument("--no-destroy", action="store_true",

                          help="do not destroy disposable client at the end of task execution")

+     parser.add_argument('--config', metavar="</path/to/config.yaml>",

+                         help="alternative taskotron.yaml config file")

  

      return parser

  
@@ -122,6 +124,9 @@ 

          if '@' not in args['ssh']:

              parser.error("SSH connection info not in format 'user@machine' or 'user@machine:port'")

  

+     if args['config']:

+         if not os.path.isfile(args['config']):

+             parser.error('Option --config-file must have an existing file as argument')

  

  def process_args(raw_args):

      """ Processes raw input args and converts them into specific data types that
@@ -137,6 +142,9 @@ 

      # store the original unprocessed args for later use when passing it to the minion

      args['_orig_args'] = raw_args

  

+     if args['config']:

+         config.CMD_CONF_FILE = args['config']

+ 

      # process item + type

      if args['type'] in check.ReportType.list():

          args[args['type']] = args['item']

rebased onto 6903414

4 years ago

Metadata Update from @kparal:
- Request assigned

4 years ago

rebased onto 8042bf1

4 years ago

rebased onto 98349ae

4 years ago

Hi, thanks for the PR, I'm sorry I haven't replied earlier. Taskotron has been recently switched to mostly a maintenance-only mode (that doesn't apply to resultsdb, though), and we won't have too many cycles on adding or reviewing anything but bugfixes. So, we'll get to this eventually, but at the current time (until we're clearer what the future holds), it's better if you avoid submitting PRs against taskotron projects (except resultsdb), because won't be able to review them reasonably fast. Thanks for understanding, and sorry once again for the wait.