Skip to content
Snippets Groups Projects
Commit 12087708 authored by Martin Bergemann's avatar Martin Bergemann :speech_balloon:
Browse files

Merge branch 'load_run_from_config' into 'master'

Load run form setup from config file.

See merge request !32
parents 382f48c2 c7ff7a3b
No related branches found
No related tags found
1 merge request!32Load run form setup from config file.
Pipeline #20101 passed
...@@ -744,6 +744,7 @@ class RunForm(npyscreen.FormMultiPageAction): ...@@ -744,6 +744,7 @@ class RunForm(npyscreen.FormMultiPageAction):
def on_cancel(self) -> None: def on_cancel(self) -> None:
"""Define what happens after the the cancel button is hit.""" """Define what happens after the the cancel button is hit."""
name = self.parentApp.current_form.lower() name = self.parentApp.current_form.lower()
self.parentApp.setup = {}
for step, form_name in self.parentApp._steps_lookup.items(): for step, form_name in self.parentApp._steps_lookup.items():
if name.startswith(step): if name.startswith(step):
# Tell the MyTestApp object to change forms. # Tell the MyTestApp object to change forms.
...@@ -761,11 +762,14 @@ class RunForm(npyscreen.FormMultiPageAction): ...@@ -761,11 +762,14 @@ class RunForm(npyscreen.FormMultiPageAction):
def _add_widgets(self) -> None: def _add_widgets(self) -> None:
"""Add the widgets to the form.""" """Add the widgets to the form."""
project_name = self.parentApp.config.get(
"project_name", self.parentApp._read_cache("project_name", "")
)
ssh_pw = self.parentApp._read_cache("ssh_pw", True) ssh_pw = self.parentApp._read_cache("ssh_pw", True)
self.project_name = self.add_widget_intelligent( self.project_name = self.add_widget_intelligent(
npyscreen.TitleText, npyscreen.TitleText,
name=f"{self.num}Set the name of the project", name=f"{self.num}Set the name of the project",
value=self.parentApp._read_cache("project_name", ""), value=project_name,
) )
self.inventory_file = self.add_widget_intelligent( self.inventory_file = self.add_widget_intelligent(
npyscreen.TitleFilename, npyscreen.TitleFilename,
......
...@@ -228,6 +228,9 @@ class MainApp(npyscreen.NPSAppManaged): ...@@ -228,6 +228,9 @@ class MainApp(npyscreen.NPSAppManaged):
def read_cert_file(self, key: str) -> str: def read_cert_file(self, key: str) -> str:
"""Read the certificate file from the cache.""" """Read the certificate file from the cache."""
cert_file = cast(str, self.config.get("certificates", {}).get(key, ""))
if cert_file:
return cert_file
return cast(str, self._read_cache(key, "")) return cast(str, self._read_cache(key, ""))
@property @property
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment