Skip to content

Commit 2d43610

Browse files
committed
allow for shpc config edit even if config file has an error
this is do-able because we disable validation when edit is being used. Signed-off-by: vsoch <[email protected]>
1 parent 5e2b88a commit 2d43610

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

shpc/client/config.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ def main(args, parser, extra, subparser):
1010

1111
from shpc.main import get_client
1212

13-
cli = get_client(quiet=args.quiet, settings_file=args.settings_file)
14-
1513
# If nothing provided, show help
1614
if not args.params:
1715
print(subparser.format_help())
@@ -20,6 +18,11 @@ def main(args, parser, extra, subparser):
2018
# The first "param" is either set of get
2119
command = args.params.pop(0)
2220

21+
validate = True if not command == "edit" else False
22+
cli = get_client(
23+
quiet=args.quiet, settings_file=args.settings_file, validate=validate
24+
)
25+
2326
# For each new setting, update and save!
2427
if command == "edit":
2528
return cli.settings.edit()

shpc/main/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ def get_client(quiet=False, **kwargs):
2121
"""
2222
# The name of the module
2323
module = kwargs.get("module")
24+
validate = kwargs.get("validate", True)
2425

2526
# Load user settings to add to client, and container technology
26-
settings = Settings(kwargs.get("settings_file"))
27+
settings = Settings(kwargs.get("settings_file"), validate)
2728
container = kwargs.get("container_tech") or settings.container_tech
2829

2930
# Use the user provided module OR the default

shpc/main/modules/templates/docker.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ proc ModulesHelp { } {
1919
puts stderr " - {|module_name|}-shell:"
2020
puts stderr " {{ command }} run -i{% if tty %}t{% endif %} -u `id -u`:`id -g` --rm --entrypoint {{ shell }}{% if envfile %} --env-file {{ module_dir }}/{{ envfile }}{% endif %} {% if bindpaths %}-v {{ bindpaths }} {% endif %} -v . -w . <container>"
2121
puts stderr " - {|module_name|}-exec:"
22-
puts stderr " {{ command }} run -i{% if tty %}t{% endif %} -u `id -u`:`id -g` --rm --entrypoint {{ shell }}{% if envfile %} --env-file {{ module_dir }}/{{ envfile }}{% endif %} {% if bindpaths %}-v {{ bindpaths }} {% endif %} -v . -w . <container> $*"
22+
puts stderr " {{ command }} run -i{% if tty %}t{% endif %} -u `id -u`:`id -g` --rm --entrypoint \"\" {% if envfile %} --env-file {{ module_dir }}/{{ envfile }}{% endif %} {% if bindpaths %}-v {{ bindpaths }} {% endif %} -v . -w . <container> $*"
2323
puts stderr " - {|module_name|}-inspect:"
2424
puts stderr " {{ command }} inspect <container>"
2525
{% if aliases %}{% for alias in aliases %} puts stderr " - {{ alias.name }}:"

shpc/main/settings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,13 @@ class Settings(SettingsBase):
141141
a dictionary-like class with extra functions.
142142
"""
143143

144-
def __init__(self, settings_file):
144+
def __init__(self, settings_file, validate=True):
145145
"""
146146
Create a new settings object, which requires a settings file to load
147147
"""
148148
self.load(settings_file)
149-
self.validate()
149+
if validate:
150+
self.validate()
150151

151152
# Set an updated time, in case it's written back to file
152153
self._settings["updated_at"] = datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")

0 commit comments

Comments
 (0)