Allow dynamic configuration/overrides for API connection (for testing, for command line option support etc)

Created on 11 April 2024, 3 months ago
Updated 2 May 2024, about 2 months ago

Problem/Motivation

While testing Orange Logic (quarterly upgrades, for example), it is useful to be able to compare the returned data from various server endpoints and sessions. Having to change configuration every time the test source needs to change is onerous, and, in some instances (such as non-writable filesystems) impossible.

I tried to use an instance of ConfigFactoryOverrideInterface to allow for temporarily overriding the configuration from the command line, but two things blocked this from working: 1) OrangeDamApi doesn't just instantiate a configFactory in its constructor, but also loads an immutable config at instantiation time, rather than at the time it is being used, meaning that any provided dynamic overrides are "too late". 2) Even if OrangeDamApi loaded its config only at the time it is needed, it would still be impossible to override anything that might have been set in a settings.php file.

Steps to reproduce

1. Create an instance of a ConfigFactoryOverrideInterface.
2. Use this instance to override the installed configuration, for, say, the orange_dam.settings base_path.
3. See that OrangeDamApi uses the config loaded at construction, rather than the config provided via your override interface.

Proposed resolution

One solution would be to modify the OrangeDamApi constructor to only instantiate the configFactory, and not load the actual config. But this still leaves us unable to override any configuration that might have been set in settings files.

The more flexible (but also more ad hoc) solution is to provide a public configOverride() method to OrangeDamApi allowing the configuration to be injected before instantiating the Orange Dam client.

Remaining tasks

Create a merge request showing the changes in suggestion 2.

User interface changes

none

API changes

The addition of a new method allowing for run-time re-configuration of the orange dam client.

Data model changes

none

✨ Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States apotek

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024