Default --configdir to current working dir

This commit is contained in:
Fred Park 2017-10-03 14:31:33 -07:00
Родитель 796a5e33b4
Коммит 9a6f44a2d1
3 изменённых файлов: 14 добавлений и 7 удалений

Просмотреть файл

@ -42,6 +42,8 @@ guide for more information.
`SHIPYARD_FS_JSON` have been renamed to `SHIPYARD_CREDENTIALS_CONF`,
`SHIPYARD_CONFIG_CONF`, `SHIPYARD_POOL_CONF`, `SHIPYARD_JOBS_CONF`, and
`SHIPYARD_FS_CONF` respectively.
- `--configdir` or `SHIPYARD_CONFIGDIR` now defaults to the current working
directory (i.e., `.`) if no other conf file options are specified.
- `aad` can be specified at a "global" level in the credentials configuration
file, which is then applied to `batch`, `keyvault` and/or `management`
section. Please see the credentials configuration guide for more information.

Просмотреть файл

@ -81,7 +81,8 @@ These options must be specified after the command and sub-command. These are:
as the regular switch option, e.g.,
pool.yaml for --pool. Individually specified
config options take precedence over this
option.
option. This defaults to "." if no other
configuration option is specified.
--credentials TEXT Credentials config file
--config TEXT Global config file
--fs TEXT RemoteFS config file
@ -112,7 +113,9 @@ below if all configuration files are in one directory and named after
their switch. For example, if you have a directory named `config` and under
that directory you have the files `credentials.yaml`, `config.yaml`,
`pool.yaml` and `jobs.yaml`, then you can use this argument instead of the
following:
following individual conf options. If this parameter is not specified or
any of the individual conf options, then this paramter defaults to the
current working directory (i.e., `.`).
* `--credentials path/to/credentials.yaml` is required for all actions
except for a select few `keyvault` commands.
* `--config path/to/config.yaml` is required for all actions.

Просмотреть файл

@ -214,14 +214,15 @@ class CliContext(object):
:return: new configuration file path
"""
# use configdir if available
if self.configdir is not None and conf_var is None:
path = pathlib.Path(self.configdir, '{}.yaml'.format(prefix))
if conf_var is None:
cd = self.configdir or '.'
path = pathlib.Path(cd, '{}.yaml'.format(prefix))
if path.exists():
return path
path = pathlib.Path(self.configdir, '{}.yml'.format(prefix))
path = pathlib.Path(cd, '{}.yml'.format(prefix))
if path.exists():
return path
return pathlib.Path(self.configdir, '{}.json'.format(prefix))
return pathlib.Path(cd, '{}.json'.format(prefix))
else:
return conf_var
@ -556,7 +557,8 @@ def _configdir_option(f):
help='Configuration directory where all configuration files can be '
'found. Each config file must be named exactly the same as the '
'regular switch option, e.g., pool.yaml for --pool. Individually '
'specified config options take precedence over this option.',
'specified config options take precedence over this option. This '
'defaults to "." if no other configuration option is specified.',
callback=callback)(f)