pulp_ansible icon indicating copy to clipboard operation
pulp_ansible copied to clipboard

[fix] Use Dynaconf lazy variables insted of re-importing the settings.

Open rochacbruno opened this issue 1 year ago • 16 comments

Instead of doing from dynaconf import settings which causes the whole settings load to be executed again, it is better to use the support for lazy evaluation and formatting https://www.dynaconf.com/dynamic/#format-token so it is possible to define a variable that is a template to be formed from interpolation with other in settings variables.

So inside a settings file that is managed by dynaconf like:

from dynaconf import settings
FOO = settings.BAR + "/zaz"

It is better to do

FOO = "@format {this.BAR}/zaz"

or if Jinja powers is needed

FOO = "@jinja {{ this.BAR }}/zaz"

This way there is no need to reload all the settings and avoids circular dependencies.

[noissue]

rochacbruno avatar Jul 21 '22 15:07 rochacbruno