app: update app_install

This commit is contained in:
axolotle 2023-04-17 16:20:52 +02:00
parent c428ba616a
commit 3ff6e6ed96

View file

@ -1098,13 +1098,9 @@ def app_install(
app_setting_path = os.path.join(APPS_SETTING_PATH, app_instance_name) app_setting_path = os.path.join(APPS_SETTING_PATH, app_instance_name)
# Retrieve arguments list for install script # Retrieve arguments list for install script
raw_questions = manifest["install"] raw_options = manifest["install"]
questions = ask_questions_and_parse_answers(raw_questions, prefilled_answers=args) options, form = ask_questions_and_parse_answers(raw_options, prefilled_answers=args)
args = { args = form.dict(exclude_none=True)
question.id: question.value
for question in questions
if not question.readonly and question.value is not None
}
# Validate domain / path availability for webapps # Validate domain / path availability for webapps
# (ideally this should be handled by the resource system for manifest v >= 2 # (ideally this should be handled by the resource system for manifest v >= 2
@ -1141,15 +1137,15 @@ def app_install(
"current_revision": manifest.get("remote", {}).get("revision", "?"), "current_revision": manifest.get("remote", {}).get("revision", "?"),
} }
# If packaging_format v2+, save all install questions as settings # If packaging_format v2+, save all install options as settings
if packaging_format >= 2: if packaging_format >= 2:
for question in questions: for option in options:
# Except user-provider passwords # Except user-provider passwords
# ... which we need to reinject later in the env_dict # ... which we need to reinject later in the env_dict
if question.type == "password": if option.type == "password":
continue continue
app_settings[question.id] = question.value app_settings[option.id] = form[option.id]
_set_app_settings(app_instance_name, app_settings) _set_app_settings(app_instance_name, app_settings)
@ -1202,23 +1198,23 @@ def app_install(
app_instance_name, args=args, workdir=extracted_app_folder, action="install" app_instance_name, args=args, workdir=extracted_app_folder, action="install"
) )
# If packaging_format v2+, save all install questions as settings # If packaging_format v2+, save all install options as settings
if packaging_format >= 2: if packaging_format >= 2:
for question in questions: for option in options:
# Reinject user-provider passwords which are not in the app settings # Reinject user-provider passwords which are not in the app settings
# (cf a few line before) # (cf a few line before)
if question.type == "password": if option.type == "password":
env_dict[question.id] = question.value env_dict[option.id] = form[option.id]
# We want to hav the env_dict in the log ... but not password values # We want to hav the env_dict in the log ... but not password values
env_dict_for_logging = env_dict.copy() env_dict_for_logging = env_dict.copy()
for question in questions: for option in options:
# Or should it be more generally question.redact ? # Or should it be more generally option.redact ?
if question.type == "password": if option.type == "password":
if f"YNH_APP_ARG_{question.id.upper()}" in env_dict_for_logging: if f"YNH_APP_ARG_{option.id.upper()}" in env_dict_for_logging:
del env_dict_for_logging[f"YNH_APP_ARG_{question.id.upper()}"] del env_dict_for_logging[f"YNH_APP_ARG_{option.id.upper()}"]
if question.id in env_dict_for_logging: if option.id in env_dict_for_logging:
del env_dict_for_logging[question.id] del env_dict_for_logging[option.id]
operation_logger.extra.update({"env": env_dict_for_logging}) operation_logger.extra.update({"env": env_dict_for_logging})