config: add DCOS_DIR env var (#939)
This commit is contained in:
@@ -25,10 +25,13 @@ Options:
|
|||||||
Environment Variables:
|
Environment Variables:
|
||||||
DCOS_CONFIG
|
DCOS_CONFIG
|
||||||
Set the path to the DC/OS configuration file. By default, this variable
|
Set the path to the DC/OS configuration file. By default, this variable
|
||||||
is set to ~/.dcos/dcos.toml.
|
is set to $DCOS_DIR/dcos.toml.
|
||||||
DCOS_DEBUG
|
DCOS_DEBUG
|
||||||
Indicates whether to print additional debug messages to stdout. By
|
Indicates whether to print additional debug messages to stdout. By
|
||||||
default this is set to false.
|
default this is set to false.
|
||||||
|
DCOS_DIR
|
||||||
|
Set the data directory for DC/OS configuration. By default, this
|
||||||
|
variable is set to ~/.dcos
|
||||||
DCOS_LOG_LEVEL
|
DCOS_LOG_LEVEL
|
||||||
Prints log messages to stderr at or above the level indicated. This is
|
Prints log messages to stderr at or above the level indicated. This is
|
||||||
equivalent to the --log-level command-line option.
|
equivalent to the --log-level command-line option.
|
||||||
|
|||||||
@@ -22,6 +22,17 @@ def get_config_path():
|
|||||||
return os.environ.get(constants.DCOS_CONFIG_ENV, get_default_config_path())
|
return os.environ.get(constants.DCOS_CONFIG_ENV, get_default_config_path())
|
||||||
|
|
||||||
|
|
||||||
|
def get_config_dir_path():
|
||||||
|
"""
|
||||||
|
:returns: path to the DC/OS data directory
|
||||||
|
:rtype: str
|
||||||
|
"""
|
||||||
|
|
||||||
|
config_dir = os.environ.get(constants.DCOS_DIR_ENV) or \
|
||||||
|
os.path.join("~", constants.DCOS_DIR)
|
||||||
|
return os.path.expanduser(config_dir)
|
||||||
|
|
||||||
|
|
||||||
def get_default_config_path():
|
def get_default_config_path():
|
||||||
"""Returns the default path to the DCOS config file.
|
"""Returns the default path to the DCOS config file.
|
||||||
|
|
||||||
@@ -29,10 +40,7 @@ def get_default_config_path():
|
|||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return os.path.expanduser(
|
return os.path.join(get_config_dir_path(), 'dcos.toml')
|
||||||
os.path.join("~",
|
|
||||||
constants.DCOS_DIR,
|
|
||||||
'dcos.toml'))
|
|
||||||
|
|
||||||
|
|
||||||
def get_config(mutable=False):
|
def get_config(mutable=False):
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
DCOS_DIR = ".dcos"
|
DCOS_DIR = ".dcos"
|
||||||
"""DC/OS data directory. Can store subcommands and the config file."""
|
"""DC/OS data directory. Can store subcommands and the config file."""
|
||||||
|
|
||||||
|
DCOS_DIR_ENV = 'DCOS_DIR'
|
||||||
|
"""Name of the environment variable pointing to the DC/OS data directory"""
|
||||||
|
|
||||||
DCOS_SUBCOMMAND_ENV_SUBDIR = 'env'
|
DCOS_SUBCOMMAND_ENV_SUBDIR = 'env'
|
||||||
"""In a package's directory, this is the cli contents subdirectory."""
|
"""In a package's directory, this is the cli contents subdirectory."""
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from distutils.version import LooseVersion
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from dcos import constants, util
|
from dcos import config, constants, util
|
||||||
from dcos.errors import DCOSException
|
from dcos.errors import DCOSException
|
||||||
from dcos.subprocess import Subproc
|
from dcos.subprocess import Subproc
|
||||||
|
|
||||||
@@ -358,10 +358,10 @@ def install(pkg):
|
|||||||
|
|
||||||
|
|
||||||
def _subcommand_dir():
|
def _subcommand_dir():
|
||||||
""" Returns ~/.dcos/subcommands """
|
""" Returns subcommand dir. defaults to ~/.dcos/subcommands """
|
||||||
return os.path.expanduser(os.path.join("~",
|
|
||||||
constants.DCOS_DIR,
|
return os.path.join(config.get_config_dir_path(),
|
||||||
constants.DCOS_SUBCOMMAND_SUBDIR))
|
constants.DCOS_SUBCOMMAND_SUBDIR)
|
||||||
|
|
||||||
|
|
||||||
def _package_dir(name):
|
def _package_dir(name):
|
||||||
|
|||||||
Reference in New Issue
Block a user