Project

General

Profile

Refactor #92

"unattended" setting value counter intuitive

Added by Martin Englund over 9 years ago. Updated about 9 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
Unattended installations
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

You have to set

:unattended: true

if you want to disable the unattended installs, which makes the following code look awkward:
# do not show these fields if unattended mode is disabled
unless $settings[:unattended]
  ...
end

History

#1 Updated by Ohad Levy over 9 years ago

I agree, any recommendations ? how does build sounds?

#2 Updated by Ohad Levy about 9 years ago

  • Assignee changed from Ohad Levy to Paul Kelly

#3 Updated by Paul Kelly about 9 years ago

  • Status changed from New to Resolved

The whole SETTINGS thing was a bit clunky so I have introduced a facility to read the settings.yaml file and then dynamically create a module with class methods matching the names. This means that:-
:tftppath: /tftp
maps to
Foreman.tftp
and I have added a query function for booleans so that
:failed_email_report_notification:
maps to both
Foreman.failed_email_report_notification
Foreman.failed_email_report_notification?
NOTE that you should not try and assign to the query interface, (Foreman.setting?=value,) but should Foreman.setting=value
I also added support for cascading settings so that
:manage:
- nodes : true # This will always be true if you want anything to work
- build : false # indicates whether we should also manage the build lifecycle?
maps to
Foreman.manage_nodes?
Foreman.manage_build?

This implementation requires that if you wish to use a setting you are required to declare it in the settings.yaml file. This is a good idea anyway as this is also documentation. If you want to use a default value in the code, unless you override this in the settings file, then set the value to false in settings.yam. The code then go
var = Foreman.setting || "hardcoded_default"

I have also updated the settings file to show the defaults from the program. (Where I can, and there is one.)

The code can be found at refactor/92 @ my github along with a replacement of all SETTINGS entries throughout the codebase.

Also available in: Atom PDF