netbox-docker icon indicating copy to clipboard operation
netbox-docker copied to clipboard

Remove hardcoded configurations

Open benwa opened this issue 2 years ago • 3 comments

Related Issue:

New Behavior

All of the Dynamic Configuration Settings are available out of the box.

Contrast to Current Behavior

Only a few DCS' were available. To use them, one had to modify configuration.py

Discussion: Benefits and Drawbacks

This allows users to utilize the awesomeness that is DCS

Changes to the Wiki

Proposed Release Note Entry

Enable the user of Dynamic Configuration Settings out of the box

Double Check

  • [x] I have read the comments and followed the PR template.
  • [x] I have explained my PR according to the information in the comments.
  • [x] My PR targets the develop branch.

benwa avatar Aug 03 '22 21:08 benwa

I'm unsure if removing them is the right way. People may rely on these settings being configurable via environment variables. Perhaps a better way forward would be to check whether the relevant env variable exists, and only if it does, then set the variable:

# …

if 'BANNER_TOP' in environ:
  BANNER_TOP = environ.get('BANNER_TOP', '')
if 'BANNER_BOTTOM' in environ:
  BANNER_BOTTOM = environ.get('BANNER_BOTTOM', '')

# …

Would that also suit the purpose, @benwa?

cimnine avatar Aug 30 '22 13:08 cimnine

Would perhaps replacing the default value '' with None for the relevant variables work already? Like this:

BANNER_TOP = environ.get('BANNER_TOP', None)
BANNER_BOTTOM = environ.get('BANNER_BOTTOM', None)

cimnine avatar Aug 30 '22 13:08 cimnine

Would perhaps replacing the default value '' with None for the relevant variables work already? Like this:

BANNER_TOP = environ.get('BANNER_TOP', None)
BANNER_BOTTOM = environ.get('BANNER_BOTTOM', None)

This won't work because then those variables are set in the settings object and found when the dynamic configuration is loaded. Only when the variables are not set at all they are pulled from the dynamic configuration (see here, this works in a similar way to our configuration.docker.py.). So the working implementation is from your previous comment.

tobiasge avatar Aug 31 '22 14:08 tobiasge

Obsoleted by #857

cimnine avatar Oct 15 '22 10:10 cimnine