Incorporate values.py review feedback from PR#49
This commit is contained in:
parent
9e8b120204
commit
b56bfa8abf
@ -79,19 +79,19 @@ def parse_args():
|
|||||||
ap.add_argument('-d', '--debug', action='store_true',
|
ap.add_argument('-d', '--debug', action='store_true',
|
||||||
default=False, help='Enable debugging')
|
default=False, help='Enable debugging')
|
||||||
ap.add_argument('-y', '--yaml', action='store',
|
ap.add_argument('-y', '--yaml', action='store',
|
||||||
help='Path to Master YAML File')
|
required=True, help='Path to Master YAML File')
|
||||||
return ap.parse_args()
|
return ap.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def setup_logging(args):
|
def setup_logging(args):
|
||||||
level = logging.INFO
|
level = logging.DEBUG if args.debug else logging.INFO
|
||||||
if args.debug:
|
|
||||||
level = logging.DEBUG
|
|
||||||
logging.basicConfig(level=level, format=LOG_FORMAT, date_fmt=LOG_DATE)
|
logging.basicConfig(level=level, format=LOG_FORMAT, date_fmt=LOG_DATE)
|
||||||
handler = SysLogHandler(address='/dev/log')
|
handler = SysLogHandler(address='/dev/log')
|
||||||
syslog_formatter = logging.Formatter('%(name)s: %(levelname)s %(message)s')
|
syslog_formatter = logging.Formatter('%(name)s: %(levelname)s %(message)s')
|
||||||
handler.setFormatter(syslog_formatter)
|
handler.setFormatter(syslog_formatter)
|
||||||
LOG.addHandler(handler)
|
LOG.addHandler(handler)
|
||||||
|
|
||||||
|
|
||||||
def is_path_creatable(pathname):
|
def is_path_creatable(pathname):
|
||||||
'''
|
'''
|
||||||
`True` if the current user has sufficient permissions to create the passed
|
`True` if the current user has sufficient permissions to create the passed
|
||||||
@ -102,6 +102,7 @@ def is_path_creatable(pathname):
|
|||||||
dirname = os.path.dirname(pathname) or os.getcwd()
|
dirname = os.path.dirname(pathname) or os.getcwd()
|
||||||
return os.access(dirname, os.W_OK)
|
return os.access(dirname, os.W_OK)
|
||||||
|
|
||||||
|
|
||||||
def process_yaml(yaml_path):
|
def process_yaml(yaml_path):
|
||||||
'''
|
'''
|
||||||
Processes YAML file and generates breakdown of top level
|
Processes YAML file and generates breakdown of top level
|
||||||
@ -111,6 +112,7 @@ def process_yaml(yaml_path):
|
|||||||
# perform some basic validation
|
# perform some basic validation
|
||||||
if not os.path.isfile(yaml_path):
|
if not os.path.isfile(yaml_path):
|
||||||
LOG.exception("The path %s does not point to a valid file", yaml_path)
|
LOG.exception("The path %s does not point to a valid file", yaml_path)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
tmp_dir = tempfile.mkdtemp(prefix='helm', dir='/tmp')
|
tmp_dir = tempfile.mkdtemp(prefix='helm', dir='/tmp')
|
||||||
|
|
||||||
@ -131,13 +133,13 @@ def process_yaml(yaml_path):
|
|||||||
else:
|
else:
|
||||||
LOG.exception("Unable to create path %s based on top level key in %s" % (top_level_path, yaml_path))
|
LOG.exception("Unable to create path %s based on top level key in %s" % (top_level_path, yaml_path))
|
||||||
|
|
||||||
def run(args):
|
|
||||||
|
|
||||||
if args.yaml:
|
def run(args):
|
||||||
|
|
||||||
LOG.info("Processing YAML file %s", args.yaml)
|
LOG.info("Processing YAML file %s", args.yaml)
|
||||||
process_yaml(args.yaml)
|
process_yaml(args.yaml)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
@ -149,3 +151,4 @@ if __name__ == '__main__':
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
LOG.exception(err)
|
LOG.exception(err)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user