Improve error handling for project root dir, add ENV support for project root
This commit is contained in:
parent
7a13e11426
commit
6cadc18397
@ -2,7 +2,7 @@ import logging
|
||||
|
||||
__author__ = "Stefan Reimer"
|
||||
__email__ = "stefan@zero-downtimet.net"
|
||||
__version__ = "0.7.6"
|
||||
__version__ = "0.7.7"
|
||||
|
||||
|
||||
# Set up logging to ``/dev/null`` like a library is supposed to.
|
||||
|
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import sys
|
||||
import click
|
||||
import functools
|
||||
|
||||
@ -7,6 +8,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from . import __version__
|
||||
from .core import CloudBender
|
||||
from .utils import setup_logging
|
||||
from .exceptions import InvalidProjectDir
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -24,11 +26,18 @@ def cli(ctx, debug, directory):
|
||||
if directory:
|
||||
if not os.path.isabs(directory):
|
||||
directory = os.path.normpath(os.path.join(os.getcwd(), directory))
|
||||
elif os.getenv('CLOUDBENDER_PROJECT_ROOT'):
|
||||
directory = os.getenv('CLOUDBENDER_PROJECT_ROOT')
|
||||
else:
|
||||
directory = os.getcwd()
|
||||
|
||||
# Read global config
|
||||
try:
|
||||
cb = CloudBender(directory)
|
||||
except InvalidProjectDir as e:
|
||||
print(e)
|
||||
sys.exit(1)
|
||||
|
||||
cb.read_config()
|
||||
cb.dump_config()
|
||||
|
||||
|
@ -4,6 +4,7 @@ import logging
|
||||
from .utils import ensure_dir
|
||||
from .stackgroup import StackGroup
|
||||
from .jinja import read_config_file
|
||||
from .exceptions import InvalidProjectDir
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -22,7 +23,7 @@ class CloudBender(object):
|
||||
}
|
||||
|
||||
if not os.path.isdir(self.ctx['config_path']):
|
||||
raise "Check '{0}' exists and is a valid project folder.".format(root_path)
|
||||
raise InvalidProjectDir("Check '{0}' exists and is a valid CloudBender project folder.".format(root_path))
|
||||
|
||||
def read_config(self):
|
||||
"""Load the <path>/config.yaml, <path>/*.yaml as stacks, sub-folders are sub-groups """
|
||||
|
@ -4,3 +4,7 @@ class ParameterNotFound(Exception):
|
||||
|
||||
class ParameterIllegalValue(Exception):
|
||||
"""My documentation"""
|
||||
|
||||
|
||||
class InvalidProjectDir(BaseException):
|
||||
"""My documentation"""
|
||||
|
@ -270,7 +270,7 @@ class Stack(object):
|
||||
|
||||
# Ignore checks regarding overloaded properties
|
||||
if self.mode == "CloudBender":
|
||||
ignore_checks = ignore_checks + ['E3035', 'E3002', 'E3012', 'W2001', 'E3001']
|
||||
ignore_checks = ignore_checks + ['E3035', 'E3002', 'E3012', 'W2001', 'E3001', 'E0002', 'E1012']
|
||||
|
||||
filename = os.path.join(self.ctx['template_path'], self.rel_path, self.stackname + ".yaml")
|
||||
logger.info('Validating {0}'.format(filename))
|
||||
|
Loading…
Reference in New Issue
Block a user